diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 75ab34eb890..05359a3d3b7 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -98,31 +98,31 @@ var PrecompiledContractsBerlin = map[libcommon.Address]PrecompiledContract{ libcommon.BytesToAddress([]byte{9}): &blake2F{}, } +var PrecompiledContractsCancun = map[libcommon.Address]PrecompiledContract{ + libcommon.BytesToAddress([]byte{0x01}): &ecrecover{}, + libcommon.BytesToAddress([]byte{0x02}): &sha256hash{}, + libcommon.BytesToAddress([]byte{0x03}): &ripemd160hash{}, + libcommon.BytesToAddress([]byte{0x04}): &dataCopy{}, + libcommon.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true}, + libcommon.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{}, + libcommon.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{}, + libcommon.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{}, + libcommon.BytesToAddress([]byte{0x09}): &blake2F{}, + libcommon.BytesToAddress([]byte{0x0a}): &pointEvaluation{}, +} + // PrecompiledContractsBLS contains the set of pre-compiled Ethereum // contracts specified in EIP-2537. These are exported for testing purposes. var PrecompiledContractsBLS = map[libcommon.Address]PrecompiledContract{ - libcommon.BytesToAddress([]byte{10}): &bls12381G1Add{}, - libcommon.BytesToAddress([]byte{11}): &bls12381G1Mul{}, - libcommon.BytesToAddress([]byte{12}): &bls12381G1MultiExp{}, - libcommon.BytesToAddress([]byte{13}): &bls12381G2Add{}, - libcommon.BytesToAddress([]byte{14}): &bls12381G2Mul{}, - libcommon.BytesToAddress([]byte{15}): &bls12381G2MultiExp{}, - libcommon.BytesToAddress([]byte{16}): &bls12381Pairing{}, - libcommon.BytesToAddress([]byte{17}): &bls12381MapG1{}, - libcommon.BytesToAddress([]byte{18}): &bls12381MapG2{}, -} - -var PrecompiledContractsCancun = map[libcommon.Address]PrecompiledContract{ - libcommon.BytesToAddress([]byte{1}): &ecrecover{}, - libcommon.BytesToAddress([]byte{2}): &sha256hash{}, - libcommon.BytesToAddress([]byte{3}): &ripemd160hash{}, - libcommon.BytesToAddress([]byte{4}): &dataCopy{}, - libcommon.BytesToAddress([]byte{5}): &bigModExp{eip2565: true}, - libcommon.BytesToAddress([]byte{6}): &bn256AddIstanbul{}, - libcommon.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{}, - libcommon.BytesToAddress([]byte{8}): &bn256PairingIstanbul{}, - libcommon.BytesToAddress([]byte{9}): &blake2F{}, - libcommon.BytesToAddress([]byte{20}): &pointEvaluation{}, + libcommon.BytesToAddress([]byte{0x0c}): &bls12381G1Add{}, + libcommon.BytesToAddress([]byte{0x0d}): &bls12381G1Mul{}, + libcommon.BytesToAddress([]byte{0x0e}): &bls12381G1MultiExp{}, + libcommon.BytesToAddress([]byte{0x0f}): &bls12381G2Add{}, + libcommon.BytesToAddress([]byte{0x10}): &bls12381G2Mul{}, + libcommon.BytesToAddress([]byte{0x11}): &bls12381G2MultiExp{}, + libcommon.BytesToAddress([]byte{0x12}): &bls12381Pairing{}, + libcommon.BytesToAddress([]byte{0x13}): &bls12381MapG1{}, + libcommon.BytesToAddress([]byte{0x14}): &bls12381MapG2{}, } var ( diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index 568df125167..40d334748e4 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -108,7 +108,7 @@ func TestExecute(t *testing.T) { func TestCall(t *testing.T) { _, tx := memdb.NewTestTx(t) state := state.New(state.NewDbStateReader(tx)) - address := libcommon.HexToAddress("0x0a") + address := libcommon.HexToAddress("0xaa") state.SetCode(address, []byte{ byte(vm.PUSH1), 10, byte(vm.PUSH1), 0,