Skip to content

Commit

Permalink
not always revert to zero, but take a snapshot in the before the call…
Browse files Browse the repository at this point in the history
…/apply instead
  • Loading branch information
lmittmann committed Jul 31, 2023
1 parent 3069589 commit 81c2e8d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions w3vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func (v *VM) apply(msg *w3types.Message, isCall bool, tracer vm.EVMLogger) (*Rec
NoBaseFee: v.noBaseFee,
})

snap := v.db.Snapshot()

// apply the message to the evm
result, err := core.ApplyMessage(evm, coreMsg, gp)
if err != nil {
Expand Down Expand Up @@ -139,11 +141,11 @@ func (v *VM) apply(msg *w3types.Message, isCall bool, tracer vm.EVMLogger) (*Rec
receipt.ContractAddress = &contractAddr
}

if isCall {
v.db.RevertToSnapshot(0)
} else {
v.db.Finalise(false)
if isCall && !result.Failed() {
v.db.RevertToSnapshot(snap)
}
v.db.Finalise(false)

return receipt, receipt.Err
}

Expand Down

0 comments on commit 81c2e8d

Please sign in to comment.