diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 008108b32e..ed292d0beb 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -93,7 +93,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c } // Execute the message to preload the implicit touched states evm := vm.NewEVM(NewEVMBlockContext(header, p.chain, nil), stateCpy, p.config, cfg) - defer evm.Free() + defer evm.Release() // Convert the transaction into an executable message and pre-cache its sender msg, err := TransactionToMessage(tx, signer, header.BaseFee) diff --git a/core/state_processor.go b/core/state_processor.go index 2226038cb7..54ebbd047b 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -88,7 +88,7 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated // Apply pre-execution system calls. context = NewEVMBlockContext(header, p.chain, nil) evm := vm.NewEVM(context, tracingStateDB, config, cfg) - defer evm.Free() + defer evm.Release() if beaconRoot := block.BeaconRoot(); beaconRoot != nil { ProcessBeaconBlockRoot(*beaconRoot, evm) diff --git a/core/vm/evm.go b/core/vm/evm.go index 6fd4d96377..26b2f73a00 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -226,9 +226,9 @@ func (evm *EVM) Cancel() { evm.abort.Store(true) } -// Free returns some memory allocated by the EVM, should be called after the EVM was used +// Release returns some memory allocated by the EVM, should be called after the EVM was used // for the last time. Not necessary, but an improvement. -func (evm *EVM) Free() { +func (evm *EVM) Release() { returnStack(evm.arena) } diff --git a/eth/gasestimator/gasestimator.go b/eth/gasestimator/gasestimator.go index 2c13353f35..efb089d456 100644 --- a/eth/gasestimator/gasestimator.go +++ b/eth/gasestimator/gasestimator.go @@ -244,7 +244,7 @@ func run(ctx context.Context, call *core.Message, opts *Options) (*core.Executio evmContext.BlobBaseFee = new(big.Int) } evm := vm.NewEVM(evmContext, dirtyState, opts.Config, vm.Config{NoBaseFee: true}) - defer evm.Free() + defer evm.Release() // Monitor the outer context and interrupt the EVM upon cancellation. To avoid // a dangling goroutine until the outer estimation finishes, create an internal diff --git a/eth/state_accessor.go b/eth/state_accessor.go index f23dd5bfaf..a806a4fc56 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -247,7 +247,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block, // Insert parent beacon block root in the state as per EIP-4788. context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil) evm := vm.NewEVM(context, statedb, eth.blockchain.Config(), vm.Config{}) - defer evm.Free() + defer evm.Release() if beaconRoot := block.BeaconRoot(); beaconRoot != nil { core.ProcessBeaconBlockRoot(*beaconRoot, evm) } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index d669f64008..dae11b81de 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -379,7 +379,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed if api.backend.ChainConfig().IsPrague(next.Number(), next.Time()) { core.ProcessParentBlockHash(next.ParentHash(), evm) } - evm.Free() + evm.Release() // Clean out any pending release functions of trace state. Note this // step must be done after constructing tracing state, because the // tracing state of block next depends on the parent state and construction @@ -525,7 +525,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config deleteEmptyObjects = chainConfig.IsEIP158(block.Number()) ) evm := vm.NewEVM(vmctx, statedb, chainConfig, vm.Config{}) - defer evm.Free() + defer evm.Release() if beaconRoot := block.BeaconRoot(); beaconRoot != nil { core.ProcessBeaconBlockRoot(*beaconRoot, evm) } @@ -586,7 +586,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{}) - defer evm.Free() + defer evm.Release() if beaconRoot := block.BeaconRoot(); beaconRoot != nil { core.ProcessBeaconBlockRoot(*beaconRoot, evm) } @@ -676,7 +676,7 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat var failed error blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{}) - defer evm.Free() + defer evm.Release() txloop: for i, tx := range txs { @@ -762,7 +762,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block } evm := vm.NewEVM(vmctx, statedb, chainConfig, vm.Config{}) - defer evm.Free() + defer evm.Release() if beaconRoot := block.BeaconRoot(); beaconRoot != nil { core.ProcessBeaconBlockRoot(*beaconRoot, evm) } @@ -810,7 +810,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block tracer.OnTxStart(evm.GetVMContext(), tx, msg.From) } _, err = core.ApplyMessage(evm, msg, nil) - evm.Free() + evm.Release() if writer != nil { writer.Flush() } @@ -1005,7 +1005,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor } tracingStateDB := state.NewHookedState(statedb, tracer.Hooks) evm := vm.NewEVM(vmctx, tracingStateDB, api.backend.ChainConfig(), vm.Config{Tracer: tracer.Hooks, NoBaseFee: true}) - defer evm.Free() + defer evm.Release() if precompiles != nil { evm.SetPrecompiles(precompiles) } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index cfcc732164..e8669b86c6 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -775,7 +775,7 @@ func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *s blockContext.BlobBaseFee = new(big.Int) } evm := b.GetEVM(ctx, state, header, vmConfig, blockContext) - defer evm.Free() + defer evm.Release() if precompiles != nil { evm.SetPrecompiles(precompiles) } @@ -1391,7 +1391,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH evm.Context.BlobBaseFee = new(big.Int) } res, err := core.ApplyMessage(evm, msg, nil) - evm.Free() + evm.Release() if err != nil { return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction(types.LegacyTxType).Hash(), err) } diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index e0898a63d0..e3a14bf5d6 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -312,7 +312,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, tracingStateDB = state.NewHookedState(sim.state, hooks) } evm := vm.NewEVM(blockContext, tracingStateDB, sim.chainConfig, *vmConfig) - defer evm.Free() + defer evm.Release() // It is possible to override precompiles with EVM bytecode, or // move them to another address. if precompiles != nil { diff --git a/miner/worker.go b/miner/worker.go index 9b65fc5fd7..158f1b26c0 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -84,7 +84,7 @@ func (env *environment) txFitsSize(tx *types.Transaction) bool { func (env *environment) discard() { env.state.StopPrefetcher() if env.evm != nil { - env.evm.Free() + env.evm.Release() } }