From e61ee6c3cdd3d0d0af8657d5e6a88c312325c8ba Mon Sep 17 00:00:00 2001 From: shahafn Date: Sun, 18 Aug 2024 12:34:32 +0300 Subject: [PATCH] Revert excution when postOp reverts --- core/state_processor_rip7560.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index b36979eef2..d123efd8cc 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -336,6 +336,7 @@ func applyPaymasterPostOpFrame(vpr *ValidationPhaseResult, executionResult *Exec func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhaseResult, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, cfg vm.Config) (*types.Receipt, error) { // TODO: snapshot EVM - we will revert back here if postOp fails + snapshotId := statedb.Snapshot() blockContext := NewEVMBlockContext(header, bc, author) message, err := TransactionToMessage(vpr.Tx, types.MakeSigner(config, header.Number, header.Time), header.BaseFee) @@ -352,7 +353,9 @@ func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhase if len(vpr.PaymasterContext) != 0 { paymasterPostOpResult, err = applyPaymasterPostOpFrame(vpr, executionResult, evm, gp, statedb, header) } + // PostOp failed, reverting execution changes if err != nil { + statedb.RevertToSnapshot(snapshotId) return nil, err }