Skip to content

Commit

Permalink
add cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Jun 10, 2024
1 parent ca3d358 commit 9fdea2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT

defer func() {
if pe := recover(); pe != nil {
// there is not supposed to be any panic
stateDB.Cleanup()
// there is not supposed to be any panic (except from OCC)
debug.PrintStack()
ctx.Logger().Error(fmt.Sprintf("EVM PANIC: %s", pe))
telemetry.IncrCounter(1, types.ModuleName, "panics")
Expand Down
2 changes: 1 addition & 1 deletion x/evm/state/accesslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ func (s *DBImpl) getCurrentAccessList() *accessList {
}

func (s *DBImpl) saveAccessList(al *accessList) {
s.tempStateCurrent.transientAccessLists = al
// s.tempStateCurrent.transientAccessLists = al
}
11 changes: 7 additions & 4 deletions x/evm/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ func (s *DBImpl) SetEVM(evm *vm.EVM) {}
// to the database.
func (s *DBImpl) AddPreimage(_ common.Hash, _ []byte) {}

func (s *DBImpl) Cleanup() {
s.tempStateCurrent = nil
s.tempStatesHist = []*TemporaryState{}
s.logger = nil
s.snapshottedCtxs = nil
}

func (s *DBImpl) Finalize() (surplus sdk.Int, err error) {
if s.simulation {
panic("should never call finalize on a simulation DB")
}
defer func() {
s.tempStateCurrent = nil
s.tempStatesHist = []*TemporaryState{}
}()
if s.err != nil {
err = s.err
return
Expand Down

0 comments on commit 9fdea2b

Please sign in to comment.