Skip to content

Commit

Permalink
Correctly handle out of gas panics leading to problem in defer
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed Dec 10, 2024
1 parent 1c87c2b commit d080d7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,22 @@ func (k *Keeper) applyEVMMessageWithTracing(
}
if onEnd != nil {
defer func() {
onEnd(res, err)
r := recover()

if r != nil {
var recoveredErr error
if err, ok := r.(error); ok {
recoveredErr = err
} else {
// Not of type error, create a new dummy one
recoveredErr = fmt.Errorf("%v", r)
}

onEnd(nil, recoveredErr)
panic(r)
} else {
onEnd(res, err)
}
}()
}

Expand Down
4 changes: 4 additions & 0 deletions x/evm/tracers/firehose.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ func getActivePrecompilesChecker(rules params.Rules) func(addr common.Address) b
}

func (f *Firehose) OnBlockEnd(err error) {
if f.block.Number >= 119822071 {
panic("Do not go above 119822071 for now")
}

blockNumber := f.block.Number
firehoseInfo("block ending (number=%d, trx=%d, err=%s)", blockNumber, len(f.block.TransactionTraces), errorView(err))

Expand Down

0 comments on commit d080d7a

Please sign in to comment.