Skip to content

Commit 91d0c5e

Browse files
committed
core,core/vm: remove EvmPool after the rework of EVM constructor
After the rework done at ethereum/go-ethereum#30745 we had to remove the EvmPool as the PR aims on using a single EVM for the whole block execution. The EvmPool was creating a race condition on miner tests
1 parent a949c37 commit 91d0c5e

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

core/state_processor.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,6 @@ func ApplyTransaction(config *params.ChainConfig, evm *vm.EVM, gp *GasPool, stat
240240
if err != nil {
241241
return nil, err
242242
}
243-
// TODO(CZ): do we need this?
244-
defer func() {
245-
ite := evm.Interpreter()
246-
vm.EVMInterpreterPool.Put(ite)
247-
vm.EvmPool.Put(evm)
248-
}()
249243
return ApplyTransactionWithEVM(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, evm, receiptProcessors...)
250244
}
251245

core/vm/evm.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package vm
1919
import (
2020
"errors"
2121
"math/big"
22-
"sync"
2322
"sync/atomic"
2423

2524
"github.com/ethereum/go-ethereum/common"
@@ -30,12 +29,6 @@ import (
3029
"github.com/holiman/uint256"
3130
)
3231

33-
var EvmPool = sync.Pool{
34-
New: func() interface{} {
35-
return &EVM{}
36-
},
37-
}
38-
3932
type (
4033
// CanTransferFunc is the signature of a transfer guard function
4134
CanTransferFunc func(StateDB, common.Address, *uint256.Int) bool
@@ -124,17 +117,13 @@ type EVM struct {
124117
// NewEVM returns a new EVM. The returned EVM is not thread safe and should
125118
// only ever be used *once*.
126119
func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainConfig, config Config) *EVM {
127-
evm := EvmPool.Get().(*EVM)
128-
evm.Context = blockCtx
129-
evm.StateDB = statedb
130-
evm.Config = config
131-
evm.chainConfig = chainConfig
132-
evm.chainRules = chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time)
133-
134-
evm.abort.Store(false)
135-
evm.callGasTemp = 0
136-
evm.depth = 0
137-
120+
evm := &EVM{
121+
Context: blockCtx,
122+
StateDB: statedb,
123+
Config: config,
124+
chainConfig: chainConfig,
125+
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
126+
}
138127
evm.precompiles = activePrecompiledContracts(evm.chainRules)
139128
evm.interpreter = NewEVMInterpreter(evm)
140129

0 commit comments

Comments
 (0)