rename Free to Release

This commit is contained in:
Guillaume Ballet 2026-04-27 16:26:14 +02:00
parent 69ba0a07fa
commit 294c274b46
No known key found for this signature in database
9 changed files with 17 additions and 17 deletions

View file

@ -93,7 +93,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
} }
// Execute the message to preload the implicit touched states // Execute the message to preload the implicit touched states
evm := vm.NewEVM(NewEVMBlockContext(header, p.chain, nil), stateCpy, p.config, cfg) 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 // Convert the transaction into an executable message and pre-cache its sender
msg, err := TransactionToMessage(tx, signer, header.BaseFee) msg, err := TransactionToMessage(tx, signer, header.BaseFee)

View file

@ -88,7 +88,7 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated
// Apply pre-execution system calls. // Apply pre-execution system calls.
context = NewEVMBlockContext(header, p.chain, nil) context = NewEVMBlockContext(header, p.chain, nil)
evm := vm.NewEVM(context, tracingStateDB, config, cfg) evm := vm.NewEVM(context, tracingStateDB, config, cfg)
defer evm.Free() defer evm.Release()
if beaconRoot := block.BeaconRoot(); beaconRoot != nil { if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
ProcessBeaconBlockRoot(*beaconRoot, evm) ProcessBeaconBlockRoot(*beaconRoot, evm)

View file

@ -226,9 +226,9 @@ func (evm *EVM) Cancel() {
evm.abort.Store(true) 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. // for the last time. Not necessary, but an improvement.
func (evm *EVM) Free() { func (evm *EVM) Release() {
returnStack(evm.arena) returnStack(evm.arena)
} }

View file

@ -244,7 +244,7 @@ func run(ctx context.Context, call *core.Message, opts *Options) (*core.Executio
evmContext.BlobBaseFee = new(big.Int) evmContext.BlobBaseFee = new(big.Int)
} }
evm := vm.NewEVM(evmContext, dirtyState, opts.Config, vm.Config{NoBaseFee: true}) 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 // Monitor the outer context and interrupt the EVM upon cancellation. To avoid
// a dangling goroutine until the outer estimation finishes, create an internal // a dangling goroutine until the outer estimation finishes, create an internal

View file

@ -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. // Insert parent beacon block root in the state as per EIP-4788.
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil) context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil)
evm := vm.NewEVM(context, statedb, eth.blockchain.Config(), vm.Config{}) evm := vm.NewEVM(context, statedb, eth.blockchain.Config(), vm.Config{})
defer evm.Free() defer evm.Release()
if beaconRoot := block.BeaconRoot(); beaconRoot != nil { if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
core.ProcessBeaconBlockRoot(*beaconRoot, evm) core.ProcessBeaconBlockRoot(*beaconRoot, evm)
} }

View file

@ -379,7 +379,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
if api.backend.ChainConfig().IsPrague(next.Number(), next.Time()) { if api.backend.ChainConfig().IsPrague(next.Number(), next.Time()) {
core.ProcessParentBlockHash(next.ParentHash(), evm) core.ProcessParentBlockHash(next.ParentHash(), evm)
} }
evm.Free() evm.Release()
// Clean out any pending release functions of trace state. Note this // Clean out any pending release functions of trace state. Note this
// step must be done after constructing tracing state, because the // step must be done after constructing tracing state, because the
// tracing state of block next depends on the parent state and construction // 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()) deleteEmptyObjects = chainConfig.IsEIP158(block.Number())
) )
evm := vm.NewEVM(vmctx, statedb, chainConfig, vm.Config{}) evm := vm.NewEVM(vmctx, statedb, chainConfig, vm.Config{})
defer evm.Free() defer evm.Release()
if beaconRoot := block.BeaconRoot(); beaconRoot != nil { if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
core.ProcessBeaconBlockRoot(*beaconRoot, evm) 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) blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{}) evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{})
defer evm.Free() defer evm.Release()
if beaconRoot := block.BeaconRoot(); beaconRoot != nil { if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
core.ProcessBeaconBlockRoot(*beaconRoot, evm) core.ProcessBeaconBlockRoot(*beaconRoot, evm)
} }
@ -676,7 +676,7 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
var failed error var failed error
blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{}) evm := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{})
defer evm.Free() defer evm.Release()
txloop: txloop:
for i, tx := range txs { 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{}) evm := vm.NewEVM(vmctx, statedb, chainConfig, vm.Config{})
defer evm.Free() defer evm.Release()
if beaconRoot := block.BeaconRoot(); beaconRoot != nil { if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
core.ProcessBeaconBlockRoot(*beaconRoot, evm) 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) tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
} }
_, err = core.ApplyMessage(evm, msg, nil) _, err = core.ApplyMessage(evm, msg, nil)
evm.Free() evm.Release()
if writer != nil { if writer != nil {
writer.Flush() writer.Flush()
} }
@ -1005,7 +1005,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
} }
tracingStateDB := state.NewHookedState(statedb, tracer.Hooks) tracingStateDB := state.NewHookedState(statedb, tracer.Hooks)
evm := vm.NewEVM(vmctx, tracingStateDB, api.backend.ChainConfig(), vm.Config{Tracer: tracer.Hooks, NoBaseFee: true}) evm := vm.NewEVM(vmctx, tracingStateDB, api.backend.ChainConfig(), vm.Config{Tracer: tracer.Hooks, NoBaseFee: true})
defer evm.Free() defer evm.Release()
if precompiles != nil { if precompiles != nil {
evm.SetPrecompiles(precompiles) evm.SetPrecompiles(precompiles)
} }

View file

@ -775,7 +775,7 @@ func applyMessage(ctx context.Context, b Backend, args TransactionArgs, state *s
blockContext.BlobBaseFee = new(big.Int) blockContext.BlobBaseFee = new(big.Int)
} }
evm := b.GetEVM(ctx, state, header, vmConfig, blockContext) evm := b.GetEVM(ctx, state, header, vmConfig, blockContext)
defer evm.Free() defer evm.Release()
if precompiles != nil { if precompiles != nil {
evm.SetPrecompiles(precompiles) evm.SetPrecompiles(precompiles)
} }
@ -1391,7 +1391,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
evm.Context.BlobBaseFee = new(big.Int) evm.Context.BlobBaseFee = new(big.Int)
} }
res, err := core.ApplyMessage(evm, msg, nil) res, err := core.ApplyMessage(evm, msg, nil)
evm.Free() evm.Release()
if err != nil { if err != nil {
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction(types.LegacyTxType).Hash(), err) return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction(types.LegacyTxType).Hash(), err)
} }

View file

@ -312,7 +312,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
tracingStateDB = state.NewHookedState(sim.state, hooks) tracingStateDB = state.NewHookedState(sim.state, hooks)
} }
evm := vm.NewEVM(blockContext, tracingStateDB, sim.chainConfig, *vmConfig) evm := vm.NewEVM(blockContext, tracingStateDB, sim.chainConfig, *vmConfig)
defer evm.Free() defer evm.Release()
// It is possible to override precompiles with EVM bytecode, or // It is possible to override precompiles with EVM bytecode, or
// move them to another address. // move them to another address.
if precompiles != nil { if precompiles != nil {

View file

@ -84,7 +84,7 @@ func (env *environment) txFitsSize(tx *types.Transaction) bool {
func (env *environment) discard() { func (env *environment) discard() {
env.state.StopPrefetcher() env.state.StopPrefetcher()
if env.evm != nil { if env.evm != nil {
env.evm.Free() env.evm.Release()
} }
} }