Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch the out of gas exception in preprocess #2638

Merged
merged 9 commits into from
Dec 10, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"sync/atomic"

"github.com/gnolang/gno/tm2/pkg/errors"
tmstore "github.com/gnolang/gno/tm2/pkg/store"
)

const (
Expand Down Expand Up @@ -117,6 +118,10 @@
_ = Transcribe(bn, func(ns []Node, ftype TransField, index int, n Node, stage TransStage) (Node, TransCtrl) {
defer func() {
if r := recover(); r != nil {
// Catch the out-of-gas exception and throw it
if _, ok := r.(tmstore.OutOfGasException); ok {
panic(r)

Check warning on line 123 in gnovm/pkg/gnolang/preprocess.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/preprocess.go#L123

Added line #L123 was not covered by tests
}
// before re-throwing the error, append location information to message.
loc := last.GetLocation()
if nline := n.GetLine(); nline > 0 {
Expand Down Expand Up @@ -393,6 +398,10 @@

defer func() {
if r := recover(); r != nil {
// Catch the out-of-gas exception and throw it
if _, ok := r.(tmstore.OutOfGasException); ok {
panic(r)

Check warning on line 403 in gnovm/pkg/gnolang/preprocess.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/preprocess.go#L403

Added line #L403 was not covered by tests
}
// before re-throwing the error, append location information to message.
loc := last.GetLocation()
if nline := n.GetLine(); nline > 0 {
Expand Down Expand Up @@ -3169,6 +3178,10 @@
func predefineNow(store Store, last BlockNode, d Decl) (Decl, bool) {
defer func() {
if r := recover(); r != nil {
// Catch the out-of-gas exception and throw it
if _, ok := r.(tmstore.OutOfGasException); ok {
panic(r)

Check warning on line 3183 in gnovm/pkg/gnolang/preprocess.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/preprocess.go#L3183

Added line #L3183 was not covered by tests
}
// before re-throwing the error, append location information to message.
loc := last.GetLocation()
if nline := d.GetLine(); nline > 0 {
Expand Down
Loading