From 09ac0941157ab83d64f35c195930ff0b83a29a43 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Thu, 1 Aug 2024 15:49:24 +0200 Subject: [PATCH] change param ordering --- cmd/evm/internal/t8ntool/execution.go | 2 +- core/state_processor.go | 4 ++-- core/state_processor_test.go | 4 ++-- eth/state_accessor.go | 2 +- eth/tracers/api.go | 8 ++++---- miner/worker.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index d39d3641f5..f2b9c573e4 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -202,7 +202,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, prevHash = pre.Env.BlockHashes[math.HexOrDecimal64(prevNumber)] evm = vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vmConfig) ) - core.ProcessParentBlockHash(statedb, evm, prevHash) + core.ProcessParentBlockHash(prevHash, evm, statedb) } for i := 0; txIt.Next(); i++ { tx, err := txIt.Tx() diff --git a/core/state_processor.go b/core/state_processor.go index 09feb79965..5a86931106 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -82,7 +82,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } if p.config.IsPrague(block.Number(), block.Time()) { // This should not underflow as genesis block is not processed. - ProcessParentBlockHash(statedb, vmenv, block.ParentHash()) + ProcessParentBlockHash(block.ParentHash(), vmenv, statedb) } // Iterate over and process the individual transactions for i, tx := range block.Transactions() { @@ -216,7 +216,7 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *stat // ProcessParentBlockHash stores the parent block hash in the history storage contract // as per EIP-2935. -func ProcessParentBlockHash(statedb *state.StateDB, vmenv *vm.EVM, prevHash common.Hash) { +func ProcessParentBlockHash(prevHash common.Hash, vmenv *vm.EVM, statedb *state.StateDB) { if vmenv.Config.Tracer != nil && vmenv.Config.Tracer.OnSystemCallStart != nil { vmenv.Config.Tracer.OnSystemCallStart() } diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 510cb5723a..4315093369 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -549,11 +549,11 @@ func TestProcessParentBlockHash(t *testing.T) { vmContext := NewEVMBlockContext(header, nil, &coinbase) evm := vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vm.Config{}) - ProcessParentBlockHash(statedb, evm, header.ParentHash) + ProcessParentBlockHash(header.ParentHash, evm, statedb) vmContext = NewEVMBlockContext(parent, nil, &coinbase) evm = vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vm.Config{}) - ProcessParentBlockHash(statedb, evm, parent.ParentHash) + ProcessParentBlockHash(parent.ParentHash, evm, statedb) // make sure that the state is correct if have := getParentBlockHash(statedb, 1); have != hashA { diff --git a/eth/state_accessor.go b/eth/state_accessor.go index 11ca44f767..94c4977376 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -243,7 +243,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block, if eth.blockchain.Config().IsPrague(block.Number(), block.Time()) { context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil) vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, eth.blockchain.Config(), vm.Config{}) - core.ProcessParentBlockHash(statedb, vmenv, block.ParentHash()) + core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb) } if txIndex == 0 && len(block.Transactions()) == 0 { return nil, vm.BlockContext{}, statedb, release, nil diff --git a/eth/tracers/api.go b/eth/tracers/api.go index d7155d00f7..9ee108d0f1 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -386,7 +386,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed if api.backend.ChainConfig().IsPrague(next.Number(), next.Time()) { context := core.NewEVMBlockContext(next.Header(), api.chainContext(ctx), nil) vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{}) - core.ProcessParentBlockHash(statedb, vmenv, next.ParentHash()) + core.ProcessParentBlockHash(next.ParentHash(), vmenv, statedb) } // Clean out any pending release functions of trace state. Note this // step must be done after constructing tracing state, because the @@ -541,7 +541,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config core.ProcessBeaconBlockRoot(*beaconRoot, vmenv, statedb) } if chainConfig.IsPrague(block.Number(), block.Time()) { - core.ProcessParentBlockHash(statedb, vm.NewEVM(vmctx, vm.TxContext{}, statedb, chainConfig, vm.Config{}), block.ParentHash()) + core.ProcessParentBlockHash(block.ParentHash(), vm.NewEVM(vmctx, vm.TxContext{}, statedb, chainConfig, vm.Config{}), statedb) } for i, tx := range block.Transactions() { if err := ctx.Err(); err != nil { @@ -624,7 +624,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac } if api.backend.ChainConfig().IsPrague(block.Number(), block.Time()) { vmenv := vm.NewEVM(blockCtx, vm.TxContext{}, statedb, api.backend.ChainConfig(), vm.Config{}) - core.ProcessParentBlockHash(statedb, vmenv, block.ParentHash()) + core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb) } for i, tx := range txs { // Generate the next state snapshot fast without tracing @@ -786,7 +786,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block } if chainConfig.IsPrague(block.Number(), block.Time()) { vmenv := vm.NewEVM(vmctx, vm.TxContext{}, statedb, chainConfig, vm.Config{}) - core.ProcessParentBlockHash(statedb, vmenv, block.ParentHash()) + core.ProcessParentBlockHash(block.ParentHash(), vmenv, statedb) } for i, tx := range block.Transactions() { // Prepare the transaction for un-traced execution diff --git a/miner/worker.go b/miner/worker.go index ea0f04eaf9..d38edd8249 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -203,7 +203,7 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error) if miner.chainConfig.IsPrague(header.Number, header.Time) { context := core.NewEVMBlockContext(header, miner.chain, nil) vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, miner.chainConfig, vm.Config{}) - core.ProcessParentBlockHash(env.state, vmenv, header.ParentHash) + core.ProcessParentBlockHash(header.ParentHash, vmenv, env.state) } return env, nil }