From c02f39778f48656ebb0d2d60b720ecb7c717d270 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 16 May 2023 11:58:52 -0700 Subject: [PATCH] Prepare for tx --- core/state/interface.go | 2 +- core/state/statedb.go | 4 ++-- core/state_transition.go | 2 +- core/vm/runtime/runtime.go | 6 +++--- tests/state_test.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/state/interface.go b/core/state/interface.go index 0f8b797344d2..5569c323eb52 100644 --- a/core/state/interface.go +++ b/core/state/interface.go @@ -71,7 +71,7 @@ type StateDBI interface { // AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform // even if the feature/fork is not active yet AddSlotToAccessList(addr common.Address, slot common.Hash) - Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) + PrepareForTx(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList) RevertToSnapshot(int) Snapshot() int diff --git a/core/state/statedb.go b/core/state/statedb.go index b92ad1035f02..cf77da4382f3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1080,7 +1080,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { return root, nil } -// Prepare handles the preparatory steps for executing a state transition with. +// PrepareForTx handles the preparatory steps for executing a state transition with. // This method must be invoked before state transition. // // Berlin fork: @@ -1093,7 +1093,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { // - Reset access list (Berlin) // - Add coinbase to access list (EIP-3651) // - Reset transient storage (EIP-1153) -func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) { +func (s *StateDB) PrepareForTx(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) { if rules.IsBerlin { // Clear out any leftover from previous executions al := NewAccessList() diff --git a/core/state_transition.go b/core/state_transition.go index 394264bf840d..eb6d56f3c09d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -361,7 +361,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) // - reset transient storage(eip 1153) - st.state.Prepare(rules, msg.From, st.evm.Context.Coinbase, msg.To, st.evm.PrecompileManager.GetActive(&rules), msg.AccessList) + st.state.PrepareForTx(rules, msg.From, st.evm.Context.Coinbase, msg.To, st.evm.PrecompileManager.GetActive(&rules), msg.AccessList) var ( ret []byte diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 8927d3b7bca7..1b7029bca1be 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -118,7 +118,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, state.StateDBI, error) { // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) // - reset transient storage(eip 1153) - cfg.State.Prepare(rules, cfg.Origin, cfg.Coinbase, &address, vmenv.PrecompileManager.GetActive(&rules), nil) + cfg.State.PrepareForTx(rules, cfg.Origin, cfg.Coinbase, &address, vmenv.PrecompileManager.GetActive(&rules), nil) cfg.State.CreateAccount(address) // set the receiver's (the executing contract) code for execution. cfg.State.SetCode(address, code) @@ -151,7 +151,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) { // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) // - reset transient storage(eip 1153) - cfg.State.Prepare(rules, cfg.Origin, cfg.Coinbase, nil, vmenv.PrecompileManager.GetActive(&rules), nil) + cfg.State.PrepareForTx(rules, cfg.Origin, cfg.Coinbase, nil, vmenv.PrecompileManager.GetActive(&rules), nil) // Call the code with the given configuration. code, address, leftOverGas, err := vmenv.Create( sender, @@ -179,7 +179,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) // - reset transient storage(eip 1153) - statedb.Prepare(rules, cfg.Origin, cfg.Coinbase, &address, vmenv.PrecompileManager.GetActive(&rules), nil) + statedb.PrepareForTx(rules, cfg.Origin, cfg.Coinbase, &address, vmenv.PrecompileManager.GetActive(&rules), nil) // Call the code with the given configuration. ret, leftOverGas, err := vmenv.Call( diff --git a/tests/state_test.go b/tests/state_test.go index 4ad177d07759..4845cac2c20d 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -239,7 +239,7 @@ func runBenchmark(b *testing.B, t *StateTest) { b.ResetTimer() for n := 0; n < b.N; n++ { snapshot := statedb.Snapshot() - statedb.Prepare(rules, msg.From, context.Coinbase, msg.To, evm.PrecompileManager.GetActive(&rules), msg.AccessList) + statedb.PrepareForTx(rules, msg.From, context.Coinbase, msg.To, evm.PrecompileManager.GetActive(&rules), msg.AccessList) b.StartTimer() start := time.Now()