diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 3d414e8206..3ee7f4a0cf 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -53,7 +53,10 @@ type PrecompiledContract interface { // PrecompiledContracts contains the precompiled contracts supported at the given fork. type PrecompiledContracts map[common.Address]PrecompiledContract -var CustomPrecompiledContracts = PrecompiledContracts{} +var CustomPrecompiledContracts = PrecompiledContracts{ + (&DASignersPrecompile{}).Address(): NewDASignersPrecompile(), + (&WrappedA0giBasePrecompile{}).Address(): NewWrappedA0giBasePrecompile(), +} // WithCustomPrecompiles merge given precompiles with custom precompiles func WithCustomPrecompiles(base PrecompiledContracts) PrecompiledContracts { @@ -287,7 +290,11 @@ func RunPrecompiledContract( inputCopy := make([]byte, len(input)) copy(inputCopy, input) - contract := NewContract(caller, p.Address(), value, suppliedGas, evm.jumpDests) + var jumpDests map[common.Hash]bitvec + if evm != nil { + jumpDests = evm.jumpDests + } + contract := NewContract(caller, p.Address(), value, suppliedGas, jumpDests) contract.Input = inputCopy gasCost := p.RequiredGas(input) diff --git a/core/vm/contracts_test.go b/core/vm/contracts_test.go index 69957783c5..3876241bf1 100644 --- a/core/vm/contracts_test.go +++ b/core/vm/contracts_test.go @@ -274,6 +274,7 @@ func TestPrecompileBlake2FMalformedInput(t *testing.T) { func TestPrecompiledEcrecover(t *testing.T) { testJson("ecRecover", "01", t) } func testJson(name, addr string, t *testing.T) { + fmt.Printf("name: %v, addr: %v\n", name, addr) tests, err := loadJson(name) if err != nil { t.Fatal(err) diff --git a/core/vm/dasigners.go b/core/vm/dasigners.go index 8423c4def0..7c6a0c332a 100644 --- a/core/vm/dasigners.go +++ b/core/vm/dasigners.go @@ -62,14 +62,14 @@ type DASignersPrecompile struct { abi abi.ABI } -func NewDASignersPrecompile() (*DASignersPrecompile, error) { +func NewDASignersPrecompile() *DASignersPrecompile { abi, err := abi.JSON(strings.NewReader(dasigners.DASignersABI)) if err != nil { - return nil, err + panic(err) } return &DASignersPrecompile{ abi: abi, - }, nil + } } // Address implements vm.PrecompiledContract. diff --git a/core/vm/wrapped_a0gi_base.go b/core/vm/wrapped_a0gi_base.go index 3af1a44026..685b0c1e47 100644 --- a/core/vm/wrapped_a0gi_base.go +++ b/core/vm/wrapped_a0gi_base.go @@ -70,14 +70,14 @@ func (w *WrappedA0giBasePrecompile) RequiredGas(input []byte) uint64 { return WrappedA0GIBaseRequiredGasMax } -func NewWrappedA0giBasePrecompile() (*WrappedA0giBasePrecompile, error) { +func NewWrappedA0giBasePrecompile() *WrappedA0giBasePrecompile { abi, err := abi.JSON(strings.NewReader(wrappeda0gibase.Wrappeda0gibaseABI)) if err != nil { - return nil, err + panic(err) } return &WrappedA0giBasePrecompile{ abi: abi, - }, nil + } } // Run implements vm.PrecompiledContract.