From 73cac89599b1dd5e170048dc2604914061a8d8fc Mon Sep 17 00:00:00 2001 From: Shawn <44221603+shaspitz@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:18:15 -0700 Subject: [PATCH] feat: rm precompiles --- core/vm/contracts.go | 126 ++++++++++++++----------------- core/vm/contracts_fuzz_test.go | 2 +- core/vm/contracts_test.go | 52 ++++++------- core/vm/contracts_with_ctx.go | 134 --------------------------------- core/vm/evm.go | 12 +-- 5 files changed, 90 insertions(+), 236 deletions(-) delete mode 100644 core/vm/contracts_with_ctx.go diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 542d5af488cd..29fe33b60ee2 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -44,93 +44,81 @@ type PrecompiledContract interface { // PrecompiledContractsHomestead contains the default set of pre-compiled Ethereum // contracts used in the Frontier and Homestead releases. -var PrecompiledContractsHomestead = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{1}): precompileWrapper{&ecrecover{}}, - common.BytesToAddress([]byte{2}): precompileWrapper{&sha256hash{}}, - common.BytesToAddress([]byte{3}): precompileWrapper{&ripemd160hash{}}, - common.BytesToAddress([]byte{4}): precompileWrapper{&dataCopy{}}, - common.BytesToAddress([]byte{0x89}): &mint{}, - common.BytesToAddress([]byte{0x90}): &burn{}, +var PrecompiledContractsHomestead = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, } // PrecompiledContractsByzantium contains the default set of pre-compiled Ethereum // contracts used in the Byzantium release. -var PrecompiledContractsByzantium = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{1}): precompileWrapper{&ecrecover{}}, - common.BytesToAddress([]byte{2}): precompileWrapper{&sha256hash{}}, - common.BytesToAddress([]byte{3}): precompileWrapper{&ripemd160hash{}}, - common.BytesToAddress([]byte{4}): precompileWrapper{&dataCopy{}}, - common.BytesToAddress([]byte{5}): precompileWrapper{&bigModExp{eip2565: false}}, - common.BytesToAddress([]byte{6}): precompileWrapper{&bn256AddByzantium{}}, - common.BytesToAddress([]byte{7}): precompileWrapper{&bn256ScalarMulByzantium{}}, - common.BytesToAddress([]byte{8}): precompileWrapper{&bn256PairingByzantium{}}, - common.BytesToAddress([]byte{0x89}): &mint{}, - common.BytesToAddress([]byte{0x90}): &burn{}, +var PrecompiledContractsByzantium = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, + common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false}, + common.BytesToAddress([]byte{6}): &bn256AddByzantium{}, + common.BytesToAddress([]byte{7}): &bn256ScalarMulByzantium{}, + common.BytesToAddress([]byte{8}): &bn256PairingByzantium{}, } // PrecompiledContractsIstanbul contains the default set of pre-compiled Ethereum // contracts used in the Istanbul release. -var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{1}): precompileWrapper{&ecrecover{}}, - common.BytesToAddress([]byte{2}): precompileWrapper{&sha256hash{}}, - common.BytesToAddress([]byte{3}): precompileWrapper{&ripemd160hash{}}, - common.BytesToAddress([]byte{4}): precompileWrapper{&dataCopy{}}, - common.BytesToAddress([]byte{5}): precompileWrapper{&bigModExp{eip2565: false}}, - common.BytesToAddress([]byte{6}): precompileWrapper{&bn256AddIstanbul{}}, - common.BytesToAddress([]byte{7}): precompileWrapper{&bn256ScalarMulIstanbul{}}, - common.BytesToAddress([]byte{8}): precompileWrapper{&bn256PairingIstanbul{}}, - common.BytesToAddress([]byte{9}): precompileWrapper{&blake2F{}}, - common.BytesToAddress([]byte{0x89}): &mint{}, - common.BytesToAddress([]byte{0x90}): &burn{}, +var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, + common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false}, + common.BytesToAddress([]byte{6}): &bn256AddIstanbul{}, + common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{}, + common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{}, + common.BytesToAddress([]byte{9}): &blake2F{}, } // PrecompiledContractsBerlin contains the default set of pre-compiled Ethereum // contracts used in the Berlin release. -var PrecompiledContractsBerlin = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{1}): precompileWrapper{&ecrecover{}}, - common.BytesToAddress([]byte{2}): precompileWrapper{&sha256hash{}}, - common.BytesToAddress([]byte{3}): precompileWrapper{&ripemd160hash{}}, - common.BytesToAddress([]byte{4}): precompileWrapper{&dataCopy{}}, - common.BytesToAddress([]byte{5}): precompileWrapper{&bigModExp{eip2565: true}}, - common.BytesToAddress([]byte{6}): precompileWrapper{&bn256AddIstanbul{}}, - common.BytesToAddress([]byte{7}): precompileWrapper{&bn256ScalarMulIstanbul{}}, - common.BytesToAddress([]byte{8}): precompileWrapper{&bn256PairingIstanbul{}}, - common.BytesToAddress([]byte{9}): precompileWrapper{&blake2F{}}, - common.BytesToAddress([]byte{0x89}): &mint{}, - common.BytesToAddress([]byte{0x90}): &burn{}, +var PrecompiledContractsBerlin = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, + common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true}, + common.BytesToAddress([]byte{6}): &bn256AddIstanbul{}, + common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{}, + common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{}, + common.BytesToAddress([]byte{9}): &blake2F{}, } // PrecompiledContractsCancun contains the default set of pre-compiled Ethereum // contracts used in the Cancun release. -var PrecompiledContractsCancun = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{1}): precompileWrapper{&ecrecover{}}, - common.BytesToAddress([]byte{2}): precompileWrapper{&sha256hash{}}, - common.BytesToAddress([]byte{3}): precompileWrapper{&ripemd160hash{}}, - common.BytesToAddress([]byte{4}): precompileWrapper{&dataCopy{}}, - common.BytesToAddress([]byte{5}): precompileWrapper{&bigModExp{eip2565: true}}, - common.BytesToAddress([]byte{6}): precompileWrapper{&bn256AddIstanbul{}}, - common.BytesToAddress([]byte{7}): precompileWrapper{&bn256ScalarMulIstanbul{}}, - common.BytesToAddress([]byte{8}): precompileWrapper{&bn256PairingIstanbul{}}, - common.BytesToAddress([]byte{9}): precompileWrapper{&blake2F{}}, - common.BytesToAddress([]byte{0x0a}): precompileWrapper{&kzgPointEvaluation{}}, - common.BytesToAddress([]byte{0x89}): &mint{}, - common.BytesToAddress([]byte{0x90}): &burn{}, +var PrecompiledContractsCancun = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, + common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true}, + common.BytesToAddress([]byte{6}): &bn256AddIstanbul{}, + common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{}, + common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{}, + common.BytesToAddress([]byte{9}): &blake2F{}, + common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{}, } // PrecompiledContractsBLS contains the set of pre-compiled Ethereum // contracts specified in EIP-2537. These are exported for testing purposes. -var PrecompiledContractsBLS = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{10}): precompileWrapper{&bls12381G1Add{}}, - common.BytesToAddress([]byte{11}): precompileWrapper{&bls12381G1Mul{}}, - common.BytesToAddress([]byte{12}): precompileWrapper{&bls12381G1MultiExp{}}, - common.BytesToAddress([]byte{13}): precompileWrapper{&bls12381G2Add{}}, - common.BytesToAddress([]byte{14}): precompileWrapper{&bls12381G2Mul{}}, - common.BytesToAddress([]byte{15}): precompileWrapper{&bls12381G2MultiExp{}}, - common.BytesToAddress([]byte{16}): precompileWrapper{&bls12381Pairing{}}, - common.BytesToAddress([]byte{17}): precompileWrapper{&bls12381MapG1{}}, - common.BytesToAddress([]byte{18}): precompileWrapper{&bls12381MapG2{}}, - common.BytesToAddress([]byte{0x89}): &mint{}, - common.BytesToAddress([]byte{0x90}): &burn{}, +var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{10}): &bls12381G1Add{}, + common.BytesToAddress([]byte{11}): &bls12381G1Mul{}, + common.BytesToAddress([]byte{12}): &bls12381G1MultiExp{}, + common.BytesToAddress([]byte{13}): &bls12381G2Add{}, + common.BytesToAddress([]byte{14}): &bls12381G2Mul{}, + common.BytesToAddress([]byte{15}): &bls12381G2MultiExp{}, + common.BytesToAddress([]byte{16}): &bls12381Pairing{}, + common.BytesToAddress([]byte{17}): &bls12381MapG1{}, + common.BytesToAddress([]byte{18}): &bls12381MapG2{}, } var ( @@ -180,13 +168,13 @@ func ActivePrecompiles(rules params.Rules) []common.Address { // - the returned bytes, // - the _remaining_ gas, // - any error that occurred -func RunPrecompiledContract(p PrecompiledContractWithCtx, input []byte, suppliedGas uint64, ctx *precompileContext) (ret []byte, remainingGas uint64, err error) { +func RunPrecompiledContract(p PrecompiledContract, input []byte, suppliedGas uint64) (ret []byte, remainingGas uint64, err error) { gasCost := p.RequiredGas(input) if suppliedGas < gasCost { return nil, 0, ErrOutOfGas } gasLeft := suppliedGas - gasCost - output, err := p.Run(input, ctx) + output, err := p.Run(input) return output, gasLeft, err } diff --git a/core/vm/contracts_fuzz_test.go b/core/vm/contracts_fuzz_test.go index 7bc30af544fa..337ab05fc6a9 100644 --- a/core/vm/contracts_fuzz_test.go +++ b/core/vm/contracts_fuzz_test.go @@ -37,7 +37,7 @@ func FuzzPrecompiledContracts(f *testing.F) { } inWant := string(input) - RunPrecompiledContract(p, input, gas, NewContext(common.HexToAddress("1337"), mockEVM)) + RunPrecompiledContract(p, input, gas) if inHave := string(input); inWant != inHave { t.Errorf("Precompiled %v modified input data", a) } diff --git a/core/vm/contracts_test.go b/core/vm/contracts_test.go index e00e6d5baa5e..78c47d5748ee 100644 --- a/core/vm/contracts_test.go +++ b/core/vm/contracts_test.go @@ -45,28 +45,28 @@ type precompiledFailureTest struct { // allPrecompiles does not map to the actual set of precompiles, as it also contains // repriced versions of precompiles at certain slots -var allPrecompiles = map[common.Address]PrecompiledContractWithCtx{ - common.BytesToAddress([]byte{1}): precompileWrapper{&ecrecover{}}, - common.BytesToAddress([]byte{2}): precompileWrapper{&sha256hash{}}, - common.BytesToAddress([]byte{3}): precompileWrapper{&ripemd160hash{}}, - common.BytesToAddress([]byte{4}): precompileWrapper{&dataCopy{}}, - common.BytesToAddress([]byte{5}): precompileWrapper{&bigModExp{eip2565: false}}, - common.BytesToAddress([]byte{0xf5}): precompileWrapper{&bigModExp{eip2565: true}}, - common.BytesToAddress([]byte{6}): precompileWrapper{&bn256AddIstanbul{}}, - common.BytesToAddress([]byte{7}): precompileWrapper{&bn256ScalarMulIstanbul{}}, - common.BytesToAddress([]byte{8}): precompileWrapper{&bn256PairingIstanbul{}}, - common.BytesToAddress([]byte{9}): precompileWrapper{&blake2F{}}, - common.BytesToAddress([]byte{0x0a}): precompileWrapper{&kzgPointEvaluation{}}, - - common.BytesToAddress([]byte{0x0f, 0x0a}): precompileWrapper{&bls12381G1Add{}}, - common.BytesToAddress([]byte{0x0f, 0x0b}): precompileWrapper{&bls12381G1Mul{}}, - common.BytesToAddress([]byte{0x0f, 0x0c}): precompileWrapper{&bls12381G1MultiExp{}}, - common.BytesToAddress([]byte{0x0f, 0x0d}): precompileWrapper{&bls12381G2Add{}}, - common.BytesToAddress([]byte{0x0f, 0x0e}): precompileWrapper{&bls12381G2Mul{}}, - common.BytesToAddress([]byte{0x0f, 0x0f}): precompileWrapper{&bls12381G2MultiExp{}}, - common.BytesToAddress([]byte{0x0f, 0x10}): precompileWrapper{&bls12381Pairing{}}, - common.BytesToAddress([]byte{0x0f, 0x11}): precompileWrapper{&bls12381MapG1{}}, - common.BytesToAddress([]byte{0x0f, 0x12}): precompileWrapper{&bls12381MapG2{}}, +var allPrecompiles = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, + common.BytesToAddress([]byte{5}): &bigModExp{eip2565: false}, + common.BytesToAddress([]byte{0xf5}): &bigModExp{eip2565: true}, + common.BytesToAddress([]byte{6}): &bn256AddIstanbul{}, + common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{}, + common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{}, + common.BytesToAddress([]byte{9}): &blake2F{}, + common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{}, + + common.BytesToAddress([]byte{0x0f, 0x0a}): &bls12381G1Add{}, + common.BytesToAddress([]byte{0x0f, 0x0b}): &bls12381G1Mul{}, + common.BytesToAddress([]byte{0x0f, 0x0c}): &bls12381G1MultiExp{}, + common.BytesToAddress([]byte{0x0f, 0x0d}): &bls12381G2Add{}, + common.BytesToAddress([]byte{0x0f, 0x0e}): &bls12381G2Mul{}, + common.BytesToAddress([]byte{0x0f, 0x0f}): &bls12381G2MultiExp{}, + common.BytesToAddress([]byte{0x0f, 0x10}): &bls12381Pairing{}, + common.BytesToAddress([]byte{0x0f, 0x11}): &bls12381MapG1{}, + common.BytesToAddress([]byte{0x0f, 0x12}): &bls12381MapG2{}, } // EIP-152 test vectors @@ -98,7 +98,7 @@ func testPrecompiled(addr string, test precompiledTest, t *testing.T) { in := common.Hex2Bytes(test.Input) gas := p.RequiredGas(in) t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) { - res, _, err := RunPrecompiledContract(p, in, gas, NewContext(common.HexToAddress("1337"), mockEVM)) + res, _, err := RunPrecompiledContract(p, in, gas) if err != nil { t.Error(err) } else if common.Bytes2Hex(res) != test.Expected { @@ -121,7 +121,7 @@ func testPrecompiledOOG(addr string, test precompiledTest, t *testing.T) { gas := p.RequiredGas(in) - 1 t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) { - _, _, err := RunPrecompiledContract(p, in, gas, NewContext(common.HexToAddress("1337"), mockEVM)) + _, _, err := RunPrecompiledContract(p, in, gas) if err.Error() != "out of gas" { t.Errorf("Expected error [out of gas], got [%v]", err) } @@ -138,7 +138,7 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing in := common.Hex2Bytes(test.Input) gas := p.RequiredGas(in) t.Run(test.Name, func(t *testing.T) { - _, _, err := RunPrecompiledContract(p, in, gas, NewContext(common.HexToAddress("1337"), mockEVM)) + _, _, err := RunPrecompiledContract(p, in, gas) if err.Error() != test.ExpectedError { t.Errorf("Expected error [%v], got [%v]", test.ExpectedError, err) } @@ -170,7 +170,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) { bench.ResetTimer() for i := 0; i < bench.N; i++ { copy(data, in) - res, _, err = RunPrecompiledContract(p, data, reqGas, NewContext(common.HexToAddress("1337"), mockEVM)) + res, _, err = RunPrecompiledContract(p, data, reqGas) } bench.StopTimer() elapsed := uint64(time.Since(start)) diff --git a/core/vm/contracts_with_ctx.go b/core/vm/contracts_with_ctx.go deleted file mode 100644 index 8296d65d79f3..000000000000 --- a/core/vm/contracts_with_ctx.go +++ /dev/null @@ -1,134 +0,0 @@ -package vm - -import ( - "fmt" - "github.com/holiman/uint256" - "math/big" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/params" -) - -// Wrapper type which allows PrecompiledContract to be used as PrecompiledContractWithCtx -type precompileWrapper struct { - PrecompiledContract -} - -func (pw precompileWrapper) Run(input []byte, ctx *precompileContext) ([]byte, error) { - return pw.PrecompiledContract.Run(input) -} - -// Interface for precompiled contract with ctx object allowing for writes to state. -type PrecompiledContractWithCtx interface { - RequiredGas(input []byte) uint64 - Run(input []byte, ctx *precompileContext) ([]byte, error) -} - -type precompileContext struct { - *BlockContext - *params.Rules - - caller common.Address - evm *EVM -} - -func NewContext(caller common.Address, evm *EVM) *precompileContext { - return &precompileContext{ - BlockContext: &evm.Context, - Rules: &evm.chainRules, - caller: caller, - evm: evm, - } -} - -var vmBlockCtx = BlockContext{ - CanTransfer: func(db StateDB, addr common.Address, amount *uint256.Int) bool { - return db.GetBalance(addr).Cmp(amount) >= 0 - }, - Transfer: func(StateDB, common.Address, common.Address, *uint256.Int) { - panic("transfer: not implemented") - }, - GetHash: func(u uint64) common.Hash { - panic("getHash: not implemented") - }, - Coinbase: common.Address{}, - BlockNumber: new(big.Int).SetUint64(10), - Time: uint64(time.Now().Unix()), -} - -var vmTxCtx = TxContext{ - GasPrice: common.Big1, - Origin: common.HexToAddress("a11ce"), -} - -// Create a global mock EVM for use in the following tests. -var mockEVM = &EVM{ - Context: vmBlockCtx, - TxContext: vmTxCtx, -} - -// Native token mint precompile to make bridging to native token possible. -type mint struct{} - -func (c *mint) RequiredGas(input []byte) uint64 { - // TODO: determine appropriate gas cost - return 100 -} - -// Predetermined create2 address of whitelist contract with exclusive mint/burn privileges. -// This address assumes deployer is 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266. -const whitelistCreate2Addr = "0x5D1415C0973034d162F5FEcF19B50dA057057e29" - -func (c *mint) Run(input []byte, ctx *precompileContext) ([]byte, error) { - - if ctx.caller != common.HexToAddress(whitelistCreate2Addr) { - log.Error("Error parsing transfer: caller not whitelisted") - return nil, fmt.Errorf("Error parsing transfer: caller not whitelisted") - } - - mintTo := common.BytesToAddress(input[0:32]) - value, err := uint256.FromHex(hexutil.Encode(input[32:64])) - if err != nil { - log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64])) - return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64])) - } - - // Create native token out of thin air - ctx.evm.StateDB.AddBalance(mintTo, value) - - return input, nil -} - -// Native token burn precompile to make bridging back to L1 possible. -type burn struct{} - -func (c *burn) RequiredGas(input []byte) uint64 { - // TODO: determine appropriate gas cost - return 100 -} - -// Note ctx.CanTransfer method obtains an incorrect balance w.r.t "burnFrom" address, -// specifically during estimateGas. The CanTransfer check was therefore removed, -// and the calling contract is responsible for checking balance. -func (c *burn) Run(input []byte, ctx *precompileContext) ([]byte, error) { - - if ctx.caller != common.HexToAddress(whitelistCreate2Addr) { - log.Error("Error parsing transfer: caller not whitelisted") - return nil, fmt.Errorf("Error parsing transfer: caller not whitelisted") - } - - burnFrom := common.BytesToAddress(input[0:32]) - - value, err := uint256.FromHex(hexutil.Encode(input[32:64])) - if err != nil { - log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64])) - return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64])) - } - - ctx.evm.StateDB.SubBalance(burnFrom, value) - - return input, nil -} diff --git a/core/vm/evm.go b/core/vm/evm.go index af5a31ab7e45..16cc8549080a 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -37,8 +37,8 @@ type ( GetHashFunc func(uint64) common.Hash ) -func (evm *EVM) precompile(addr common.Address) (PrecompiledContractWithCtx, bool) { - var precompiles map[common.Address]PrecompiledContractWithCtx +func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) { + var precompiles map[common.Address]PrecompiledContract switch { case evm.chainRules.IsCancun: precompiles = PrecompiledContractsCancun @@ -224,7 +224,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas } if isPrecompile { - ret, gas, err = RunPrecompiledContract(p, input, gas, NewContext(caller.Address(), evm)) + ret, gas, err = RunPrecompiledContract(p, input, gas) } else { // Initialise a new contract and set the code that is to be used by the EVM. // The contract is a scoped environment for this execution context only. @@ -287,7 +287,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, // It is allowed to call precompiles, even via delegatecall if p, isPrecompile := evm.precompile(addr); isPrecompile { - ret, gas, err = RunPrecompiledContract(p, input, gas, NewContext(caller.Address(), evm)) + ret, gas, err = RunPrecompiledContract(p, input, gas) } else { addrCopy := addr // Initialise a new contract and set the code that is to be used by the EVM. @@ -332,7 +332,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by // It is allowed to call precompiles, even via delegatecall if p, isPrecompile := evm.precompile(addr); isPrecompile { - ret, gas, err = RunPrecompiledContract(p, input, gas, NewContext(caller.Address(), evm)) + ret, gas, err = RunPrecompiledContract(p, input, gas) } else { addrCopy := addr // Initialise a new contract and make initialise the delegate values @@ -381,7 +381,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte } if p, isPrecompile := evm.precompile(addr); isPrecompile { - ret, gas, err = RunPrecompiledContract(p, input, gas, NewContext(caller.Address(), evm)) + ret, gas, err = RunPrecompiledContract(p, input, gas) } else { // At this point, we use a copy of address. If we don't, the go compiler will // leak the 'contract' to the outer scope, and make allocation for 'contract'