From 1b9940486ee0e8e2e9d4ab8f77382fa1894ace6e Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Tue, 15 Oct 2024 10:11:44 -0600 Subject: [PATCH 1/2] Restore state test transction context In state tests when running prague system contracts the origin remains as the system account. Restore the prior tx context after running system contracts. --- core/state_processor.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/state_processor.go b/core/state_processor.go index c4e2bcf1e5..54b98a1b44 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -249,6 +249,7 @@ func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state. } } + oldContext := vmenv.TxContext msg := &Message{ From: params.SystemAddress, GasLimit: 30_000_000, @@ -262,6 +263,7 @@ func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state. statedb.AddAddressToAccessList(params.HistoryStorageAddress) _, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560) statedb.Finalise(true) + vmenv.Reset(oldContext, statedb) } // ParseDepositLogs extracts the EIP-6110 deposit values from logs emitted by From ff7ac5134824ee62b5514947b0adc55c03a2458d Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Tue, 15 Oct 2024 15:01:27 -0600 Subject: [PATCH 2/2] limit scope to state tests --- core/state_processor.go | 2 -- tests/state_test_util.go | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 54b98a1b44..c4e2bcf1e5 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -249,7 +249,6 @@ func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state. } } - oldContext := vmenv.TxContext msg := &Message{ From: params.SystemAddress, GasLimit: 30_000_000, @@ -263,7 +262,6 @@ func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state. statedb.AddAddressToAccessList(params.HistoryStorageAddress) _, _, _ = vmenv.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560) statedb.Finalise(true) - vmenv.Reset(oldContext, statedb) } // ParseDepositLogs extracts the EIP-6110 deposit values from logs emitted by diff --git a/tests/state_test_util.go b/tests/state_test_util.go index a03a622ead..1165463b02 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -299,11 +299,13 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh tracer.OnTxStart(evm.GetVMContext(), nil, msg.From) } + oldContext := evm.TxContext if config.IsPrague(new(big.Int), 0) { for i := int(block.Number().Uint64() - 1); i >= 0; i-- { core.ProcessParentBlockHash(vmTestBlockHash(uint64(i)), evm, st.StateDB) } } + evm.Reset(oldContext, st.StateDB) // Execute the message. snapshot := st.StateDB.Snapshot()