Skip to content

Commit

Permalink
core/vm: combine function precompile and precompile2
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Sep 19, 2024
1 parent a020259 commit b5040f5
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.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 {
Expand Down Expand Up @@ -229,7 +213,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 {
Expand Down

0 comments on commit b5040f5

Please sign in to comment.