From e231adb359c1ceab24fd76d2590885e85b0669d5 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Thu, 19 Sep 2024 16:28:31 +0800 Subject: [PATCH] core/vm: combine function precompile and precompile2 --- core/vm/evm.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index c84d905b8d32..22c2bdc3f7ca 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -58,22 +58,6 @@ func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) { return p, ok } -func (evm *EVM) precompile2(addr common.Address) (PrecompiledContract, bool) { - var precompiles map[common.Address]PrecompiledContract - switch { - case evm.chainRules.IsXDCxDisable: - precompiles = PrecompiledContractsXDCv2 - case evm.chainRules.IsIstanbul && evm.ChainConfig().IsTIPXDCXCancellationFee(evm.Context.BlockNumber): - precompiles = PrecompiledContractsIstanbul - case evm.chainRules.IsByzantium: - precompiles = PrecompiledContractsByzantium - default: - precompiles = PrecompiledContractsHomestead - } - p, ok := precompiles[addr] - return p, ok -} - // run runs the given contract and takes care of running precompiles with a fallback to the byte code interpreter. func run(evm *EVM, contract *Contract, input []byte, readOnly bool) ([]byte, error) { if contract.CodeAddr != nil { @@ -242,7 +226,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas snapshot = evm.StateDB.Snapshot() ) if !evm.StateDB.Exist(addr) { - _, isPrecompile := evm.precompile2(addr) + _, isPrecompile := evm.precompile(addr) if !isPrecompile && evm.chainRules.IsEIP158 && value.Sign() == 0 { // Calling a non existing account, don't do anything, but ping the tracer if evm.vmConfig.Debug {