From d24e25400bf03f44983d460cd503a20da30327b9 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Mon, 11 Nov 2024 10:56:13 +0000 Subject: [PATCH 01/22] feat: `precompilegen` binary --- core/vm/contracts.libevm.go | 56 +++++ libevm/precompilegen/IPrecompile.abi | 1 + libevm/precompilegen/IPrecompile.sol | 20 ++ libevm/precompilegen/gen.go | 173 ++++++++++++++ libevm/precompilegen/gen_test.go | 87 +++++++ libevm/precompilegen/precompile.go.tmpl | 112 +++++++++ .../precompilegen/testprecompile/generated.go | 221 ++++++++++++++++++ 7 files changed, 670 insertions(+) create mode 100644 libevm/precompilegen/IPrecompile.abi create mode 100644 libevm/precompilegen/IPrecompile.sol create mode 100644 libevm/precompilegen/gen.go create mode 100644 libevm/precompilegen/gen_test.go create mode 100644 libevm/precompilegen/precompile.go.tmpl create mode 100644 libevm/precompilegen/testprecompile/generated.go diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index c235d0a78094..149022339da2 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -19,9 +19,11 @@ package vm import ( "fmt" "math/big" + "unsafe" "github.com/holiman/uint256" + "github.com/ava-labs/libevm/accounts/abi" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/libevm" @@ -199,3 +201,57 @@ var ( (*EVM)(nil).StaticCall, } ) + +// SelectorByteLen is the number of bytes in an ABI function selector. +const SelectorByteLen = 4 + +// A Selector is an ABI function selector. It is a uint32 instead of a [4]byte +// to allow for simpler hex literals. +type Selector = uint32 + +// ExtractSelector returns the first 4 bytes of the slice as a Selector. It +// assumes that its input is of sufficient length. +func ExtractSelector(data []byte) Selector { + arr := (*[SelectorByteLen]byte)(data) + return *(*Selector)(unsafe.Pointer(arr)) //nolint:gosec // Valid use under [unsafe.Pointer] documentation: (1) Conversion of a *T1 to Pointer to *T2. +} + +// MethodsBySelector maps 4-byte ABI selectors to the corresponding method +// representation. The key MUST be equivalent to the value's [abi.Method.ID]. +type MethodsBySelector map[Selector]abi.Method + +// BySelector remaps the Methods to be keyed by their Selectors. +func BySelector(methods map[string]abi.Method) MethodsBySelector { + ms := make(MethodsBySelector) + for _, m := range methods { + ms[ExtractSelector(m.ID)] = m + } + return ms +} + +// FindSelector extracts the Selector from `data` and, if it exists in `m`, +// returns it. The returned boolean functions as for regular map lookups. Unlike +// [ExtractSelector], FindSelector confirms that `data` has at least 4 bytes, +// treating invalid inputs as not found. +func (m MethodsBySelector) FindSelector(data []byte) (Selector, bool) { + if len(data) < SelectorByteLen { + return 0, false + } + return ExtractSelector(data), true +} + +// A RevertError is an error that couples [ErrExecutionReverted] with the EVM +// return buffer. TODO(arr4n): explain use with precompilegen contracts. +type RevertError []byte + +// Error is equivalent to the respective method on [ErrExecutionReverted]. +func (e RevertError) Error() string { return ErrExecutionReverted.Error() } + +// Bytes returns the return buffer with which an EVM context reverted. +func (e RevertError) Bytes() []byte { return []byte(e) } + +// Is returns true if `err` is directly == to `e` or if `err` is +// [ErrExecutionReverted]. +func (e RevertError) Is(err error) bool { + return error(e) == err || err == ErrExecutionReverted +} diff --git a/libevm/precompilegen/IPrecompile.abi b/libevm/precompilegen/IPrecompile.abi new file mode 100644 index 000000000000..9d4b92c95fe8 --- /dev/null +++ b/libevm/precompilegen/IPrecompile.abi @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/IPrecompile.sol b/libevm/precompilegen/IPrecompile.sol new file mode 100644 index 000000000000..30c47aa532f4 --- /dev/null +++ b/libevm/precompilegen/IPrecompile.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: LGPL-3.0 +pragma solidity 0.8.28; + +interface IPrecompile { + function Echo(string memory) external view returns (string memory); + + function Echo(uint256) external view returns (uint256); + + function HashPacked(uint256, bytes2, address) external returns (bytes32); + + struct Wrapper { + int256 val; + } + + function Extract(Wrapper memory) external returns (int256); + + function Self() external returns (address); + + function RevertWith(bytes memory) external; +} diff --git a/libevm/precompilegen/gen.go b/libevm/precompilegen/gen.go new file mode 100644 index 000000000000..18da3a8b6d6e --- /dev/null +++ b/libevm/precompilegen/gen.go @@ -0,0 +1,173 @@ +// Copyright 2024 the libevm authors. +// +// The libevm additions to go-ethereum are free software: you can redistribute +// them and/or modify them under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The libevm additions are distributed in the hope that they will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see +// . + +// The precompilegen binary generates code for creating EVM precompiles +// conforming to arbitrary Solidity interfaces. +package main + +import ( + "bytes" + "flag" + "fmt" + "go/format" + "io" + "os" + "sort" + "strings" + "text/template" + + "github.com/ava-labs/libevm/accounts/abi" + "github.com/ava-labs/libevm/core/vm" + + _ "embed" +) + +type config struct { + in, out string + pkg string +} + +func main() { + var c config + flag.StringVar(&c.in, "in", "", `Input ABI file or empty for stdin.`) + flag.StringVar(&c.out, "out", "", `Output Go file or empty for stdout.`) + flag.StringVar(&c.pkg, "package", "", "Generated package name.") + flag.Parse() + + in := os.Stdin + if c.in != "" { + in = mustOpen(c.in, os.O_RDONLY, 0) + } + out := os.Stdout + if c.out != "" { + out = mustOpen(c.out, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + } + + if err := c.generate(in, out); err != nil { + exit(err) + } + fmt.Fprintln(os.Stderr, "Generated precompile") +} + +func mustOpen(name string, flag int, perm os.FileMode) *os.File { + f, err := os.OpenFile(name, flag, perm) //nolint:gosec // User-provided file path is necessary behaviour, isolated to development environment. + if err != nil { + exit(err) + } + return f +} + +func exit(a ...any) { + fmt.Fprintln(os.Stderr, a...) + os.Exit(1) +} + +var ( + //go:embed precompile.go.tmpl + rawTemplate string + funcs = template.FuncMap{ + "methods": methods, + "signature": signature, + "hex": hex, + "type": goType, + "args": args, + "interfaceID": interfaceID, + } + tmpl = template.Must(template.New("contract").Funcs(funcs).Parse(rawTemplate)) +) + +func (c *config) generate(abiJSON io.Reader, out io.WriteCloser) error { + var jsonCopy bytes.Buffer + parsed, err := abi.JSON(io.TeeReader(abiJSON, &jsonCopy)) + if err != nil { + return fmt.Errorf("parse ABI: %v", err) + } + + var buf bytes.Buffer + data := struct { + ABI abi.ABI + JSON string + Package string + }{parsed, jsonCopy.String(), c.pkg} + if err := tmpl.Execute(&buf, data); err != nil { + return fmt.Errorf("execute template: %v", err) + } + + src, err := format.Source(buf.Bytes()) + if err != nil { + return fmt.Errorf("format source: %v", err) + } + if _, err := out.Write(src); err != nil { + return fmt.Errorf("write output: %v", err) + } + return out.Close() +} + +func methods(a abi.ABI) []abi.Method { + methods := make([]abi.Method, 0, len(a.Methods)) + for _, m := range a.Methods { + methods = append(methods, m) + } + sort.Slice(methods, func(i, j int) bool { + return methods[i].Name < methods[j].Name + }) + return methods +} + +func signature(m abi.Method) string { + in := append([]string{"vm.PrecompileEnvironment"}, asGoArgs(m.Inputs)...) + out := append(asGoArgs(m.Outputs), "error") + return fmt.Sprintf("%s(%s) (%s)", m.Name, strings.Join(in, ","), strings.Join(out, ",")) +} + +// interfaceID returns the EIP-165 interface ID of the methods. +func interfaceID(a abi.ABI) vm.Selector { + var id vm.Selector + for _, m := range a.Methods { + id ^= vm.ExtractSelector(m.ID) + } + return id +} + +func asGoArgs(args abi.Arguments) []string { + goArgs := make([]string, len(args)) + for i, a := range args { + goArgs[i] = a.Type.GetType().String() + } + return goArgs +} + +func hex(x any) string { + return fmt.Sprintf("%#x", x) +} + +func goType(a abi.Argument) string { + return a.Type.GetType().String() +} + +func args(prefix string, n int, withEnv, withErr bool) string { + a := make([]string, n) + for i := 0; i < n; i++ { + a[i] = fmt.Sprintf("%s%d", prefix, i) + } + if withEnv { + a = append([]string{"env"}, a...) + } + if withErr { + a = append(a, "err") + } + return strings.Join(a, ", ") +} diff --git a/libevm/precompilegen/gen_test.go b/libevm/precompilegen/gen_test.go new file mode 100644 index 000000000000..84dbaebe8de4 --- /dev/null +++ b/libevm/precompilegen/gen_test.go @@ -0,0 +1,87 @@ +// Copyright 2024 the libevm authors. +// +// The libevm additions to go-ethereum are free software: you can redistribute +// them and/or modify them under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The libevm additions are distributed in the hope that they will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see +// . +package main + +import ( + "math/big" + "testing" + + "github.com/holiman/uint256" + + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/vm" + "github.com/ava-labs/libevm/crypto" + "github.com/ava-labs/libevm/libevm" + "github.com/ava-labs/libevm/libevm/ethtest" + "github.com/ava-labs/libevm/libevm/hookstest" + "github.com/ava-labs/libevm/libevm/precompilegen/testprecompile" +) + +//go:generate solc -o ./ --overwrite --abi IPrecompile.sol +//go:generate go run . -in IPrecompile.abi -out ./testprecompile/generated.go -package testprecompile + +func TestGeneratedPrecompile(t *testing.T) { + addr := ethtest.NewPseudoRand(424242).Address() + + hooks := hookstest.Stub{ + PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ + addr: testprecompile.New(precompile{}), + }, + } + hooks.Register(t) +} + +type precompile struct{} + +var _ testprecompile.Contract = precompile{} + +func (precompile) Fallback(env vm.PrecompileEnvironment, x []byte) ([]byte, uint64, error) { + return nil, 0, nil +} + +func (precompile) Echo(env vm.PrecompileEnvironment, x *big.Int) (*big.Int, error) { + return x, nil +} + +func (precompile) Echo0(env vm.PrecompileEnvironment, x string) (string, error) { + return x, nil +} + +func (precompile) Extract(env vm.PrecompileEnvironment, x struct { + Val *big.Int "json:\"val\"" +}) (*big.Int, error) { + return x.Val, nil +} + +func (precompile) HashPacked(env vm.PrecompileEnvironment, x *big.Int, y [2]byte, z common.Address) (hash [32]byte, _ error) { + copy( + hash[:], + crypto.Keccak256( + uint256.MustFromBig(x).PaddedBytes(32), + y[:], + z.Bytes(), + ), + ) + return hash, nil +} + +func (precompile) RevertWith(env vm.PrecompileEnvironment, x []byte) error { + return vm.RevertError(x) +} + +func (precompile) Self(env vm.PrecompileEnvironment) (common.Address, error) { + return env.Addresses().Self, nil +} diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl new file mode 100644 index 000000000000..ea9e2f63f58e --- /dev/null +++ b/libevm/precompilegen/precompile.go.tmpl @@ -0,0 +1,112 @@ +// Package {{.Package}} is a generated package for creating EVM precompiles +// conforming to the EIP-165 interface ID {{hex (interfaceID .ABI)}}. +package {{.Package}} + +// Code generated by precompilegen. DO NOT EDIT. + +import ( + "math/big" + "strings" + + "github.com/ava-labs/libevm/accounts/abi" + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/vm" +) + +// A Contract is an implementation of a precompiled contract conforming to the +// EIP-165 interface ID {{hex (interfaceID .ABI)}}. +type Contract interface { + // Fallback implements a fallback function, called if the method selector + // fails to match any other method. + Fallback(vm.PrecompileEnvironment, []byte) ([]byte, uint64, error) +{{range methods .ABI}} + // {{.Name}} implements the function with selector {{hex .ID}}: + // {{.String}} + {{signature .}} +{{end}} +} + +type methodDispatcher = func(Contract, vm.PrecompileEnvironment, []byte) ([]byte, error) + +var ( + // Avoid unused-import errors. + _ *big.Int = nil + _ *common.Address = nil + + methods vm.MethodsBySelector + dispatchers map[vm.Selector]methodDispatcher +) + +const abiJSON = `{{.JSON}}` + +func init() { + parsed, err := abi.JSON(strings.NewReader(abiJSON)) + if err != nil { + panic(err.Error()) + } + methods = vm.BySelector(parsed.Methods) + + var d dispatch + dispatchers = map[vm.Selector]methodDispatcher{ + {{range methods .ABI}}{{hex .ID}}: d.{{.Name}}, + {{end}} + } +} + +// New returns a precompiled contract backed by the provided implementation. +func New(impl Contract) vm.PrecompiledContract { + return vm.NewStatefulPrecompile(precompile{impl}.run) +} + +type precompile struct { + impl Contract +} + +func (p precompile) run(env vm.PrecompileEnvironment, input []byte, suppliedGas uint64) ([]byte, uint64, error) { + selector, ok := methods.FindSelector(input) + if !ok { + return p.impl.Fallback(env, input) + } + ret, err := dispatchers[selector](p.impl, env, input) + switch err := err.(type) { + case nil: + return ret, 0, nil + case vm.RevertError: + return err.Bytes(), 0, vm.ErrExecutionReverted + default: + return nil, 0, err + } +} + +// dispatch is the type on which all method dispatchers are defined, stopping +// them from being exported as top-level identifiers that clutter package +// documentation. +type dispatch struct{} + +{{range methods .ABI}} +func (dispatch) {{.Name}}(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[{{hex .ID}}] + + {{if gt (len .Inputs) 0}} + inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + if err != nil { + return nil, err + } + {{- range $i, $in := .Inputs}} + i{{$i}} := inputs[{{$i}}].({{type $in}}) + {{- end}} + {{end}} + + { + {{args "o" (len .Outputs) false true}} := impl.{{.Name}}({{args "i" (len .Inputs) true false}}) + if err != nil { + return nil, err + } + {{if gt (len .Outputs) 0}} + return method.Outputs.Pack({{args "o" (len .Outputs) false false}}) + {{- else -}} + return nil, nil + {{end}} + } +} +{{end}} \ No newline at end of file diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go new file mode 100644 index 000000000000..bd2f15991ff9 --- /dev/null +++ b/libevm/precompilegen/testprecompile/generated.go @@ -0,0 +1,221 @@ +// Package testprecompile is a generated package for creating EVM precompiles +// conforming to the EIP-165 interface ID 0x55cd0ffa. +package testprecompile + +// Code generated by precompilegen. DO NOT EDIT. + +import ( + "math/big" + "strings" + + "github.com/ava-labs/libevm/accounts/abi" + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/vm" +) + +// A Contract is an implementation of a precompiled contract conforming to the +// EIP-165 interface ID 0x55cd0ffa. +type Contract interface { + // Fallback implements a fallback function, called if the method selector + // fails to match any other method. + Fallback(vm.PrecompileEnvironment, []byte) ([]byte, uint64, error) + + // Echo implements the function with selector 0x34d6d9be: + // function Echo(uint256 ) view returns(uint256) + Echo(vm.PrecompileEnvironment, *big.Int) (*big.Int, error) + + // Echo0 implements the function with selector 0xdb84d7c0: + // function Echo(string ) view returns(string) + Echo0(vm.PrecompileEnvironment, string) (string, error) + + // Extract implements the function with selector 0xad8108a4: + // function Extract((int256) ) returns(int256) + Extract(vm.PrecompileEnvironment, struct { + Val *big.Int "json:\"val\"" + }) (*big.Int, error) + + // HashPacked implements the function with selector 0xd7cc1f37: + // function HashPacked(uint256 , bytes2 , address ) returns(bytes32) + HashPacked(vm.PrecompileEnvironment, *big.Int, [2]uint8, common.Address) ([32]uint8, error) + + // RevertWith implements the function with selector 0xa93cbd97: + // function RevertWith(bytes ) returns() + RevertWith(vm.PrecompileEnvironment, []uint8) error + + // Self implements the function with selector 0xc62c692f: + // function Self() returns(address) + Self(vm.PrecompileEnvironment) (common.Address, error) +} + +type methodDispatcher = func(Contract, vm.PrecompileEnvironment, []byte) ([]byte, error) + +var ( + // Avoid unused-import errors. + _ *big.Int = nil + _ *common.Address = nil + + methods vm.MethodsBySelector + dispatchers map[vm.Selector]methodDispatcher +) + +const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}]` + +func init() { + parsed, err := abi.JSON(strings.NewReader(abiJSON)) + if err != nil { + panic(err.Error()) + } + methods = vm.BySelector(parsed.Methods) + + var d dispatch + dispatchers = map[vm.Selector]methodDispatcher{ + 0x34d6d9be: d.Echo, + 0xdb84d7c0: d.Echo0, + 0xad8108a4: d.Extract, + 0xd7cc1f37: d.HashPacked, + 0xa93cbd97: d.RevertWith, + 0xc62c692f: d.Self, + } +} + +// New returns a precompiled contract backed by the provided implementation. +func New(impl Contract) vm.PrecompiledContract { + return vm.NewStatefulPrecompile(precompile{impl}.run) +} + +type precompile struct { + impl Contract +} + +func (p precompile) run(env vm.PrecompileEnvironment, input []byte, suppliedGas uint64) ([]byte, uint64, error) { + selector, ok := methods.FindSelector(input) + if !ok { + return p.impl.Fallback(env, input) + } + ret, err := dispatchers[selector](p.impl, env, input) + switch err := err.(type) { + case nil: + return ret, 0, nil + case vm.RevertError: + return err.Bytes(), 0, vm.ErrExecutionReverted + default: + return nil, 0, err + } +} + +// dispatch is the type on which all method dispatchers are defined, stopping +// them from being exported as top-level identifiers that clutter package +// documentation. +type dispatch struct{} + +func (dispatch) Echo(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0x34d6d9be] + + inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + if err != nil { + return nil, err + } + i0 := inputs[0].(*big.Int) + + { + o0, err := impl.Echo(env, i0) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0) + } +} + +func (dispatch) Echo0(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xdb84d7c0] + + inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + if err != nil { + return nil, err + } + i0 := inputs[0].(string) + + { + o0, err := impl.Echo0(env, i0) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0) + } +} + +func (dispatch) Extract(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xad8108a4] + + inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + if err != nil { + return nil, err + } + i0 := inputs[0].(struct { + Val *big.Int "json:\"val\"" + }) + + { + o0, err := impl.Extract(env, i0) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0) + } +} + +func (dispatch) HashPacked(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xd7cc1f37] + + inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + if err != nil { + return nil, err + } + i0 := inputs[0].(*big.Int) + i1 := inputs[1].([2]uint8) + i2 := inputs[2].(common.Address) + + { + o0, err := impl.HashPacked(env, i0, i1, i2) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0) + } +} + +func (dispatch) RevertWith(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xa93cbd97] + + inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + if err != nil { + return nil, err + } + i0 := inputs[0].([]uint8) + + { + err := impl.RevertWith(env, i0) + if err != nil { + return nil, err + } + return nil, nil + + } +} + +func (dispatch) Self(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xc62c692f] + + { + o0, err := impl.Self(env) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0) + } +} From 853453040c2e17db8c07db47aa9ad86739e3088c Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Mon, 11 Nov 2024 19:02:18 +0000 Subject: [PATCH 02/22] test: explicit (i.e. non-fallback) `precompilegen` contract methods --- core/vm/contracts.libevm.go | 20 +- libevm/ethtest/rand.go | 13 + libevm/hookstest/stub.go | 9 + libevm/precompilegen/.gitignore | 1 + libevm/precompilegen/IPrecompile.abi | 2 +- libevm/precompilegen/IPrecompile.sol | 20 - libevm/precompilegen/PrecompileTest.abi | 1 + libevm/precompilegen/PrecompileTest.bin | 1 + libevm/precompilegen/Test.sol | 62 +++ libevm/precompilegen/abigen.gen_test.go | 442 ++++++++++++++++++ libevm/precompilegen/gen_test.go | 128 ++++- libevm/precompilegen/precompile.go.tmpl | 4 +- .../precompilegen/testprecompile/generated.go | 12 +- 13 files changed, 666 insertions(+), 49 deletions(-) create mode 100644 libevm/precompilegen/.gitignore delete mode 100644 libevm/precompilegen/IPrecompile.sol create mode 100644 libevm/precompilegen/PrecompileTest.abi create mode 100644 libevm/precompilegen/PrecompileTest.bin create mode 100644 libevm/precompilegen/Test.sol create mode 100644 libevm/precompilegen/abigen.gen_test.go diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index 149022339da2..d4630116f6e7 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -17,9 +17,9 @@ package vm import ( + "encoding/binary" "fmt" "math/big" - "unsafe" "github.com/holiman/uint256" @@ -207,13 +207,19 @@ const SelectorByteLen = 4 // A Selector is an ABI function selector. It is a uint32 instead of a [4]byte // to allow for simpler hex literals. -type Selector = uint32 +type Selector uint32 + +// String returns a hex encoding of `s`. +func (s Selector) String() string { + b := make([]byte, 4) + binary.BigEndian.PutUint32(b, uint32(s)) + return fmt.Sprintf("%#x", b) +} // ExtractSelector returns the first 4 bytes of the slice as a Selector. It // assumes that its input is of sufficient length. func ExtractSelector(data []byte) Selector { - arr := (*[SelectorByteLen]byte)(data) - return *(*Selector)(unsafe.Pointer(arr)) //nolint:gosec // Valid use under [unsafe.Pointer] documentation: (1) Conversion of a *T1 to Pointer to *T2. + return Selector(binary.BigEndian.Uint32(data[:4])) } // MethodsBySelector maps 4-byte ABI selectors to the corresponding method @@ -237,7 +243,11 @@ func (m MethodsBySelector) FindSelector(data []byte) (Selector, bool) { if len(data) < SelectorByteLen { return 0, false } - return ExtractSelector(data), true + sel := ExtractSelector(data) + if _, ok := m[sel]; !ok { + return 0, false + } + return sel, true } // A RevertError is an error that couples [ErrExecutionReverted] with the EVM diff --git a/libevm/ethtest/rand.go b/libevm/ethtest/rand.go index ffb9de6b8f29..2f3ee75957ea 100644 --- a/libevm/ethtest/rand.go +++ b/libevm/ethtest/rand.go @@ -17,12 +17,15 @@ package ethtest import ( + "crypto/ecdsa" "math/big" + "testing" "github.com/holiman/uint256" "golang.org/x/exp/rand" "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/crypto" ) // PseudoRand extends [rand.Rand] (*not* crypto/rand). @@ -88,3 +91,13 @@ func (r *PseudoRand) Uint64Ptr() *uint64 { func (r *PseudoRand) Uint256() *uint256.Int { return new(uint256.Int).SetBytes(r.Bytes(32)) } + +// UnsafePrivateKey returns a private key on the secp256k1 curve. +func (r *PseudoRand) UnsafePrivateKey(tb testing.TB) *ecdsa.PrivateKey { + tb.Helper() + key, err := ecdsa.GenerateKey(crypto.S256(), r.Rand) + if err != nil { + tb.Fatalf("ecdsa.GenerateKey(crypto.S256(), %T) error %v", r.Rand, err) + } + return key +} diff --git a/libevm/hookstest/stub.go b/libevm/hookstest/stub.go index 1e37aa3f940d..40cd5c185740 100644 --- a/libevm/hookstest/stub.go +++ b/libevm/hookstest/stub.go @@ -19,6 +19,7 @@ package hookstest import ( + "encoding/json" "math/big" "testing" @@ -126,3 +127,11 @@ var _ interface { params.ChainConfigHooks params.RulesHooks } = Stub{} + +// MarshalJSON implements [json.Marshaler], always returning the empty JSON +// object. +func (*Stub) MarshalJSON() ([]byte, error) { + return []byte(`{}`), nil +} + +var _ json.Marshaler = (*Stub)(nil) diff --git a/libevm/precompilegen/.gitignore b/libevm/precompilegen/.gitignore new file mode 100644 index 000000000000..dcc4b4f7fe81 --- /dev/null +++ b/libevm/precompilegen/.gitignore @@ -0,0 +1 @@ +IPrecompile.bin diff --git a/libevm/precompilegen/IPrecompile.abi b/libevm/precompilegen/IPrecompile.abi index 9d4b92c95fe8..93403c2815f9 100644 --- a/libevm/precompilegen/IPrecompile.abi +++ b/libevm/precompilegen/IPrecompile.abi @@ -1 +1 @@ -[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/IPrecompile.sol b/libevm/precompilegen/IPrecompile.sol deleted file mode 100644 index 30c47aa532f4..000000000000 --- a/libevm/precompilegen/IPrecompile.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0 -pragma solidity 0.8.28; - -interface IPrecompile { - function Echo(string memory) external view returns (string memory); - - function Echo(uint256) external view returns (uint256); - - function HashPacked(uint256, bytes2, address) external returns (bytes32); - - struct Wrapper { - int256 val; - } - - function Extract(Wrapper memory) external returns (int256); - - function Self() external returns (address); - - function RevertWith(bytes memory) external; -} diff --git a/libevm/precompilegen/PrecompileTest.abi b/libevm/precompilegen/PrecompileTest.abi new file mode 100644 index 000000000000..5ea2565d2a5c --- /dev/null +++ b/libevm/precompilegen/PrecompileTest.abi @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"contract IPrecompile","name":"_precompile","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"func","type":"string"}],"name":"Called","type":"event"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"bytes2","name":"y","type":"bytes2"},{"internalType":"address","name":"z","type":"address"}],"name":"HashPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"err","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/PrecompileTest.bin b/libevm/precompilegen/PrecompileTest.bin new file mode 100644 index 000000000000..37a2ea65cc9e --- /dev/null +++ b/libevm/precompilegen/PrecompileTest.bin @@ -0,0 +1 @@ +60a060405234801561000f575f5ffd5b50604051611253380380611253833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161111461013f5f395f818160d6015281816101b60152818161031a0152818161035101528181610464015261056f01526111145ff3fe608060405234801561000f575f5ffd5b5060043610610055575f3560e01c806334d6d9be14610059578063a93cbd9714610075578063c62c692f14610091578063d7cc1f371461009b578063db84d7c0146100b7575b5f5ffd5b610073600480360381019061006e91906106b8565b6100d3565b005b61008f600480360381019061008a919061081f565b6101b2565b005b610099610318565b005b6100b560048036038101906100b09190610915565b610437565b005b6100d160048036038101906100cc9190610a03565b610546565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161012d9190610a59565b602060405180830381865afa158015610148573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061016c9190610a86565b1461017a57610179610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101a790610b38565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102049190610bb6565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161026e9190610c10565b5f604051808303815f865af19150503d805f81146102a7576040519150601f19603f3d011682016040523d82523d5f602084013e6102ac565b606091505b509150915081156102c0576102bf610ab1565b5b82805190602001208180519060200120146102de576102dd610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161030b90610c70565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dc9190610ca2565b73ffffffffffffffffffffffffffffffffffffffff1614610400576103ff610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161042d90610d17565b60405180910390a1565b82828260405160200161044c93929190610dba565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b81526004016104bf93929190610e14565b602060405180830381865afa1580156104da573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104fe9190610e7c565b1461050c5761050b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161053990610ef1565b60405180910390a1505050565b806040516020016105579190610f53565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016105c69190610fa1565b5f60405180830381865afa1580156105e0573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610608919061102f565b6040516020016106189190610f53565b604051602081830303815290604052805190602001201461063c5761063b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610669906110c0565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61069781610685565b81146106a1575f5ffd5b50565b5f813590506106b28161068e565b92915050565b5f602082840312156106cd576106cc61067d565b5b5f6106da848285016106a4565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610731826106eb565b810181811067ffffffffffffffff821117156107505761074f6106fb565b5b80604052505050565b5f610762610674565b905061076e8282610728565b919050565b5f67ffffffffffffffff82111561078d5761078c6106fb565b5b610796826106eb565b9050602081019050919050565b828183375f83830152505050565b5f6107c36107be84610773565b610759565b9050828152602081018484840111156107df576107de6106e7565b5b6107ea8482856107a3565b509392505050565b5f82601f830112610806576108056106e3565b5b81356108168482602086016107b1565b91505092915050565b5f602082840312156108345761083361067d565b5b5f82013567ffffffffffffffff81111561085157610850610681565b5b61085d848285016107f2565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61089a81610866565b81146108a4575f5ffd5b50565b5f813590506108b581610891565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6108e4826108bb565b9050919050565b6108f4816108da565b81146108fe575f5ffd5b50565b5f8135905061090f816108eb565b92915050565b5f5f5f6060848603121561092c5761092b61067d565b5b5f610939868287016106a4565b935050602061094a868287016108a7565b925050604061095b86828701610901565b9150509250925092565b5f67ffffffffffffffff82111561097f5761097e6106fb565b5b610988826106eb565b9050602081019050919050565b5f6109a76109a284610965565b610759565b9050828152602081018484840111156109c3576109c26106e7565b5b6109ce8482856107a3565b509392505050565b5f82601f8301126109ea576109e96106e3565b5b81356109fa848260208601610995565b91505092915050565b5f60208284031215610a1857610a1761067d565b5b5f82013567ffffffffffffffff811115610a3557610a34610681565b5b610a41848285016109d6565b91505092915050565b610a5381610685565b82525050565b5f602082019050610a6c5f830184610a4a565b92915050565b5f81519050610a808161068e565b92915050565b5f60208284031215610a9b57610a9a61067d565b5b5f610aa884828501610a72565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610b22600d83610ade565b9150610b2d82610aee565b602082019050919050565b5f6020820190508181035f830152610b4f81610b16565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610b8882610b56565b610b928185610b60565b9350610ba2818560208601610b70565b610bab816106eb565b840191505092915050565b5f6020820190508181035f830152610bce8184610b7e565b905092915050565b5f81905092915050565b5f610bea82610b56565b610bf48185610bd6565b9350610c04818560208601610b70565b80840191505092915050565b5f610c1b8284610be0565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610c5a600f83610ade565b9150610c6582610c26565b602082019050919050565b5f6020820190508181035f830152610c8781610c4e565b9050919050565b5f81519050610c9c816108eb565b92915050565b5f60208284031215610cb757610cb661067d565b5b5f610cc484828501610c8e565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610d01600683610ade565b9150610d0c82610ccd565b602082019050919050565b5f6020820190508181035f830152610d2e81610cf5565b9050919050565b5f819050919050565b610d4f610d4a82610685565b610d35565b82525050565b5f819050919050565b610d6f610d6a82610866565b610d55565b82525050565b5f8160601b9050919050565b5f610d8b82610d75565b9050919050565b5f610d9c82610d81565b9050919050565b610db4610daf826108da565b610d92565b82525050565b5f610dc58286610d3e565b602082019150610dd58285610d5e565b600282019150610de58284610da3565b601482019150819050949350505050565b610dff81610866565b82525050565b610e0e816108da565b82525050565b5f606082019050610e275f830186610a4a565b610e346020830185610df6565b610e416040830184610e05565b949350505050565b5f819050919050565b610e5b81610e49565b8114610e65575f5ffd5b50565b5f81519050610e7681610e52565b92915050565b5f60208284031215610e9157610e9061067d565b5b5f610e9e84828501610e68565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f610edb600f83610ade565b9150610ee682610ea7565b602082019050919050565b5f6020820190508181035f830152610f0881610ecf565b9050919050565b5f81519050919050565b5f81905092915050565b5f610f2d82610f0f565b610f378185610f19565b9350610f47818560208601610b70565b80840191505092915050565b5f610f5e8284610f23565b915081905092915050565b5f610f7382610f0f565b610f7d8185610ade565b9350610f8d818560208601610b70565b610f96816106eb565b840191505092915050565b5f6020820190508181035f830152610fb98184610f69565b905092915050565b5f610fd3610fce84610965565b610759565b905082815260208101848484011115610fef57610fee6106e7565b5b610ffa848285610b70565b509392505050565b5f82601f830112611016576110156106e3565b5b8151611026848260208601610fc1565b91505092915050565b5f602082840312156110445761104361067d565b5b5f82015167ffffffffffffffff81111561106157611060610681565b5b61106d84828501611002565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f6110aa600c83610ade565b91506110b582611076565b602082019050919050565b5f6020820190508181035f8301526110d78161109e565b905091905056fea2646970667358221220dbd8e8b7b9412c1c2ca9fc32a128eab4ffca4ec73c31dc078ba49163bd3f407d64736f6c634300081c0033 \ No newline at end of file diff --git a/libevm/precompilegen/Test.sol b/libevm/precompilegen/Test.sol new file mode 100644 index 000000000000..1288a0af5d76 --- /dev/null +++ b/libevm/precompilegen/Test.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: LGPL-3.0 +pragma solidity 0.8.28; + +/// @dev Interface of precompiled contract for implementation via `precompilegen`. +interface IPrecompile { + function Echo(string memory) external view returns (string memory); + + function Echo(uint256) external view returns (uint256); + + function HashPacked(uint256, bytes2, address) external view returns (bytes32); + + struct Wrapper { + int256 val; + } + + function Extract(Wrapper memory) external view returns (int256); + + function Self() external view returns (address); + + function RevertWith(bytes memory) external; +} + +/// @dev Testing contract to exercise the implementaiton of `IPrecompile`. +contract PrecompileTest { + IPrecompile immutable precompile; + + constructor(IPrecompile _precompile) { + precompile = _precompile; + } + + /// @dev Emitted by each function to prove that it was successfully called. + event Called(string func); + + function Echo(string memory x) external { + assert(keccak256(abi.encodePacked(precompile.Echo(x))) == keccak256(abi.encodePacked(x))); + emit Called("Echo(string)"); + } + + function Echo(uint256 x) external { + assert(precompile.Echo(x) == x); + emit Called("Echo(uint256)"); + } + + function HashPacked(uint256 x, bytes2 y, address z) external { + assert(precompile.HashPacked(x, y, z) == keccak256(abi.encodePacked(x, y, z))); + emit Called("HashPacked(...)"); + } + + function Self() external { + assert(precompile.Self() == address(precompile)); + emit Called("Self()"); + } + + function RevertWith(bytes memory err) external { + (bool ok, bytes memory ret) = + address(precompile).call(abi.encodeWithSelector(IPrecompile.RevertWith.selector, err)); + assert(!ok); + assert(keccak256(ret) == keccak256(err)); + + emit Called("RevertWith(...)"); + } +} diff --git a/libevm/precompilegen/abigen.gen_test.go b/libevm/precompilegen/abigen.gen_test.go new file mode 100644 index 000000000000..a5865c1370bb --- /dev/null +++ b/libevm/precompilegen/abigen.gen_test.go @@ -0,0 +1,442 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package main + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ava-labs/libevm" + "github.com/ava-labs/libevm/accounts/abi" + "github.com/ava-labs/libevm/accounts/abi/bind" + "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" + "github.com/ava-labs/libevm/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// PrecompileTestMetaData contains all meta data concerning the PrecompileTest contract. +var PrecompileTestMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561000f575f5ffd5b50604051611253380380611253833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161111461013f5f395f818160d6015281816101b60152818161031a0152818161035101528181610464015261056f01526111145ff3fe608060405234801561000f575f5ffd5b5060043610610055575f3560e01c806334d6d9be14610059578063a93cbd9714610075578063c62c692f14610091578063d7cc1f371461009b578063db84d7c0146100b7575b5f5ffd5b610073600480360381019061006e91906106b8565b6100d3565b005b61008f600480360381019061008a919061081f565b6101b2565b005b610099610318565b005b6100b560048036038101906100b09190610915565b610437565b005b6100d160048036038101906100cc9190610a03565b610546565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161012d9190610a59565b602060405180830381865afa158015610148573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061016c9190610a86565b1461017a57610179610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101a790610b38565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102049190610bb6565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161026e9190610c10565b5f604051808303815f865af19150503d805f81146102a7576040519150601f19603f3d011682016040523d82523d5f602084013e6102ac565b606091505b509150915081156102c0576102bf610ab1565b5b82805190602001208180519060200120146102de576102dd610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161030b90610c70565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dc9190610ca2565b73ffffffffffffffffffffffffffffffffffffffff1614610400576103ff610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161042d90610d17565b60405180910390a1565b82828260405160200161044c93929190610dba565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b81526004016104bf93929190610e14565b602060405180830381865afa1580156104da573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104fe9190610e7c565b1461050c5761050b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161053990610ef1565b60405180910390a1505050565b806040516020016105579190610f53565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016105c69190610fa1565b5f60405180830381865afa1580156105e0573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610608919061102f565b6040516020016106189190610f53565b604051602081830303815290604052805190602001201461063c5761063b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610669906110c0565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61069781610685565b81146106a1575f5ffd5b50565b5f813590506106b28161068e565b92915050565b5f602082840312156106cd576106cc61067d565b5b5f6106da848285016106a4565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610731826106eb565b810181811067ffffffffffffffff821117156107505761074f6106fb565b5b80604052505050565b5f610762610674565b905061076e8282610728565b919050565b5f67ffffffffffffffff82111561078d5761078c6106fb565b5b610796826106eb565b9050602081019050919050565b828183375f83830152505050565b5f6107c36107be84610773565b610759565b9050828152602081018484840111156107df576107de6106e7565b5b6107ea8482856107a3565b509392505050565b5f82601f830112610806576108056106e3565b5b81356108168482602086016107b1565b91505092915050565b5f602082840312156108345761083361067d565b5b5f82013567ffffffffffffffff81111561085157610850610681565b5b61085d848285016107f2565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61089a81610866565b81146108a4575f5ffd5b50565b5f813590506108b581610891565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6108e4826108bb565b9050919050565b6108f4816108da565b81146108fe575f5ffd5b50565b5f8135905061090f816108eb565b92915050565b5f5f5f6060848603121561092c5761092b61067d565b5b5f610939868287016106a4565b935050602061094a868287016108a7565b925050604061095b86828701610901565b9150509250925092565b5f67ffffffffffffffff82111561097f5761097e6106fb565b5b610988826106eb565b9050602081019050919050565b5f6109a76109a284610965565b610759565b9050828152602081018484840111156109c3576109c26106e7565b5b6109ce8482856107a3565b509392505050565b5f82601f8301126109ea576109e96106e3565b5b81356109fa848260208601610995565b91505092915050565b5f60208284031215610a1857610a1761067d565b5b5f82013567ffffffffffffffff811115610a3557610a34610681565b5b610a41848285016109d6565b91505092915050565b610a5381610685565b82525050565b5f602082019050610a6c5f830184610a4a565b92915050565b5f81519050610a808161068e565b92915050565b5f60208284031215610a9b57610a9a61067d565b5b5f610aa884828501610a72565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610b22600d83610ade565b9150610b2d82610aee565b602082019050919050565b5f6020820190508181035f830152610b4f81610b16565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610b8882610b56565b610b928185610b60565b9350610ba2818560208601610b70565b610bab816106eb565b840191505092915050565b5f6020820190508181035f830152610bce8184610b7e565b905092915050565b5f81905092915050565b5f610bea82610b56565b610bf48185610bd6565b9350610c04818560208601610b70565b80840191505092915050565b5f610c1b8284610be0565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610c5a600f83610ade565b9150610c6582610c26565b602082019050919050565b5f6020820190508181035f830152610c8781610c4e565b9050919050565b5f81519050610c9c816108eb565b92915050565b5f60208284031215610cb757610cb661067d565b5b5f610cc484828501610c8e565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610d01600683610ade565b9150610d0c82610ccd565b602082019050919050565b5f6020820190508181035f830152610d2e81610cf5565b9050919050565b5f819050919050565b610d4f610d4a82610685565b610d35565b82525050565b5f819050919050565b610d6f610d6a82610866565b610d55565b82525050565b5f8160601b9050919050565b5f610d8b82610d75565b9050919050565b5f610d9c82610d81565b9050919050565b610db4610daf826108da565b610d92565b82525050565b5f610dc58286610d3e565b602082019150610dd58285610d5e565b600282019150610de58284610da3565b601482019150819050949350505050565b610dff81610866565b82525050565b610e0e816108da565b82525050565b5f606082019050610e275f830186610a4a565b610e346020830185610df6565b610e416040830184610e05565b949350505050565b5f819050919050565b610e5b81610e49565b8114610e65575f5ffd5b50565b5f81519050610e7681610e52565b92915050565b5f60208284031215610e9157610e9061067d565b5b5f610e9e84828501610e68565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f610edb600f83610ade565b9150610ee682610ea7565b602082019050919050565b5f6020820190508181035f830152610f0881610ecf565b9050919050565b5f81519050919050565b5f81905092915050565b5f610f2d82610f0f565b610f378185610f19565b9350610f47818560208601610b70565b80840191505092915050565b5f610f5e8284610f23565b915081905092915050565b5f610f7382610f0f565b610f7d8185610ade565b9350610f8d818560208601610b70565b610f96816106eb565b840191505092915050565b5f6020820190508181035f830152610fb98184610f69565b905092915050565b5f610fd3610fce84610965565b610759565b905082815260208101848484011115610fef57610fee6106e7565b5b610ffa848285610b70565b509392505050565b5f82601f830112611016576110156106e3565b5b8151611026848260208601610fc1565b91505092915050565b5f602082840312156110445761104361067d565b5b5f82015167ffffffffffffffff81111561106157611060610681565b5b61106d84828501611002565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f6110aa600c83610ade565b91506110b582611076565b602082019050919050565b5f6020820190508181035f8301526110d78161109e565b905091905056fea2646970667358221220dbd8e8b7b9412c1c2ca9fc32a128eab4ffca4ec73c31dc078ba49163bd3f407d64736f6c634300081c0033", +} + +// PrecompileTestABI is the input ABI used to generate the binding from. +// Deprecated: Use PrecompileTestMetaData.ABI instead. +var PrecompileTestABI = PrecompileTestMetaData.ABI + +// PrecompileTestBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use PrecompileTestMetaData.Bin instead. +var PrecompileTestBin = PrecompileTestMetaData.Bin + +// DeployPrecompileTest deploys a new Ethereum contract, binding an instance of PrecompileTest to it. +func DeployPrecompileTest(auth *bind.TransactOpts, backend bind.ContractBackend, _precompile common.Address) (common.Address, *types.Transaction, *PrecompileTest, error) { + parsed, err := PrecompileTestMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(PrecompileTestBin), backend, _precompile) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &PrecompileTest{PrecompileTestCaller: PrecompileTestCaller{contract: contract}, PrecompileTestTransactor: PrecompileTestTransactor{contract: contract}, PrecompileTestFilterer: PrecompileTestFilterer{contract: contract}}, nil +} + +// PrecompileTest is an auto generated Go binding around an Ethereum contract. +type PrecompileTest struct { + PrecompileTestCaller // Read-only binding to the contract + PrecompileTestTransactor // Write-only binding to the contract + PrecompileTestFilterer // Log filterer for contract events +} + +// PrecompileTestCaller is an auto generated read-only Go binding around an Ethereum contract. +type PrecompileTestCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PrecompileTestTransactor is an auto generated write-only Go binding around an Ethereum contract. +type PrecompileTestTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PrecompileTestFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type PrecompileTestFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PrecompileTestSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type PrecompileTestSession struct { + Contract *PrecompileTest // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PrecompileTestCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type PrecompileTestCallerSession struct { + Contract *PrecompileTestCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// PrecompileTestTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type PrecompileTestTransactorSession struct { + Contract *PrecompileTestTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PrecompileTestRaw is an auto generated low-level Go binding around an Ethereum contract. +type PrecompileTestRaw struct { + Contract *PrecompileTest // Generic contract binding to access the raw methods on +} + +// PrecompileTestCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type PrecompileTestCallerRaw struct { + Contract *PrecompileTestCaller // Generic read-only contract binding to access the raw methods on +} + +// PrecompileTestTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type PrecompileTestTransactorRaw struct { + Contract *PrecompileTestTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewPrecompileTest creates a new instance of PrecompileTest, bound to a specific deployed contract. +func NewPrecompileTest(address common.Address, backend bind.ContractBackend) (*PrecompileTest, error) { + contract, err := bindPrecompileTest(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &PrecompileTest{PrecompileTestCaller: PrecompileTestCaller{contract: contract}, PrecompileTestTransactor: PrecompileTestTransactor{contract: contract}, PrecompileTestFilterer: PrecompileTestFilterer{contract: contract}}, nil +} + +// NewPrecompileTestCaller creates a new read-only instance of PrecompileTest, bound to a specific deployed contract. +func NewPrecompileTestCaller(address common.Address, caller bind.ContractCaller) (*PrecompileTestCaller, error) { + contract, err := bindPrecompileTest(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &PrecompileTestCaller{contract: contract}, nil +} + +// NewPrecompileTestTransactor creates a new write-only instance of PrecompileTest, bound to a specific deployed contract. +func NewPrecompileTestTransactor(address common.Address, transactor bind.ContractTransactor) (*PrecompileTestTransactor, error) { + contract, err := bindPrecompileTest(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &PrecompileTestTransactor{contract: contract}, nil +} + +// NewPrecompileTestFilterer creates a new log filterer instance of PrecompileTest, bound to a specific deployed contract. +func NewPrecompileTestFilterer(address common.Address, filterer bind.ContractFilterer) (*PrecompileTestFilterer, error) { + contract, err := bindPrecompileTest(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &PrecompileTestFilterer{contract: contract}, nil +} + +// bindPrecompileTest binds a generic wrapper to an already deployed contract. +func bindPrecompileTest(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := PrecompileTestMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PrecompileTest *PrecompileTestRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PrecompileTest.Contract.PrecompileTestCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PrecompileTest *PrecompileTestRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.Contract.PrecompileTestTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PrecompileTest *PrecompileTestRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PrecompileTest.Contract.PrecompileTestTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PrecompileTest *PrecompileTestCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PrecompileTest.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PrecompileTest *PrecompileTestTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PrecompileTest *PrecompileTestTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PrecompileTest.Contract.contract.Transact(opts, method, params...) +} + +// Echo is a paid mutator transaction binding the contract method 0x34d6d9be. +// +// Solidity: function Echo(uint256 x) returns() +func (_PrecompileTest *PrecompileTestTransactor) Echo(opts *bind.TransactOpts, x *big.Int) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "Echo", x) +} + +// Echo is a paid mutator transaction binding the contract method 0x34d6d9be. +// +// Solidity: function Echo(uint256 x) returns() +func (_PrecompileTest *PrecompileTestSession) Echo(x *big.Int) (*types.Transaction, error) { + return _PrecompileTest.Contract.Echo(&_PrecompileTest.TransactOpts, x) +} + +// Echo is a paid mutator transaction binding the contract method 0x34d6d9be. +// +// Solidity: function Echo(uint256 x) returns() +func (_PrecompileTest *PrecompileTestTransactorSession) Echo(x *big.Int) (*types.Transaction, error) { + return _PrecompileTest.Contract.Echo(&_PrecompileTest.TransactOpts, x) +} + +// Echo0 is a paid mutator transaction binding the contract method 0xdb84d7c0. +// +// Solidity: function Echo(string x) returns() +func (_PrecompileTest *PrecompileTestTransactor) Echo0(opts *bind.TransactOpts, x string) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "Echo0", x) +} + +// Echo0 is a paid mutator transaction binding the contract method 0xdb84d7c0. +// +// Solidity: function Echo(string x) returns() +func (_PrecompileTest *PrecompileTestSession) Echo0(x string) (*types.Transaction, error) { + return _PrecompileTest.Contract.Echo0(&_PrecompileTest.TransactOpts, x) +} + +// Echo0 is a paid mutator transaction binding the contract method 0xdb84d7c0. +// +// Solidity: function Echo(string x) returns() +func (_PrecompileTest *PrecompileTestTransactorSession) Echo0(x string) (*types.Transaction, error) { + return _PrecompileTest.Contract.Echo0(&_PrecompileTest.TransactOpts, x) +} + +// HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. +// +// Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() +func (_PrecompileTest *PrecompileTestTransactor) HashPacked(opts *bind.TransactOpts, x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "HashPacked", x, y, z) +} + +// HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. +// +// Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() +func (_PrecompileTest *PrecompileTestSession) HashPacked(x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { + return _PrecompileTest.Contract.HashPacked(&_PrecompileTest.TransactOpts, x, y, z) +} + +// HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. +// +// Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() +func (_PrecompileTest *PrecompileTestTransactorSession) HashPacked(x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { + return _PrecompileTest.Contract.HashPacked(&_PrecompileTest.TransactOpts, x, y, z) +} + +// RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. +// +// Solidity: function RevertWith(bytes err) returns() +func (_PrecompileTest *PrecompileTestTransactor) RevertWith(opts *bind.TransactOpts, err []byte) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "RevertWith", err) +} + +// RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. +// +// Solidity: function RevertWith(bytes err) returns() +func (_PrecompileTest *PrecompileTestSession) RevertWith(err []byte) (*types.Transaction, error) { + return _PrecompileTest.Contract.RevertWith(&_PrecompileTest.TransactOpts, err) +} + +// RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. +// +// Solidity: function RevertWith(bytes err) returns() +func (_PrecompileTest *PrecompileTestTransactorSession) RevertWith(err []byte) (*types.Transaction, error) { + return _PrecompileTest.Contract.RevertWith(&_PrecompileTest.TransactOpts, err) +} + +// Self is a paid mutator transaction binding the contract method 0xc62c692f. +// +// Solidity: function Self() returns() +func (_PrecompileTest *PrecompileTestTransactor) Self(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "Self") +} + +// Self is a paid mutator transaction binding the contract method 0xc62c692f. +// +// Solidity: function Self() returns() +func (_PrecompileTest *PrecompileTestSession) Self() (*types.Transaction, error) { + return _PrecompileTest.Contract.Self(&_PrecompileTest.TransactOpts) +} + +// Self is a paid mutator transaction binding the contract method 0xc62c692f. +// +// Solidity: function Self() returns() +func (_PrecompileTest *PrecompileTestTransactorSession) Self() (*types.Transaction, error) { + return _PrecompileTest.Contract.Self(&_PrecompileTest.TransactOpts) +} + +// PrecompileTestCalledIterator is returned from FilterCalled and is used to iterate over the raw logs and unpacked data for Called events raised by the PrecompileTest contract. +type PrecompileTestCalledIterator struct { + Event *PrecompileTestCalled // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PrecompileTestCalledIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PrecompileTestCalled) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PrecompileTestCalled) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PrecompileTestCalledIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PrecompileTestCalledIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PrecompileTestCalled represents a Called event raised by the PrecompileTest contract. +type PrecompileTestCalled struct { + Arg0 string + Raw types.Log // Blockchain specific contextual infos +} + +// FilterCalled is a free log retrieval operation binding the contract event 0x3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a. +// +// Solidity: event Called(string func) +func (_PrecompileTest *PrecompileTestFilterer) FilterCalled(opts *bind.FilterOpts) (*PrecompileTestCalledIterator, error) { + + logs, sub, err := _PrecompileTest.contract.FilterLogs(opts, "Called") + if err != nil { + return nil, err + } + return &PrecompileTestCalledIterator{contract: _PrecompileTest.contract, event: "Called", logs: logs, sub: sub}, nil +} + +// WatchCalled is a free log subscription operation binding the contract event 0x3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a. +// +// Solidity: event Called(string func) +func (_PrecompileTest *PrecompileTestFilterer) WatchCalled(opts *bind.WatchOpts, sink chan<- *PrecompileTestCalled) (event.Subscription, error) { + + logs, sub, err := _PrecompileTest.contract.WatchLogs(opts, "Called") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PrecompileTestCalled) + if err := _PrecompileTest.contract.UnpackLog(event, "Called", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseCalled is a log parse operation binding the contract event 0x3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a. +// +// Solidity: event Called(string func) +func (_PrecompileTest *PrecompileTestFilterer) ParseCalled(log types.Log) (*PrecompileTestCalled, error) { + event := new(PrecompileTestCalled) + if err := _PrecompileTest.contract.UnpackLog(event, "Called", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/libevm/precompilegen/gen_test.go b/libevm/precompilegen/gen_test.go index 84dbaebe8de4..e27a172d701a 100644 --- a/libevm/precompilegen/gen_test.go +++ b/libevm/precompilegen/gen_test.go @@ -16,57 +16,155 @@ package main import ( + "context" "math/big" "testing" "github.com/holiman/uint256" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/ava-labs/libevm/accounts/abi/bind" "github.com/ava-labs/libevm/common" + "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/core/vm" "github.com/ava-labs/libevm/crypto" + "github.com/ava-labs/libevm/eth/ethconfig" + "github.com/ava-labs/libevm/ethclient/simulated" "github.com/ava-labs/libevm/libevm" "github.com/ava-labs/libevm/libevm/ethtest" "github.com/ava-labs/libevm/libevm/hookstest" "github.com/ava-labs/libevm/libevm/precompilegen/testprecompile" + "github.com/ava-labs/libevm/node" + "github.com/ava-labs/libevm/params" ) -//go:generate solc -o ./ --overwrite --abi IPrecompile.sol +//go:generate solc -o ./ --overwrite --abi --bin Test.sol //go:generate go run . -in IPrecompile.abi -out ./testprecompile/generated.go -package testprecompile +//go:generate go run ../../cmd/abigen --abi PrecompileTest.abi --bin PrecompileTest.bin --pkg main --out ./abigen.gen_test.go --type PrecompileTest func TestGeneratedPrecompile(t *testing.T) { - addr := ethtest.NewPseudoRand(424242).Address() + rng := ethtest.NewPseudoRand(424242) + precompile := rng.Address() - hooks := hookstest.Stub{ + hooks := &hookstest.Stub{ PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ - addr: testprecompile.New(precompile{}), + precompile: testprecompile.New(contract{}), }, } - hooks.Register(t) + extras := hookstest.Register(t, params.Extras[*hookstest.Stub, *hookstest.Stub]{ + NewRules: func(_ *params.ChainConfig, r *params.Rules, _ *hookstest.Stub, blockNum *big.Int, isMerge bool, timestamp uint64) *hookstest.Stub { + r.IsCancun = true // enable PUSH0 + return hooks + }, + }) + + key := rng.UnsafePrivateKey(t) + eoa := crypto.PubkeyToAddress(key.PublicKey) + + sim := simulated.NewBackend( + types.GenesisAlloc{ + eoa: types.Account{ + Balance: new(uint256.Int).Not(uint256.NewInt(0)).ToBig(), + }, + }, + func(nodeConf *node.Config, ethConf *ethconfig.Config) { + ethConf.Genesis.GasLimit = 30e6 + extras.SetOnChainConfig(ethConf.Genesis.Config, hooks) + }, + ) + defer sim.Close() + + txOpts, err := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) + require.NoError(t, err, "bind.NewKeyedTransactorWithChainID(..., 1337)") + txOpts.GasLimit = 1e6 + + client := sim.Client() + _, _, tester, err := DeployPrecompileTest(txOpts, client, precompile) + require.NoError(t, err, "DeployPrecompileTest(...)") + sim.Commit() + test := &PrecompileTestSession{ + Contract: tester, + TransactOpts: *txOpts, + } + + tests := []struct { + transact func() (*types.Transaction, error) + wantCalledEvent string + }{ + { + transact: func() (*types.Transaction, error) { + return test.Echo(rng.BigUint64()) + }, + wantCalledEvent: "Echo(uint256)", + }, + { + transact: func() (*types.Transaction, error) { + return test.Echo0("hello world") + }, + wantCalledEvent: "Echo(string)", + }, + { + transact: func() (*types.Transaction, error) { + return test.HashPacked(rng.BigUint64(), [2]byte{42, 42}, rng.Address()) + }, + wantCalledEvent: "HashPacked(...)", + }, + { + transact: func() (*types.Transaction, error) { + return test.Self() + }, + wantCalledEvent: "Self()", + }, + { + transact: func() (*types.Transaction, error) { + return test.RevertWith(rng.Bytes(8)) + }, + wantCalledEvent: "RevertWith(...)", + }, + } + + for _, tt := range tests { + t.Run(tt.wantCalledEvent, func(t *testing.T) { + tx, err := tt.transact() + require.NoError(t, err, "send tx") + sim.Commit() + + rcpt, err := bind.WaitMined(context.Background(), client, tx) + require.NoError(t, err, "bind.WaitMined([tx just sent])") + require.Equalf(t, uint64(1), rcpt.Status, "%T.Status (i.e. transaction included)", rcpt) + + require.Lenf(t, rcpt.Logs, 1, "%T.Logs", rcpt) + called, err := tester.ParseCalled(*rcpt.Logs[0]) + require.NoErrorf(t, err, "%T.ParseCalled(...)", tester, err) + assert.Equal(t, tt.wantCalledEvent, called.Arg0, "function name emitted with `Called` event") + }) + } } -type precompile struct{} +type contract struct{} -var _ testprecompile.Contract = precompile{} +var _ testprecompile.Contract = contract{} -func (precompile) Fallback(env vm.PrecompileEnvironment, x []byte) ([]byte, uint64, error) { - return nil, 0, nil +func (contract) Fallback(env vm.PrecompileEnvironment, callData []byte) ([]byte, uint64, error) { + return callData, 0, nil } -func (precompile) Echo(env vm.PrecompileEnvironment, x *big.Int) (*big.Int, error) { +func (contract) Echo(env vm.PrecompileEnvironment, x *big.Int) (*big.Int, error) { return x, nil } -func (precompile) Echo0(env vm.PrecompileEnvironment, x string) (string, error) { +func (contract) Echo0(env vm.PrecompileEnvironment, x string) (string, error) { return x, nil } -func (precompile) Extract(env vm.PrecompileEnvironment, x struct { +func (contract) Extract(env vm.PrecompileEnvironment, x struct { Val *big.Int "json:\"val\"" }) (*big.Int, error) { return x.Val, nil } -func (precompile) HashPacked(env vm.PrecompileEnvironment, x *big.Int, y [2]byte, z common.Address) (hash [32]byte, _ error) { +func (contract) HashPacked(env vm.PrecompileEnvironment, x *big.Int, y [2]byte, z common.Address) (hash [32]byte, _ error) { copy( hash[:], crypto.Keccak256( @@ -78,10 +176,10 @@ func (precompile) HashPacked(env vm.PrecompileEnvironment, x *big.Int, y [2]byte return hash, nil } -func (precompile) RevertWith(env vm.PrecompileEnvironment, x []byte) error { +func (contract) RevertWith(env vm.PrecompileEnvironment, x []byte) error { return vm.RevertError(x) } -func (precompile) Self(env vm.PrecompileEnvironment) (common.Address, error) { +func (contract) Self(env vm.PrecompileEnvironment) (common.Address, error) { return env.Addresses().Self, nil } diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index ea9e2f63f58e..51428166b991 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -1,5 +1,5 @@ // Package {{.Package}} is a generated package for creating EVM precompiles -// conforming to the EIP-165 interface ID {{hex (interfaceID .ABI)}}. +// conforming to the EIP-165 interface ID {{interfaceID .ABI}}. package {{.Package}} // Code generated by precompilegen. DO NOT EDIT. @@ -14,7 +14,7 @@ import ( ) // A Contract is an implementation of a precompiled contract conforming to the -// EIP-165 interface ID {{hex (interfaceID .ABI)}}. +// EIP-165 interface ID {{interfaceID .ABI}}. type Contract interface { // Fallback implements a fallback function, called if the method selector // fails to match any other method. diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index bd2f15991ff9..5a702d91b8f8 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -1,5 +1,5 @@ // Package testprecompile is a generated package for creating EVM precompiles -// conforming to the EIP-165 interface ID 0x55cd0ffa. +// conforming to the EIP-165 interface ID 0xfa0fcd55. package testprecompile // Code generated by precompilegen. DO NOT EDIT. @@ -14,7 +14,7 @@ import ( ) // A Contract is an implementation of a precompiled contract conforming to the -// EIP-165 interface ID 0x55cd0ffa. +// EIP-165 interface ID 0xfa0fcd55. type Contract interface { // Fallback implements a fallback function, called if the method selector // fails to match any other method. @@ -29,13 +29,13 @@ type Contract interface { Echo0(vm.PrecompileEnvironment, string) (string, error) // Extract implements the function with selector 0xad8108a4: - // function Extract((int256) ) returns(int256) + // function Extract((int256) ) view returns(int256) Extract(vm.PrecompileEnvironment, struct { Val *big.Int "json:\"val\"" }) (*big.Int, error) // HashPacked implements the function with selector 0xd7cc1f37: - // function HashPacked(uint256 , bytes2 , address ) returns(bytes32) + // function HashPacked(uint256 , bytes2 , address ) view returns(bytes32) HashPacked(vm.PrecompileEnvironment, *big.Int, [2]uint8, common.Address) ([32]uint8, error) // RevertWith implements the function with selector 0xa93cbd97: @@ -43,7 +43,7 @@ type Contract interface { RevertWith(vm.PrecompileEnvironment, []uint8) error // Self implements the function with selector 0xc62c692f: - // function Self() returns(address) + // function Self() view returns(address) Self(vm.PrecompileEnvironment) (common.Address, error) } @@ -58,7 +58,7 @@ var ( dispatchers map[vm.Selector]methodDispatcher ) -const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}]` +const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]` func init() { parsed, err := abi.JSON(strings.NewReader(abiJSON)) From 45c4c0cf00fb06ccf84b2dbfafc82f0eeddc7e66 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 12 Nov 2024 17:40:31 +0000 Subject: [PATCH 03/22] test: `precompilgen` fallback function --- core/vm/contracts.libevm.go | 2 +- libevm/precompilegen/PrecompileTest.abi | 2 +- libevm/precompilegen/PrecompileTest.bin | 2 +- libevm/precompilegen/Test.sol | 11 +++++++ libevm/precompilegen/abigen.gen_test.go | 25 ++++++++++++-- libevm/precompilegen/gen_test.go | 43 +++++++++++++++++-------- 6 files changed, 67 insertions(+), 18 deletions(-) diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index d4630116f6e7..57016f91296d 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -94,7 +94,7 @@ func (t CallType) OpCode() OpCode { // regular types. func (args *evmCallArgs) run(p PrecompiledContract, input []byte, suppliedGas uint64) (ret []byte, remainingGas uint64, err error) { if p, ok := p.(statefulPrecompile); ok { - return p(args.env(), input, suppliedGas) + return p(args.env(), common.CopyBytes(input), suppliedGas) } // Gas consumption for regular precompiles was already handled by the native // RunPrecompiledContract(), which called this method. diff --git a/libevm/precompilegen/PrecompileTest.abi b/libevm/precompilegen/PrecompileTest.abi index 5ea2565d2a5c..ed745fcc12d0 100644 --- a/libevm/precompilegen/PrecompileTest.abi +++ b/libevm/precompilegen/PrecompileTest.abi @@ -1 +1 @@ -[{"inputs":[{"internalType":"contract IPrecompile","name":"_precompile","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"func","type":"string"}],"name":"Called","type":"event"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"bytes2","name":"y","type":"bytes2"},{"internalType":"address","name":"z","type":"address"}],"name":"HashPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"err","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"inputs":[{"internalType":"contract IPrecompile","name":"_precompile","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"func","type":"string"}],"name":"Called","type":"event"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"}],"name":"EchoingFallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"bytes2","name":"y","type":"bytes2"},{"internalType":"address","name":"z","type":"address"}],"name":"HashPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"err","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/PrecompileTest.bin b/libevm/precompilegen/PrecompileTest.bin index 37a2ea65cc9e..c99d8eaafadc 100644 --- a/libevm/precompilegen/PrecompileTest.bin +++ b/libevm/precompilegen/PrecompileTest.bin @@ -1 +1 @@ -60a060405234801561000f575f5ffd5b50604051611253380380611253833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161111461013f5f395f818160d6015281816101b60152818161031a0152818161035101528181610464015261056f01526111145ff3fe608060405234801561000f575f5ffd5b5060043610610055575f3560e01c806334d6d9be14610059578063a93cbd9714610075578063c62c692f14610091578063d7cc1f371461009b578063db84d7c0146100b7575b5f5ffd5b610073600480360381019061006e91906106b8565b6100d3565b005b61008f600480360381019061008a919061081f565b6101b2565b005b610099610318565b005b6100b560048036038101906100b09190610915565b610437565b005b6100d160048036038101906100cc9190610a03565b610546565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161012d9190610a59565b602060405180830381865afa158015610148573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061016c9190610a86565b1461017a57610179610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101a790610b38565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102049190610bb6565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161026e9190610c10565b5f604051808303815f865af19150503d805f81146102a7576040519150601f19603f3d011682016040523d82523d5f602084013e6102ac565b606091505b509150915081156102c0576102bf610ab1565b5b82805190602001208180519060200120146102de576102dd610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161030b90610c70565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dc9190610ca2565b73ffffffffffffffffffffffffffffffffffffffff1614610400576103ff610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161042d90610d17565b60405180910390a1565b82828260405160200161044c93929190610dba565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b81526004016104bf93929190610e14565b602060405180830381865afa1580156104da573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104fe9190610e7c565b1461050c5761050b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161053990610ef1565b60405180910390a1505050565b806040516020016105579190610f53565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016105c69190610fa1565b5f60405180830381865afa1580156105e0573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610608919061102f565b6040516020016106189190610f53565b604051602081830303815290604052805190602001201461063c5761063b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610669906110c0565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61069781610685565b81146106a1575f5ffd5b50565b5f813590506106b28161068e565b92915050565b5f602082840312156106cd576106cc61067d565b5b5f6106da848285016106a4565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610731826106eb565b810181811067ffffffffffffffff821117156107505761074f6106fb565b5b80604052505050565b5f610762610674565b905061076e8282610728565b919050565b5f67ffffffffffffffff82111561078d5761078c6106fb565b5b610796826106eb565b9050602081019050919050565b828183375f83830152505050565b5f6107c36107be84610773565b610759565b9050828152602081018484840111156107df576107de6106e7565b5b6107ea8482856107a3565b509392505050565b5f82601f830112610806576108056106e3565b5b81356108168482602086016107b1565b91505092915050565b5f602082840312156108345761083361067d565b5b5f82013567ffffffffffffffff81111561085157610850610681565b5b61085d848285016107f2565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61089a81610866565b81146108a4575f5ffd5b50565b5f813590506108b581610891565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6108e4826108bb565b9050919050565b6108f4816108da565b81146108fe575f5ffd5b50565b5f8135905061090f816108eb565b92915050565b5f5f5f6060848603121561092c5761092b61067d565b5b5f610939868287016106a4565b935050602061094a868287016108a7565b925050604061095b86828701610901565b9150509250925092565b5f67ffffffffffffffff82111561097f5761097e6106fb565b5b610988826106eb565b9050602081019050919050565b5f6109a76109a284610965565b610759565b9050828152602081018484840111156109c3576109c26106e7565b5b6109ce8482856107a3565b509392505050565b5f82601f8301126109ea576109e96106e3565b5b81356109fa848260208601610995565b91505092915050565b5f60208284031215610a1857610a1761067d565b5b5f82013567ffffffffffffffff811115610a3557610a34610681565b5b610a41848285016109d6565b91505092915050565b610a5381610685565b82525050565b5f602082019050610a6c5f830184610a4a565b92915050565b5f81519050610a808161068e565b92915050565b5f60208284031215610a9b57610a9a61067d565b5b5f610aa884828501610a72565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610b22600d83610ade565b9150610b2d82610aee565b602082019050919050565b5f6020820190508181035f830152610b4f81610b16565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610b8882610b56565b610b928185610b60565b9350610ba2818560208601610b70565b610bab816106eb565b840191505092915050565b5f6020820190508181035f830152610bce8184610b7e565b905092915050565b5f81905092915050565b5f610bea82610b56565b610bf48185610bd6565b9350610c04818560208601610b70565b80840191505092915050565b5f610c1b8284610be0565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610c5a600f83610ade565b9150610c6582610c26565b602082019050919050565b5f6020820190508181035f830152610c8781610c4e565b9050919050565b5f81519050610c9c816108eb565b92915050565b5f60208284031215610cb757610cb661067d565b5b5f610cc484828501610c8e565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610d01600683610ade565b9150610d0c82610ccd565b602082019050919050565b5f6020820190508181035f830152610d2e81610cf5565b9050919050565b5f819050919050565b610d4f610d4a82610685565b610d35565b82525050565b5f819050919050565b610d6f610d6a82610866565b610d55565b82525050565b5f8160601b9050919050565b5f610d8b82610d75565b9050919050565b5f610d9c82610d81565b9050919050565b610db4610daf826108da565b610d92565b82525050565b5f610dc58286610d3e565b602082019150610dd58285610d5e565b600282019150610de58284610da3565b601482019150819050949350505050565b610dff81610866565b82525050565b610e0e816108da565b82525050565b5f606082019050610e275f830186610a4a565b610e346020830185610df6565b610e416040830184610e05565b949350505050565b5f819050919050565b610e5b81610e49565b8114610e65575f5ffd5b50565b5f81519050610e7681610e52565b92915050565b5f60208284031215610e9157610e9061067d565b5b5f610e9e84828501610e68565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f610edb600f83610ade565b9150610ee682610ea7565b602082019050919050565b5f6020820190508181035f830152610f0881610ecf565b9050919050565b5f81519050919050565b5f81905092915050565b5f610f2d82610f0f565b610f378185610f19565b9350610f47818560208601610b70565b80840191505092915050565b5f610f5e8284610f23565b915081905092915050565b5f610f7382610f0f565b610f7d8185610ade565b9350610f8d818560208601610b70565b610f96816106eb565b840191505092915050565b5f6020820190508181035f830152610fb98184610f69565b905092915050565b5f610fd3610fce84610965565b610759565b905082815260208101848484011115610fef57610fee6106e7565b5b610ffa848285610b70565b509392505050565b5f82601f830112611016576110156106e3565b5b8151611026848260208601610fc1565b91505092915050565b5f602082840312156110445761104361067d565b5b5f82015167ffffffffffffffff81111561106157611060610681565b5b61106d84828501611002565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f6110aa600c83610ade565b91506110b582611076565b602082019050919050565b5f6020820190508181035f8301526110d78161109e565b905091905056fea2646970667358221220dbd8e8b7b9412c1c2ca9fc32a128eab4ffca4ec73c31dc078ba49163bd3f407d64736f6c634300081c0033 \ No newline at end of file +60a060405234801561000f575f5ffd5b5060405161142f38038061142f833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b6080516112e96101465f395f818160fd015281816101dd0152818161039901528181610487015281816104be015281816105d101526106dc01526112e95ff3fe608060405234801561000f575f5ffd5b5060043610610060575f3560e01c806334d6d9be14610064578063a93cbd9714610080578063b4a818081461009c578063c62c692f146100b8578063d7cc1f37146100c2578063db84d7c0146100de575b5f5ffd5b61007e60048036038101906100799190610825565b6100fa565b005b61009a6004803603810190610095919061098c565b6101d9565b005b6100b660048036038101906100b1919061098c565b61033f565b005b6100c0610485565b005b6100dc60048036038101906100d79190610a82565b6105a4565b005b6100f860048036038101906100f39190610b70565b6106b3565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016101549190610bc6565b602060405180830381865afa15801561016f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101939190610bf3565b146101a1576101a0610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101ce90610ca5565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161022b9190610d23565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102959190610d7d565b5f604051808303815f865af19150503d805f81146102ce576040519150601f19603f3d011682016040523d82523d5f602084013e6102d3565b606091505b509150915081156102e7576102e6610c1e565b5b828051906020012081805190602001201461030557610304610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161033290610ddd565b60405180910390a1505050565b5f5f826040516024016103529190610d23565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516103dc9190610d7d565b5f60405180830381855afa9150503d805f8114610414576040519150601f19603f3d011682016040523d82523d5f602084013e610419565b606091505b50915091508161042c5761042b610c1e565b5b828051906020012081805190602001201461044a57610449610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161047790610e45565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610525573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105499190610e77565b73ffffffffffffffffffffffffffffffffffffffff161461056d5761056c610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161059a90610eec565b60405180910390a1565b8282826040516020016105b993929190610f8f565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161062c93929190610fe9565b602060405180830381865afa158015610647573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061066b9190611051565b1461067957610678610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106a6906110c6565b60405180910390a1505050565b806040516020016106c49190611128565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016107339190611176565b5f60405180830381865afa15801561074d573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906107759190611204565b6040516020016107859190611128565b60405160208183030381529060405280519060200120146107a9576107a8610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107d690611295565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610804816107f2565b811461080e575f5ffd5b50565b5f8135905061081f816107fb565b92915050565b5f6020828403121561083a576108396107ea565b5b5f61084784828501610811565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61089e82610858565b810181811067ffffffffffffffff821117156108bd576108bc610868565b5b80604052505050565b5f6108cf6107e1565b90506108db8282610895565b919050565b5f67ffffffffffffffff8211156108fa576108f9610868565b5b61090382610858565b9050602081019050919050565b828183375f83830152505050565b5f61093061092b846108e0565b6108c6565b90508281526020810184848401111561094c5761094b610854565b5b610957848285610910565b509392505050565b5f82601f83011261097357610972610850565b5b813561098384826020860161091e565b91505092915050565b5f602082840312156109a1576109a06107ea565b5b5f82013567ffffffffffffffff8111156109be576109bd6107ee565b5b6109ca8482850161095f565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610a07816109d3565b8114610a11575f5ffd5b50565b5f81359050610a22816109fe565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a5182610a28565b9050919050565b610a6181610a47565b8114610a6b575f5ffd5b50565b5f81359050610a7c81610a58565b92915050565b5f5f5f60608486031215610a9957610a986107ea565b5b5f610aa686828701610811565b9350506020610ab786828701610a14565b9250506040610ac886828701610a6e565b9150509250925092565b5f67ffffffffffffffff821115610aec57610aeb610868565b5b610af582610858565b9050602081019050919050565b5f610b14610b0f84610ad2565b6108c6565b905082815260208101848484011115610b3057610b2f610854565b5b610b3b848285610910565b509392505050565b5f82601f830112610b5757610b56610850565b5b8135610b67848260208601610b02565b91505092915050565b5f60208284031215610b8557610b846107ea565b5b5f82013567ffffffffffffffff811115610ba257610ba16107ee565b5b610bae84828501610b43565b91505092915050565b610bc0816107f2565b82525050565b5f602082019050610bd95f830184610bb7565b92915050565b5f81519050610bed816107fb565b92915050565b5f60208284031215610c0857610c076107ea565b5b5f610c1584828501610bdf565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610c8f600d83610c4b565b9150610c9a82610c5b565b602082019050919050565b5f6020820190508181035f830152610cbc81610c83565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610cf582610cc3565b610cff8185610ccd565b9350610d0f818560208601610cdd565b610d1881610858565b840191505092915050565b5f6020820190508181035f830152610d3b8184610ceb565b905092915050565b5f81905092915050565b5f610d5782610cc3565b610d618185610d43565b9350610d71818560208601610cdd565b80840191505092915050565b5f610d888284610d4d565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610dc7600f83610c4b565b9150610dd282610d93565b602082019050919050565b5f6020820190508181035f830152610df481610dbb565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f610e2f601483610c4b565b9150610e3a82610dfb565b602082019050919050565b5f6020820190508181035f830152610e5c81610e23565b9050919050565b5f81519050610e7181610a58565b92915050565b5f60208284031215610e8c57610e8b6107ea565b5b5f610e9984828501610e63565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610ed6600683610c4b565b9150610ee182610ea2565b602082019050919050565b5f6020820190508181035f830152610f0381610eca565b9050919050565b5f819050919050565b610f24610f1f826107f2565b610f0a565b82525050565b5f819050919050565b610f44610f3f826109d3565b610f2a565b82525050565b5f8160601b9050919050565b5f610f6082610f4a565b9050919050565b5f610f7182610f56565b9050919050565b610f89610f8482610a47565b610f67565b82525050565b5f610f9a8286610f13565b602082019150610faa8285610f33565b600282019150610fba8284610f78565b601482019150819050949350505050565b610fd4816109d3565b82525050565b610fe381610a47565b82525050565b5f606082019050610ffc5f830186610bb7565b6110096020830185610fcb565b6110166040830184610fda565b949350505050565b5f819050919050565b6110308161101e565b811461103a575f5ffd5b50565b5f8151905061104b81611027565b92915050565b5f60208284031215611066576110656107ea565b5b5f6110738482850161103d565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6110b0600f83610c4b565b91506110bb8261107c565b602082019050919050565b5f6020820190508181035f8301526110dd816110a4565b9050919050565b5f81519050919050565b5f81905092915050565b5f611102826110e4565b61110c81856110ee565b935061111c818560208601610cdd565b80840191505092915050565b5f61113382846110f8565b915081905092915050565b5f611148826110e4565b6111528185610c4b565b9350611162818560208601610cdd565b61116b81610858565b840191505092915050565b5f6020820190508181035f83015261118e818461113e565b905092915050565b5f6111a86111a384610ad2565b6108c6565b9050828152602081018484840111156111c4576111c3610854565b5b6111cf848285610cdd565b509392505050565b5f82601f8301126111eb576111ea610850565b5b81516111fb848260208601611196565b91505092915050565b5f60208284031215611219576112186107ea565b5b5f82015167ffffffffffffffff811115611236576112356107ee565b5b611242848285016111d7565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61127f600c83610c4b565b915061128a8261124b565b602082019050919050565b5f6020820190508181035f8301526112ac81611273565b905091905056fea26469706673582212205b27c3eb77c769b322aae891da6187e69e9871d973cb9f5fda8da3dec22f71af64736f6c634300081c0033 \ No newline at end of file diff --git a/libevm/precompilegen/Test.sol b/libevm/precompilegen/Test.sol index 1288a0af5d76..fb1cd59c4a06 100644 --- a/libevm/precompilegen/Test.sol +++ b/libevm/precompilegen/Test.sol @@ -59,4 +59,15 @@ contract PrecompileTest { emit Called("RevertWith(...)"); } + + function EchoingFallback(bytes memory input) external { + bytes memory data = abi.encodeWithSelector( /*non-existent selector*/ 0, input); + (bool ok, bytes memory ret) = address(precompile).staticcall(data); + assert(ok); + // Note equality with `data`, not `input` as the fallback echoes its + // entire calldata, which includes the non-matching selector. + assert(keccak256(ret) == keccak256(data)); + + emit Called("EchoingFallback(...)"); + } } diff --git a/libevm/precompilegen/abigen.gen_test.go b/libevm/precompilegen/abigen.gen_test.go index a5865c1370bb..2d9470803e1b 100644 --- a/libevm/precompilegen/abigen.gen_test.go +++ b/libevm/precompilegen/abigen.gen_test.go @@ -31,8 +31,8 @@ var ( // PrecompileTestMetaData contains all meta data concerning the PrecompileTest contract. var PrecompileTestMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561000f575f5ffd5b50604051611253380380611253833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161111461013f5f395f818160d6015281816101b60152818161031a0152818161035101528181610464015261056f01526111145ff3fe608060405234801561000f575f5ffd5b5060043610610055575f3560e01c806334d6d9be14610059578063a93cbd9714610075578063c62c692f14610091578063d7cc1f371461009b578063db84d7c0146100b7575b5f5ffd5b610073600480360381019061006e91906106b8565b6100d3565b005b61008f600480360381019061008a919061081f565b6101b2565b005b610099610318565b005b6100b560048036038101906100b09190610915565b610437565b005b6100d160048036038101906100cc9190610a03565b610546565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161012d9190610a59565b602060405180830381865afa158015610148573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061016c9190610a86565b1461017a57610179610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101a790610b38565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102049190610bb6565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161026e9190610c10565b5f604051808303815f865af19150503d805f81146102a7576040519150601f19603f3d011682016040523d82523d5f602084013e6102ac565b606091505b509150915081156102c0576102bf610ab1565b5b82805190602001208180519060200120146102de576102dd610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161030b90610c70565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103b8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dc9190610ca2565b73ffffffffffffffffffffffffffffffffffffffff1614610400576103ff610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161042d90610d17565b60405180910390a1565b82828260405160200161044c93929190610dba565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b81526004016104bf93929190610e14565b602060405180830381865afa1580156104da573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104fe9190610e7c565b1461050c5761050b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161053990610ef1565b60405180910390a1505050565b806040516020016105579190610f53565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016105c69190610fa1565b5f60405180830381865afa1580156105e0573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610608919061102f565b6040516020016106189190610f53565b604051602081830303815290604052805190602001201461063c5761063b610ab1565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610669906110c0565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61069781610685565b81146106a1575f5ffd5b50565b5f813590506106b28161068e565b92915050565b5f602082840312156106cd576106cc61067d565b5b5f6106da848285016106a4565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610731826106eb565b810181811067ffffffffffffffff821117156107505761074f6106fb565b5b80604052505050565b5f610762610674565b905061076e8282610728565b919050565b5f67ffffffffffffffff82111561078d5761078c6106fb565b5b610796826106eb565b9050602081019050919050565b828183375f83830152505050565b5f6107c36107be84610773565b610759565b9050828152602081018484840111156107df576107de6106e7565b5b6107ea8482856107a3565b509392505050565b5f82601f830112610806576108056106e3565b5b81356108168482602086016107b1565b91505092915050565b5f602082840312156108345761083361067d565b5b5f82013567ffffffffffffffff81111561085157610850610681565b5b61085d848285016107f2565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61089a81610866565b81146108a4575f5ffd5b50565b5f813590506108b581610891565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6108e4826108bb565b9050919050565b6108f4816108da565b81146108fe575f5ffd5b50565b5f8135905061090f816108eb565b92915050565b5f5f5f6060848603121561092c5761092b61067d565b5b5f610939868287016106a4565b935050602061094a868287016108a7565b925050604061095b86828701610901565b9150509250925092565b5f67ffffffffffffffff82111561097f5761097e6106fb565b5b610988826106eb565b9050602081019050919050565b5f6109a76109a284610965565b610759565b9050828152602081018484840111156109c3576109c26106e7565b5b6109ce8482856107a3565b509392505050565b5f82601f8301126109ea576109e96106e3565b5b81356109fa848260208601610995565b91505092915050565b5f60208284031215610a1857610a1761067d565b5b5f82013567ffffffffffffffff811115610a3557610a34610681565b5b610a41848285016109d6565b91505092915050565b610a5381610685565b82525050565b5f602082019050610a6c5f830184610a4a565b92915050565b5f81519050610a808161068e565b92915050565b5f60208284031215610a9b57610a9a61067d565b5b5f610aa884828501610a72565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610b22600d83610ade565b9150610b2d82610aee565b602082019050919050565b5f6020820190508181035f830152610b4f81610b16565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610b8882610b56565b610b928185610b60565b9350610ba2818560208601610b70565b610bab816106eb565b840191505092915050565b5f6020820190508181035f830152610bce8184610b7e565b905092915050565b5f81905092915050565b5f610bea82610b56565b610bf48185610bd6565b9350610c04818560208601610b70565b80840191505092915050565b5f610c1b8284610be0565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610c5a600f83610ade565b9150610c6582610c26565b602082019050919050565b5f6020820190508181035f830152610c8781610c4e565b9050919050565b5f81519050610c9c816108eb565b92915050565b5f60208284031215610cb757610cb661067d565b5b5f610cc484828501610c8e565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610d01600683610ade565b9150610d0c82610ccd565b602082019050919050565b5f6020820190508181035f830152610d2e81610cf5565b9050919050565b5f819050919050565b610d4f610d4a82610685565b610d35565b82525050565b5f819050919050565b610d6f610d6a82610866565b610d55565b82525050565b5f8160601b9050919050565b5f610d8b82610d75565b9050919050565b5f610d9c82610d81565b9050919050565b610db4610daf826108da565b610d92565b82525050565b5f610dc58286610d3e565b602082019150610dd58285610d5e565b600282019150610de58284610da3565b601482019150819050949350505050565b610dff81610866565b82525050565b610e0e816108da565b82525050565b5f606082019050610e275f830186610a4a565b610e346020830185610df6565b610e416040830184610e05565b949350505050565b5f819050919050565b610e5b81610e49565b8114610e65575f5ffd5b50565b5f81519050610e7681610e52565b92915050565b5f60208284031215610e9157610e9061067d565b5b5f610e9e84828501610e68565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f610edb600f83610ade565b9150610ee682610ea7565b602082019050919050565b5f6020820190508181035f830152610f0881610ecf565b9050919050565b5f81519050919050565b5f81905092915050565b5f610f2d82610f0f565b610f378185610f19565b9350610f47818560208601610b70565b80840191505092915050565b5f610f5e8284610f23565b915081905092915050565b5f610f7382610f0f565b610f7d8185610ade565b9350610f8d818560208601610b70565b610f96816106eb565b840191505092915050565b5f6020820190508181035f830152610fb98184610f69565b905092915050565b5f610fd3610fce84610965565b610759565b905082815260208101848484011115610fef57610fee6106e7565b5b610ffa848285610b70565b509392505050565b5f82601f830112611016576110156106e3565b5b8151611026848260208601610fc1565b91505092915050565b5f602082840312156110445761104361067d565b5b5f82015167ffffffffffffffff81111561106157611060610681565b5b61106d84828501611002565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f6110aa600c83610ade565b91506110b582611076565b602082019050919050565b5f6020820190508181035f8301526110d78161109e565b905091905056fea2646970667358221220dbd8e8b7b9412c1c2ca9fc32a128eab4ffca4ec73c31dc078ba49163bd3f407d64736f6c634300081c0033", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561000f575f5ffd5b5060405161142f38038061142f833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b6080516112e96101465f395f818160fd015281816101dd0152818161039901528181610487015281816104be015281816105d101526106dc01526112e95ff3fe608060405234801561000f575f5ffd5b5060043610610060575f3560e01c806334d6d9be14610064578063a93cbd9714610080578063b4a818081461009c578063c62c692f146100b8578063d7cc1f37146100c2578063db84d7c0146100de575b5f5ffd5b61007e60048036038101906100799190610825565b6100fa565b005b61009a6004803603810190610095919061098c565b6101d9565b005b6100b660048036038101906100b1919061098c565b61033f565b005b6100c0610485565b005b6100dc60048036038101906100d79190610a82565b6105a4565b005b6100f860048036038101906100f39190610b70565b6106b3565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016101549190610bc6565b602060405180830381865afa15801561016f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101939190610bf3565b146101a1576101a0610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101ce90610ca5565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161022b9190610d23565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102959190610d7d565b5f604051808303815f865af19150503d805f81146102ce576040519150601f19603f3d011682016040523d82523d5f602084013e6102d3565b606091505b509150915081156102e7576102e6610c1e565b5b828051906020012081805190602001201461030557610304610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161033290610ddd565b60405180910390a1505050565b5f5f826040516024016103529190610d23565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516103dc9190610d7d565b5f60405180830381855afa9150503d805f8114610414576040519150601f19603f3d011682016040523d82523d5f602084013e610419565b606091505b50915091508161042c5761042b610c1e565b5b828051906020012081805190602001201461044a57610449610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161047790610e45565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610525573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105499190610e77565b73ffffffffffffffffffffffffffffffffffffffff161461056d5761056c610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161059a90610eec565b60405180910390a1565b8282826040516020016105b993929190610f8f565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161062c93929190610fe9565b602060405180830381865afa158015610647573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061066b9190611051565b1461067957610678610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106a6906110c6565b60405180910390a1505050565b806040516020016106c49190611128565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016107339190611176565b5f60405180830381865afa15801561074d573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906107759190611204565b6040516020016107859190611128565b60405160208183030381529060405280519060200120146107a9576107a8610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107d690611295565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610804816107f2565b811461080e575f5ffd5b50565b5f8135905061081f816107fb565b92915050565b5f6020828403121561083a576108396107ea565b5b5f61084784828501610811565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61089e82610858565b810181811067ffffffffffffffff821117156108bd576108bc610868565b5b80604052505050565b5f6108cf6107e1565b90506108db8282610895565b919050565b5f67ffffffffffffffff8211156108fa576108f9610868565b5b61090382610858565b9050602081019050919050565b828183375f83830152505050565b5f61093061092b846108e0565b6108c6565b90508281526020810184848401111561094c5761094b610854565b5b610957848285610910565b509392505050565b5f82601f83011261097357610972610850565b5b813561098384826020860161091e565b91505092915050565b5f602082840312156109a1576109a06107ea565b5b5f82013567ffffffffffffffff8111156109be576109bd6107ee565b5b6109ca8482850161095f565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610a07816109d3565b8114610a11575f5ffd5b50565b5f81359050610a22816109fe565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a5182610a28565b9050919050565b610a6181610a47565b8114610a6b575f5ffd5b50565b5f81359050610a7c81610a58565b92915050565b5f5f5f60608486031215610a9957610a986107ea565b5b5f610aa686828701610811565b9350506020610ab786828701610a14565b9250506040610ac886828701610a6e565b9150509250925092565b5f67ffffffffffffffff821115610aec57610aeb610868565b5b610af582610858565b9050602081019050919050565b5f610b14610b0f84610ad2565b6108c6565b905082815260208101848484011115610b3057610b2f610854565b5b610b3b848285610910565b509392505050565b5f82601f830112610b5757610b56610850565b5b8135610b67848260208601610b02565b91505092915050565b5f60208284031215610b8557610b846107ea565b5b5f82013567ffffffffffffffff811115610ba257610ba16107ee565b5b610bae84828501610b43565b91505092915050565b610bc0816107f2565b82525050565b5f602082019050610bd95f830184610bb7565b92915050565b5f81519050610bed816107fb565b92915050565b5f60208284031215610c0857610c076107ea565b5b5f610c1584828501610bdf565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610c8f600d83610c4b565b9150610c9a82610c5b565b602082019050919050565b5f6020820190508181035f830152610cbc81610c83565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610cf582610cc3565b610cff8185610ccd565b9350610d0f818560208601610cdd565b610d1881610858565b840191505092915050565b5f6020820190508181035f830152610d3b8184610ceb565b905092915050565b5f81905092915050565b5f610d5782610cc3565b610d618185610d43565b9350610d71818560208601610cdd565b80840191505092915050565b5f610d888284610d4d565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610dc7600f83610c4b565b9150610dd282610d93565b602082019050919050565b5f6020820190508181035f830152610df481610dbb565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f610e2f601483610c4b565b9150610e3a82610dfb565b602082019050919050565b5f6020820190508181035f830152610e5c81610e23565b9050919050565b5f81519050610e7181610a58565b92915050565b5f60208284031215610e8c57610e8b6107ea565b5b5f610e9984828501610e63565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610ed6600683610c4b565b9150610ee182610ea2565b602082019050919050565b5f6020820190508181035f830152610f0381610eca565b9050919050565b5f819050919050565b610f24610f1f826107f2565b610f0a565b82525050565b5f819050919050565b610f44610f3f826109d3565b610f2a565b82525050565b5f8160601b9050919050565b5f610f6082610f4a565b9050919050565b5f610f7182610f56565b9050919050565b610f89610f8482610a47565b610f67565b82525050565b5f610f9a8286610f13565b602082019150610faa8285610f33565b600282019150610fba8284610f78565b601482019150819050949350505050565b610fd4816109d3565b82525050565b610fe381610a47565b82525050565b5f606082019050610ffc5f830186610bb7565b6110096020830185610fcb565b6110166040830184610fda565b949350505050565b5f819050919050565b6110308161101e565b811461103a575f5ffd5b50565b5f8151905061104b81611027565b92915050565b5f60208284031215611066576110656107ea565b5b5f6110738482850161103d565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6110b0600f83610c4b565b91506110bb8261107c565b602082019050919050565b5f6020820190508181035f8301526110dd816110a4565b9050919050565b5f81519050919050565b5f81905092915050565b5f611102826110e4565b61110c81856110ee565b935061111c818560208601610cdd565b80840191505092915050565b5f61113382846110f8565b915081905092915050565b5f611148826110e4565b6111528185610c4b565b9350611162818560208601610cdd565b61116b81610858565b840191505092915050565b5f6020820190508181035f83015261118e818461113e565b905092915050565b5f6111a86111a384610ad2565b6108c6565b9050828152602081018484840111156111c4576111c3610854565b5b6111cf848285610cdd565b509392505050565b5f82601f8301126111eb576111ea610850565b5b81516111fb848260208601611196565b91505092915050565b5f60208284031215611219576112186107ea565b5b5f82015167ffffffffffffffff811115611236576112356107ee565b5b611242848285016111d7565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61127f600c83610c4b565b915061128a8261124b565b602082019050919050565b5f6020820190508181035f8301526112ac81611273565b905091905056fea26469706673582212205b27c3eb77c769b322aae891da6187e69e9871d973cb9f5fda8da3dec22f71af64736f6c634300081c0033", } // PrecompileTestABI is the input ABI used to generate the binding from. @@ -244,6 +244,27 @@ func (_PrecompileTest *PrecompileTestTransactorSession) Echo0(x string) (*types. return _PrecompileTest.Contract.Echo0(&_PrecompileTest.TransactOpts, x) } +// EchoingFallback is a paid mutator transaction binding the contract method 0xb4a81808. +// +// Solidity: function EchoingFallback(bytes input) returns() +func (_PrecompileTest *PrecompileTestTransactor) EchoingFallback(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "EchoingFallback", input) +} + +// EchoingFallback is a paid mutator transaction binding the contract method 0xb4a81808. +// +// Solidity: function EchoingFallback(bytes input) returns() +func (_PrecompileTest *PrecompileTestSession) EchoingFallback(input []byte) (*types.Transaction, error) { + return _PrecompileTest.Contract.EchoingFallback(&_PrecompileTest.TransactOpts, input) +} + +// EchoingFallback is a paid mutator transaction binding the contract method 0xb4a81808. +// +// Solidity: function EchoingFallback(bytes input) returns() +func (_PrecompileTest *PrecompileTestTransactorSession) EchoingFallback(input []byte) (*types.Transaction, error) { + return _PrecompileTest.Contract.EchoingFallback(&_PrecompileTest.TransactOpts, input) +} + // HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. // // Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() diff --git a/libevm/precompilegen/gen_test.go b/libevm/precompilegen/gen_test.go index e27a172d701a..597873bd5475 100644 --- a/libevm/precompilegen/gen_test.go +++ b/libevm/precompilegen/gen_test.go @@ -43,7 +43,16 @@ import ( //go:generate go run . -in IPrecompile.abi -out ./testprecompile/generated.go -package testprecompile //go:generate go run ../../cmd/abigen --abi PrecompileTest.abi --bin PrecompileTest.bin --pkg main --out ./abigen.gen_test.go --type PrecompileTest +func successfulTxReceipt(ctx context.Context, tb testing.TB, client bind.DeployBackend, tx *types.Transaction) *types.Receipt { + tb.Helper() + r, err := bind.WaitMined(ctx, client, tx) + require.NoErrorf(tb, err, "bind.WaitMined(tx %#x)", tx.Hash()) + require.Equalf(tb, uint64(1), r.Status, "%T.Status", r) + return r +} + func TestGeneratedPrecompile(t *testing.T) { + ctx := context.Background() rng := ethtest.NewPseudoRand(424242) precompile := rng.Address() @@ -77,14 +86,15 @@ func TestGeneratedPrecompile(t *testing.T) { txOpts, err := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) require.NoError(t, err, "bind.NewKeyedTransactorWithChainID(..., 1337)") - txOpts.GasLimit = 1e6 + txOpts.GasLimit = 30e6 client := sim.Client() - _, _, tester, err := DeployPrecompileTest(txOpts, client, precompile) + _, tx, test, err := DeployPrecompileTest(txOpts, client, precompile) require.NoError(t, err, "DeployPrecompileTest(...)") sim.Commit() - test := &PrecompileTestSession{ - Contract: tester, + successfulTxReceipt(ctx, t, client, tx) + suite := &PrecompileTestSession{ + Contract: test, TransactOpts: *txOpts, } @@ -94,34 +104,40 @@ func TestGeneratedPrecompile(t *testing.T) { }{ { transact: func() (*types.Transaction, error) { - return test.Echo(rng.BigUint64()) + return suite.Echo(rng.BigUint64()) }, wantCalledEvent: "Echo(uint256)", }, { transact: func() (*types.Transaction, error) { - return test.Echo0("hello world") + return suite.Echo0("hello world") }, wantCalledEvent: "Echo(string)", }, { transact: func() (*types.Transaction, error) { - return test.HashPacked(rng.BigUint64(), [2]byte{42, 42}, rng.Address()) + return suite.HashPacked(rng.BigUint64(), [2]byte{42, 42}, rng.Address()) }, wantCalledEvent: "HashPacked(...)", }, { transact: func() (*types.Transaction, error) { - return test.Self() + return suite.Self() }, wantCalledEvent: "Self()", }, { transact: func() (*types.Transaction, error) { - return test.RevertWith(rng.Bytes(8)) + return suite.RevertWith(rng.Bytes(8)) }, wantCalledEvent: "RevertWith(...)", }, + { + transact: func() (*types.Transaction, error) { + return suite.EchoingFallback(rng.Bytes(8)) + }, + wantCalledEvent: "EchoingFallback(...)", + }, } for _, tt := range tests { @@ -130,13 +146,12 @@ func TestGeneratedPrecompile(t *testing.T) { require.NoError(t, err, "send tx") sim.Commit() - rcpt, err := bind.WaitMined(context.Background(), client, tx) - require.NoError(t, err, "bind.WaitMined([tx just sent])") + rcpt := successfulTxReceipt(ctx, t, client, tx) require.Equalf(t, uint64(1), rcpt.Status, "%T.Status (i.e. transaction included)", rcpt) require.Lenf(t, rcpt.Logs, 1, "%T.Logs", rcpt) - called, err := tester.ParseCalled(*rcpt.Logs[0]) - require.NoErrorf(t, err, "%T.ParseCalled(...)", tester, err) + called, err := test.ParseCalled(*rcpt.Logs[0]) + require.NoErrorf(t, err, "%T.ParseCalled(...)", test, err) assert.Equal(t, tt.wantCalledEvent, called.Arg0, "function name emitted with `Called` event") }) } @@ -147,6 +162,8 @@ type contract struct{} var _ testprecompile.Contract = contract{} func (contract) Fallback(env vm.PrecompileEnvironment, callData []byte) ([]byte, uint64, error) { + // Note the test-suite assumption of the fallback's behaviour: + var _ = (*PrecompileTest).EchoingFallback return callData, 0, nil } From 85669ed615be23acb2821d9f254129082c6b2e80 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 12 Nov 2024 18:18:05 +0000 Subject: [PATCH 04/22] test: `precompilegen` tuple arguments --- libevm/precompilegen/PrecompileTest.abi | 2 +- libevm/precompilegen/PrecompileTest.bin | 2 +- libevm/precompilegen/Test.sol | 5 +++++ libevm/precompilegen/abigen.gen_test.go | 30 +++++++++++++++++++++++-- libevm/precompilegen/gen_test.go | 8 +++++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/libevm/precompilegen/PrecompileTest.abi b/libevm/precompilegen/PrecompileTest.abi index ed745fcc12d0..26976dc1914f 100644 --- a/libevm/precompilegen/PrecompileTest.abi +++ b/libevm/precompilegen/PrecompileTest.abi @@ -1 +1 @@ -[{"inputs":[{"internalType":"contract IPrecompile","name":"_precompile","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"func","type":"string"}],"name":"Called","type":"event"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"}],"name":"EchoingFallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"bytes2","name":"y","type":"bytes2"},{"internalType":"address","name":"z","type":"address"}],"name":"HashPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"err","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"inputs":[{"internalType":"contract IPrecompile","name":"_precompile","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"func","type":"string"}],"name":"Called","type":"event"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"}],"name":"EchoingFallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"x","type":"tuple"}],"name":"Extract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"bytes2","name":"y","type":"bytes2"},{"internalType":"address","name":"z","type":"address"}],"name":"HashPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"err","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/PrecompileTest.bin b/libevm/precompilegen/PrecompileTest.bin index c99d8eaafadc..b98d329aa25e 100644 --- a/libevm/precompilegen/PrecompileTest.bin +++ b/libevm/precompilegen/PrecompileTest.bin @@ -1 +1 @@ -60a060405234801561000f575f5ffd5b5060405161142f38038061142f833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b6080516112e96101465f395f818160fd015281816101dd0152818161039901528181610487015281816104be015281816105d101526106dc01526112e95ff3fe608060405234801561000f575f5ffd5b5060043610610060575f3560e01c806334d6d9be14610064578063a93cbd9714610080578063b4a818081461009c578063c62c692f146100b8578063d7cc1f37146100c2578063db84d7c0146100de575b5f5ffd5b61007e60048036038101906100799190610825565b6100fa565b005b61009a6004803603810190610095919061098c565b6101d9565b005b6100b660048036038101906100b1919061098c565b61033f565b005b6100c0610485565b005b6100dc60048036038101906100d79190610a82565b6105a4565b005b6100f860048036038101906100f39190610b70565b6106b3565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016101549190610bc6565b602060405180830381865afa15801561016f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101939190610bf3565b146101a1576101a0610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101ce90610ca5565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161022b9190610d23565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102959190610d7d565b5f604051808303815f865af19150503d805f81146102ce576040519150601f19603f3d011682016040523d82523d5f602084013e6102d3565b606091505b509150915081156102e7576102e6610c1e565b5b828051906020012081805190602001201461030557610304610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161033290610ddd565b60405180910390a1505050565b5f5f826040516024016103529190610d23565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516103dc9190610d7d565b5f60405180830381855afa9150503d805f8114610414576040519150601f19603f3d011682016040523d82523d5f602084013e610419565b606091505b50915091508161042c5761042b610c1e565b5b828051906020012081805190602001201461044a57610449610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161047790610e45565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610525573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105499190610e77565b73ffffffffffffffffffffffffffffffffffffffff161461056d5761056c610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161059a90610eec565b60405180910390a1565b8282826040516020016105b993929190610f8f565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161062c93929190610fe9565b602060405180830381865afa158015610647573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061066b9190611051565b1461067957610678610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106a6906110c6565b60405180910390a1505050565b806040516020016106c49190611128565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016107339190611176565b5f60405180830381865afa15801561074d573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906107759190611204565b6040516020016107859190611128565b60405160208183030381529060405280519060200120146107a9576107a8610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107d690611295565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610804816107f2565b811461080e575f5ffd5b50565b5f8135905061081f816107fb565b92915050565b5f6020828403121561083a576108396107ea565b5b5f61084784828501610811565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61089e82610858565b810181811067ffffffffffffffff821117156108bd576108bc610868565b5b80604052505050565b5f6108cf6107e1565b90506108db8282610895565b919050565b5f67ffffffffffffffff8211156108fa576108f9610868565b5b61090382610858565b9050602081019050919050565b828183375f83830152505050565b5f61093061092b846108e0565b6108c6565b90508281526020810184848401111561094c5761094b610854565b5b610957848285610910565b509392505050565b5f82601f83011261097357610972610850565b5b813561098384826020860161091e565b91505092915050565b5f602082840312156109a1576109a06107ea565b5b5f82013567ffffffffffffffff8111156109be576109bd6107ee565b5b6109ca8482850161095f565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610a07816109d3565b8114610a11575f5ffd5b50565b5f81359050610a22816109fe565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a5182610a28565b9050919050565b610a6181610a47565b8114610a6b575f5ffd5b50565b5f81359050610a7c81610a58565b92915050565b5f5f5f60608486031215610a9957610a986107ea565b5b5f610aa686828701610811565b9350506020610ab786828701610a14565b9250506040610ac886828701610a6e565b9150509250925092565b5f67ffffffffffffffff821115610aec57610aeb610868565b5b610af582610858565b9050602081019050919050565b5f610b14610b0f84610ad2565b6108c6565b905082815260208101848484011115610b3057610b2f610854565b5b610b3b848285610910565b509392505050565b5f82601f830112610b5757610b56610850565b5b8135610b67848260208601610b02565b91505092915050565b5f60208284031215610b8557610b846107ea565b5b5f82013567ffffffffffffffff811115610ba257610ba16107ee565b5b610bae84828501610b43565b91505092915050565b610bc0816107f2565b82525050565b5f602082019050610bd95f830184610bb7565b92915050565b5f81519050610bed816107fb565b92915050565b5f60208284031215610c0857610c076107ea565b5b5f610c1584828501610bdf565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610c8f600d83610c4b565b9150610c9a82610c5b565b602082019050919050565b5f6020820190508181035f830152610cbc81610c83565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610cf582610cc3565b610cff8185610ccd565b9350610d0f818560208601610cdd565b610d1881610858565b840191505092915050565b5f6020820190508181035f830152610d3b8184610ceb565b905092915050565b5f81905092915050565b5f610d5782610cc3565b610d618185610d43565b9350610d71818560208601610cdd565b80840191505092915050565b5f610d888284610d4d565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610dc7600f83610c4b565b9150610dd282610d93565b602082019050919050565b5f6020820190508181035f830152610df481610dbb565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f610e2f601483610c4b565b9150610e3a82610dfb565b602082019050919050565b5f6020820190508181035f830152610e5c81610e23565b9050919050565b5f81519050610e7181610a58565b92915050565b5f60208284031215610e8c57610e8b6107ea565b5b5f610e9984828501610e63565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610ed6600683610c4b565b9150610ee182610ea2565b602082019050919050565b5f6020820190508181035f830152610f0381610eca565b9050919050565b5f819050919050565b610f24610f1f826107f2565b610f0a565b82525050565b5f819050919050565b610f44610f3f826109d3565b610f2a565b82525050565b5f8160601b9050919050565b5f610f6082610f4a565b9050919050565b5f610f7182610f56565b9050919050565b610f89610f8482610a47565b610f67565b82525050565b5f610f9a8286610f13565b602082019150610faa8285610f33565b600282019150610fba8284610f78565b601482019150819050949350505050565b610fd4816109d3565b82525050565b610fe381610a47565b82525050565b5f606082019050610ffc5f830186610bb7565b6110096020830185610fcb565b6110166040830184610fda565b949350505050565b5f819050919050565b6110308161101e565b811461103a575f5ffd5b50565b5f8151905061104b81611027565b92915050565b5f60208284031215611066576110656107ea565b5b5f6110738482850161103d565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6110b0600f83610c4b565b91506110bb8261107c565b602082019050919050565b5f6020820190508181035f8301526110dd816110a4565b9050919050565b5f81519050919050565b5f81905092915050565b5f611102826110e4565b61110c81856110ee565b935061111c818560208601610cdd565b80840191505092915050565b5f61113382846110f8565b915081905092915050565b5f611148826110e4565b6111528185610c4b565b9350611162818560208601610cdd565b61116b81610858565b840191505092915050565b5f6020820190508181035f83015261118e818461113e565b905092915050565b5f6111a86111a384610ad2565b6108c6565b9050828152602081018484840111156111c4576111c3610854565b5b6111cf848285610cdd565b509392505050565b5f82601f8301126111eb576111ea610850565b5b81516111fb848260208601611196565b91505092915050565b5f60208284031215611219576112186107ea565b5b5f82015167ffffffffffffffff811115611236576112356107ee565b5b611242848285016111d7565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61127f600c83610c4b565b915061128a8261124b565b602082019050919050565b5f6020820190508181035f8301526112ac81611273565b905091905056fea26469706673582212205b27c3eb77c769b322aae891da6187e69e9871d973cb9f5fda8da3dec22f71af64736f6c634300081c0033 \ No newline at end of file +60a060405234801561000f575f5ffd5b506040516116d43803806116d4833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161158661014e5f395f81816101340152818161021401528181610378015281816104b2015281816105a0015281816105d7015281816106ea01526107f501526115865ff3fe608060405234801561000f575f5ffd5b506004361061007b575f3560e01c8063b4a8180811610059578063b4a81808146100d3578063c62c692f146100ef578063d7cc1f37146100f9578063db84d7c0146101155761007b565b806334d6d9be1461007f578063a93cbd971461009b578063ad8108a4146100b7575b5f5ffd5b6100996004803603810190610094919061093e565b610131565b005b6100b560048036038101906100b09190610aa5565b610210565b005b6100d160048036038101906100cc9190610b5c565b610376565b005b6100ed60048036038101906100e89190610aa5565b610458565b005b6100f761059e565b005b610113600480360381019061010e9190610c36565b6106bd565b005b61012f600480360381019061012a9190610d24565b6107cc565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161018b9190610d7a565b602060405180830381865afa1580156101a6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101ca9190610da7565b146101d8576101d7610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161020590610e59565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102629190610ed7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102cc9190610f31565b5f604051808303815f865af19150503d805f8114610305576040519150601f19603f3d011682016040523d82523d5f602084013e61030a565b606091505b5091509150811561031e5761031d610dd2565b5b828051906020012081805190602001201461033c5761033b610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161036990610f91565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016103cf9190610fd8565b602060405180830381865afa1580156103ea573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061040e9190611005565b815f0151146104205761041f610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161044d9061107a565b60405180910390a150565b5f5f8260405160240161046b9190610ed7565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516104f59190610f31565b5f60405180830381855afa9150503d805f811461052d576040519150601f19603f3d011682016040523d82523d5f602084013e610532565b606091505b50915091508161054557610544610dd2565b5b828051906020012081805190602001201461056357610562610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610590906110e2565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561063e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106629190611114565b73ffffffffffffffffffffffffffffffffffffffff161461068657610685610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106b390611189565b60405180910390a1565b8282826040516020016106d29392919061122c565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161074593929190611286565b602060405180830381865afa158015610760573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061078491906112ee565b1461079257610791610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107bf90611363565b60405180910390a1505050565b806040516020016107dd91906113c5565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b815260040161084c9190611413565b5f60405180830381865afa158015610866573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061088e91906114a1565b60405160200161089e91906113c5565b60405160208183030381529060405280519060200120146108c2576108c1610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108ef90611532565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61091d8161090b565b8114610927575f5ffd5b50565b5f8135905061093881610914565b92915050565b5f6020828403121561095357610952610903565b5b5f6109608482850161092a565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6109b782610971565b810181811067ffffffffffffffff821117156109d6576109d5610981565b5b80604052505050565b5f6109e86108fa565b90506109f482826109ae565b919050565b5f67ffffffffffffffff821115610a1357610a12610981565b5b610a1c82610971565b9050602081019050919050565b828183375f83830152505050565b5f610a49610a44846109f9565b6109df565b905082815260208101848484011115610a6557610a6461096d565b5b610a70848285610a29565b509392505050565b5f82601f830112610a8c57610a8b610969565b5b8135610a9c848260208601610a37565b91505092915050565b5f60208284031215610aba57610ab9610903565b5b5f82013567ffffffffffffffff811115610ad757610ad6610907565b5b610ae384828501610a78565b91505092915050565b5f5ffd5b5f819050919050565b610b0281610af0565b8114610b0c575f5ffd5b50565b5f81359050610b1d81610af9565b92915050565b5f60208284031215610b3857610b37610aec565b5b610b4260206109df565b90505f610b5184828501610b0f565b5f8301525092915050565b5f60208284031215610b7157610b70610903565b5b5f610b7e84828501610b23565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610bbb81610b87565b8114610bc5575f5ffd5b50565b5f81359050610bd681610bb2565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c0582610bdc565b9050919050565b610c1581610bfb565b8114610c1f575f5ffd5b50565b5f81359050610c3081610c0c565b92915050565b5f5f5f60608486031215610c4d57610c4c610903565b5b5f610c5a8682870161092a565b9350506020610c6b86828701610bc8565b9250506040610c7c86828701610c22565b9150509250925092565b5f67ffffffffffffffff821115610ca057610c9f610981565b5b610ca982610971565b9050602081019050919050565b5f610cc8610cc384610c86565b6109df565b905082815260208101848484011115610ce457610ce361096d565b5b610cef848285610a29565b509392505050565b5f82601f830112610d0b57610d0a610969565b5b8135610d1b848260208601610cb6565b91505092915050565b5f60208284031215610d3957610d38610903565b5b5f82013567ffffffffffffffff811115610d5657610d55610907565b5b610d6284828501610cf7565b91505092915050565b610d748161090b565b82525050565b5f602082019050610d8d5f830184610d6b565b92915050565b5f81519050610da181610914565b92915050565b5f60208284031215610dbc57610dbb610903565b5b5f610dc984828501610d93565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610e43600d83610dff565b9150610e4e82610e0f565b602082019050919050565b5f6020820190508181035f830152610e7081610e37565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610ea982610e77565b610eb38185610e81565b9350610ec3818560208601610e91565b610ecc81610971565b840191505092915050565b5f6020820190508181035f830152610eef8184610e9f565b905092915050565b5f81905092915050565b5f610f0b82610e77565b610f158185610ef7565b9350610f25818560208601610e91565b80840191505092915050565b5f610f3c8284610f01565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610f7b600f83610dff565b9150610f8682610f47565b602082019050919050565b5f6020820190508181035f830152610fa881610f6f565b9050919050565b610fb881610af0565b82525050565b602082015f820151610fd25f850182610faf565b50505050565b5f602082019050610feb5f830184610fbe565b92915050565b5f81519050610fff81610af9565b92915050565b5f6020828403121561101a57611019610903565b5b5f61102784828501610ff1565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f611064600c83610dff565b915061106f82611030565b602082019050919050565b5f6020820190508181035f83015261109181611058565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6110cc601483610dff565b91506110d782611098565b602082019050919050565b5f6020820190508181035f8301526110f9816110c0565b9050919050565b5f8151905061110e81610c0c565b92915050565b5f6020828403121561112957611128610903565b5b5f61113684828501611100565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f611173600683610dff565b915061117e8261113f565b602082019050919050565b5f6020820190508181035f8301526111a081611167565b9050919050565b5f819050919050565b6111c16111bc8261090b565b6111a7565b82525050565b5f819050919050565b6111e16111dc82610b87565b6111c7565b82525050565b5f8160601b9050919050565b5f6111fd826111e7565b9050919050565b5f61120e826111f3565b9050919050565b61122661122182610bfb565b611204565b82525050565b5f61123782866111b0565b60208201915061124782856111d0565b6002820191506112578284611215565b601482019150819050949350505050565b61127181610b87565b82525050565b61128081610bfb565b82525050565b5f6060820190506112995f830186610d6b565b6112a66020830185611268565b6112b36040830184611277565b949350505050565b5f819050919050565b6112cd816112bb565b81146112d7575f5ffd5b50565b5f815190506112e8816112c4565b92915050565b5f6020828403121561130357611302610903565b5b5f611310848285016112da565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f61134d600f83610dff565b915061135882611319565b602082019050919050565b5f6020820190508181035f83015261137a81611341565b9050919050565b5f81519050919050565b5f81905092915050565b5f61139f82611381565b6113a9818561138b565b93506113b9818560208601610e91565b80840191505092915050565b5f6113d08284611395565b915081905092915050565b5f6113e582611381565b6113ef8185610dff565b93506113ff818560208601610e91565b61140881610971565b840191505092915050565b5f6020820190508181035f83015261142b81846113db565b905092915050565b5f61144561144084610c86565b6109df565b9050828152602081018484840111156114615761146061096d565b5b61146c848285610e91565b509392505050565b5f82601f83011261148857611487610969565b5b8151611498848260208601611433565b91505092915050565b5f602082840312156114b6576114b5610903565b5b5f82015167ffffffffffffffff8111156114d3576114d2610907565b5b6114df84828501611474565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61151c600c83610dff565b9150611527826114e8565b602082019050919050565b5f6020820190508181035f83015261154981611510565b905091905056fea2646970667358221220cf4e683be87368d3d249175e8c416ebdb3928dae67bb586945f4f9798c59c2a664736f6c634300081c0033 \ No newline at end of file diff --git a/libevm/precompilegen/Test.sol b/libevm/precompilegen/Test.sol index fb1cd59c4a06..3b7ae27bde4b 100644 --- a/libevm/precompilegen/Test.sol +++ b/libevm/precompilegen/Test.sol @@ -41,6 +41,11 @@ contract PrecompileTest { emit Called("Echo(uint256)"); } + function Extract(IPrecompile.Wrapper memory x) external { + assert(x.val == precompile.Extract(x)); + emit Called("Extract(...)"); + } + function HashPacked(uint256 x, bytes2 y, address z) external { assert(precompile.HashPacked(x, y, z) == keccak256(abi.encodePacked(x, y, z))); emit Called("HashPacked(...)"); diff --git a/libevm/precompilegen/abigen.gen_test.go b/libevm/precompilegen/abigen.gen_test.go index 2d9470803e1b..226a67d4dd76 100644 --- a/libevm/precompilegen/abigen.gen_test.go +++ b/libevm/precompilegen/abigen.gen_test.go @@ -29,10 +29,15 @@ var ( _ = abi.ConvertType ) +// IPrecompileWrapper is an auto generated low-level Go binding around an user-defined struct. +type IPrecompileWrapper struct { + Val *big.Int +} + // PrecompileTestMetaData contains all meta data concerning the PrecompileTest contract. var PrecompileTestMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561000f575f5ffd5b5060405161142f38038061142f833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b6080516112e96101465f395f818160fd015281816101dd0152818161039901528181610487015281816104be015281816105d101526106dc01526112e95ff3fe608060405234801561000f575f5ffd5b5060043610610060575f3560e01c806334d6d9be14610064578063a93cbd9714610080578063b4a818081461009c578063c62c692f146100b8578063d7cc1f37146100c2578063db84d7c0146100de575b5f5ffd5b61007e60048036038101906100799190610825565b6100fa565b005b61009a6004803603810190610095919061098c565b6101d9565b005b6100b660048036038101906100b1919061098c565b61033f565b005b6100c0610485565b005b6100dc60048036038101906100d79190610a82565b6105a4565b005b6100f860048036038101906100f39190610b70565b6106b3565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016101549190610bc6565b602060405180830381865afa15801561016f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101939190610bf3565b146101a1576101a0610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101ce90610ca5565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161022b9190610d23565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102959190610d7d565b5f604051808303815f865af19150503d805f81146102ce576040519150601f19603f3d011682016040523d82523d5f602084013e6102d3565b606091505b509150915081156102e7576102e6610c1e565b5b828051906020012081805190602001201461030557610304610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161033290610ddd565b60405180910390a1505050565b5f5f826040516024016103529190610d23565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516103dc9190610d7d565b5f60405180830381855afa9150503d805f8114610414576040519150601f19603f3d011682016040523d82523d5f602084013e610419565b606091505b50915091508161042c5761042b610c1e565b5b828051906020012081805190602001201461044a57610449610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161047790610e45565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610525573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105499190610e77565b73ffffffffffffffffffffffffffffffffffffffff161461056d5761056c610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161059a90610eec565b60405180910390a1565b8282826040516020016105b993929190610f8f565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161062c93929190610fe9565b602060405180830381865afa158015610647573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061066b9190611051565b1461067957610678610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106a6906110c6565b60405180910390a1505050565b806040516020016106c49190611128565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b81526004016107339190611176565b5f60405180830381865afa15801561074d573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f820116820180604052508101906107759190611204565b6040516020016107859190611128565b60405160208183030381529060405280519060200120146107a9576107a8610c1e565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107d690611295565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610804816107f2565b811461080e575f5ffd5b50565b5f8135905061081f816107fb565b92915050565b5f6020828403121561083a576108396107ea565b5b5f61084784828501610811565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61089e82610858565b810181811067ffffffffffffffff821117156108bd576108bc610868565b5b80604052505050565b5f6108cf6107e1565b90506108db8282610895565b919050565b5f67ffffffffffffffff8211156108fa576108f9610868565b5b61090382610858565b9050602081019050919050565b828183375f83830152505050565b5f61093061092b846108e0565b6108c6565b90508281526020810184848401111561094c5761094b610854565b5b610957848285610910565b509392505050565b5f82601f83011261097357610972610850565b5b813561098384826020860161091e565b91505092915050565b5f602082840312156109a1576109a06107ea565b5b5f82013567ffffffffffffffff8111156109be576109bd6107ee565b5b6109ca8482850161095f565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610a07816109d3565b8114610a11575f5ffd5b50565b5f81359050610a22816109fe565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a5182610a28565b9050919050565b610a6181610a47565b8114610a6b575f5ffd5b50565b5f81359050610a7c81610a58565b92915050565b5f5f5f60608486031215610a9957610a986107ea565b5b5f610aa686828701610811565b9350506020610ab786828701610a14565b9250506040610ac886828701610a6e565b9150509250925092565b5f67ffffffffffffffff821115610aec57610aeb610868565b5b610af582610858565b9050602081019050919050565b5f610b14610b0f84610ad2565b6108c6565b905082815260208101848484011115610b3057610b2f610854565b5b610b3b848285610910565b509392505050565b5f82601f830112610b5757610b56610850565b5b8135610b67848260208601610b02565b91505092915050565b5f60208284031215610b8557610b846107ea565b5b5f82013567ffffffffffffffff811115610ba257610ba16107ee565b5b610bae84828501610b43565b91505092915050565b610bc0816107f2565b82525050565b5f602082019050610bd95f830184610bb7565b92915050565b5f81519050610bed816107fb565b92915050565b5f60208284031215610c0857610c076107ea565b5b5f610c1584828501610bdf565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610c8f600d83610c4b565b9150610c9a82610c5b565b602082019050919050565b5f6020820190508181035f830152610cbc81610c83565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610cf582610cc3565b610cff8185610ccd565b9350610d0f818560208601610cdd565b610d1881610858565b840191505092915050565b5f6020820190508181035f830152610d3b8184610ceb565b905092915050565b5f81905092915050565b5f610d5782610cc3565b610d618185610d43565b9350610d71818560208601610cdd565b80840191505092915050565b5f610d888284610d4d565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610dc7600f83610c4b565b9150610dd282610d93565b602082019050919050565b5f6020820190508181035f830152610df481610dbb565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f610e2f601483610c4b565b9150610e3a82610dfb565b602082019050919050565b5f6020820190508181035f830152610e5c81610e23565b9050919050565b5f81519050610e7181610a58565b92915050565b5f60208284031215610e8c57610e8b6107ea565b5b5f610e9984828501610e63565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f610ed6600683610c4b565b9150610ee182610ea2565b602082019050919050565b5f6020820190508181035f830152610f0381610eca565b9050919050565b5f819050919050565b610f24610f1f826107f2565b610f0a565b82525050565b5f819050919050565b610f44610f3f826109d3565b610f2a565b82525050565b5f8160601b9050919050565b5f610f6082610f4a565b9050919050565b5f610f7182610f56565b9050919050565b610f89610f8482610a47565b610f67565b82525050565b5f610f9a8286610f13565b602082019150610faa8285610f33565b600282019150610fba8284610f78565b601482019150819050949350505050565b610fd4816109d3565b82525050565b610fe381610a47565b82525050565b5f606082019050610ffc5f830186610bb7565b6110096020830185610fcb565b6110166040830184610fda565b949350505050565b5f819050919050565b6110308161101e565b811461103a575f5ffd5b50565b5f8151905061104b81611027565b92915050565b5f60208284031215611066576110656107ea565b5b5f6110738482850161103d565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6110b0600f83610c4b565b91506110bb8261107c565b602082019050919050565b5f6020820190508181035f8301526110dd816110a4565b9050919050565b5f81519050919050565b5f81905092915050565b5f611102826110e4565b61110c81856110ee565b935061111c818560208601610cdd565b80840191505092915050565b5f61113382846110f8565b915081905092915050565b5f611148826110e4565b6111528185610c4b565b9350611162818560208601610cdd565b61116b81610858565b840191505092915050565b5f6020820190508181035f83015261118e818461113e565b905092915050565b5f6111a86111a384610ad2565b6108c6565b9050828152602081018484840111156111c4576111c3610854565b5b6111cf848285610cdd565b509392505050565b5f82601f8301126111eb576111ea610850565b5b81516111fb848260208601611196565b91505092915050565b5f60208284031215611219576112186107ea565b5b5f82015167ffffffffffffffff811115611236576112356107ee565b5b611242848285016111d7565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61127f600c83610c4b565b915061128a8261124b565b602082019050919050565b5f6020820190508181035f8301526112ac81611273565b905091905056fea26469706673582212205b27c3eb77c769b322aae891da6187e69e9871d973cb9f5fda8da3dec22f71af64736f6c634300081c0033", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561000f575f5ffd5b506040516116d43803806116d4833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161158661014e5f395f81816101340152818161021401528181610378015281816104b2015281816105a0015281816105d7015281816106ea01526107f501526115865ff3fe608060405234801561000f575f5ffd5b506004361061007b575f3560e01c8063b4a8180811610059578063b4a81808146100d3578063c62c692f146100ef578063d7cc1f37146100f9578063db84d7c0146101155761007b565b806334d6d9be1461007f578063a93cbd971461009b578063ad8108a4146100b7575b5f5ffd5b6100996004803603810190610094919061093e565b610131565b005b6100b560048036038101906100b09190610aa5565b610210565b005b6100d160048036038101906100cc9190610b5c565b610376565b005b6100ed60048036038101906100e89190610aa5565b610458565b005b6100f761059e565b005b610113600480360381019061010e9190610c36565b6106bd565b005b61012f600480360381019061012a9190610d24565b6107cc565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161018b9190610d7a565b602060405180830381865afa1580156101a6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101ca9190610da7565b146101d8576101d7610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161020590610e59565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102629190610ed7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102cc9190610f31565b5f604051808303815f865af19150503d805f8114610305576040519150601f19603f3d011682016040523d82523d5f602084013e61030a565b606091505b5091509150811561031e5761031d610dd2565b5b828051906020012081805190602001201461033c5761033b610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161036990610f91565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016103cf9190610fd8565b602060405180830381865afa1580156103ea573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061040e9190611005565b815f0151146104205761041f610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161044d9061107a565b60405180910390a150565b5f5f8260405160240161046b9190610ed7565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516104f59190610f31565b5f60405180830381855afa9150503d805f811461052d576040519150601f19603f3d011682016040523d82523d5f602084013e610532565b606091505b50915091508161054557610544610dd2565b5b828051906020012081805190602001201461056357610562610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610590906110e2565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561063e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106629190611114565b73ffffffffffffffffffffffffffffffffffffffff161461068657610685610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106b390611189565b60405180910390a1565b8282826040516020016106d29392919061122c565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161074593929190611286565b602060405180830381865afa158015610760573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061078491906112ee565b1461079257610791610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107bf90611363565b60405180910390a1505050565b806040516020016107dd91906113c5565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b815260040161084c9190611413565b5f60405180830381865afa158015610866573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061088e91906114a1565b60405160200161089e91906113c5565b60405160208183030381529060405280519060200120146108c2576108c1610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108ef90611532565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61091d8161090b565b8114610927575f5ffd5b50565b5f8135905061093881610914565b92915050565b5f6020828403121561095357610952610903565b5b5f6109608482850161092a565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6109b782610971565b810181811067ffffffffffffffff821117156109d6576109d5610981565b5b80604052505050565b5f6109e86108fa565b90506109f482826109ae565b919050565b5f67ffffffffffffffff821115610a1357610a12610981565b5b610a1c82610971565b9050602081019050919050565b828183375f83830152505050565b5f610a49610a44846109f9565b6109df565b905082815260208101848484011115610a6557610a6461096d565b5b610a70848285610a29565b509392505050565b5f82601f830112610a8c57610a8b610969565b5b8135610a9c848260208601610a37565b91505092915050565b5f60208284031215610aba57610ab9610903565b5b5f82013567ffffffffffffffff811115610ad757610ad6610907565b5b610ae384828501610a78565b91505092915050565b5f5ffd5b5f819050919050565b610b0281610af0565b8114610b0c575f5ffd5b50565b5f81359050610b1d81610af9565b92915050565b5f60208284031215610b3857610b37610aec565b5b610b4260206109df565b90505f610b5184828501610b0f565b5f8301525092915050565b5f60208284031215610b7157610b70610903565b5b5f610b7e84828501610b23565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610bbb81610b87565b8114610bc5575f5ffd5b50565b5f81359050610bd681610bb2565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c0582610bdc565b9050919050565b610c1581610bfb565b8114610c1f575f5ffd5b50565b5f81359050610c3081610c0c565b92915050565b5f5f5f60608486031215610c4d57610c4c610903565b5b5f610c5a8682870161092a565b9350506020610c6b86828701610bc8565b9250506040610c7c86828701610c22565b9150509250925092565b5f67ffffffffffffffff821115610ca057610c9f610981565b5b610ca982610971565b9050602081019050919050565b5f610cc8610cc384610c86565b6109df565b905082815260208101848484011115610ce457610ce361096d565b5b610cef848285610a29565b509392505050565b5f82601f830112610d0b57610d0a610969565b5b8135610d1b848260208601610cb6565b91505092915050565b5f60208284031215610d3957610d38610903565b5b5f82013567ffffffffffffffff811115610d5657610d55610907565b5b610d6284828501610cf7565b91505092915050565b610d748161090b565b82525050565b5f602082019050610d8d5f830184610d6b565b92915050565b5f81519050610da181610914565b92915050565b5f60208284031215610dbc57610dbb610903565b5b5f610dc984828501610d93565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610e43600d83610dff565b9150610e4e82610e0f565b602082019050919050565b5f6020820190508181035f830152610e7081610e37565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610ea982610e77565b610eb38185610e81565b9350610ec3818560208601610e91565b610ecc81610971565b840191505092915050565b5f6020820190508181035f830152610eef8184610e9f565b905092915050565b5f81905092915050565b5f610f0b82610e77565b610f158185610ef7565b9350610f25818560208601610e91565b80840191505092915050565b5f610f3c8284610f01565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610f7b600f83610dff565b9150610f8682610f47565b602082019050919050565b5f6020820190508181035f830152610fa881610f6f565b9050919050565b610fb881610af0565b82525050565b602082015f820151610fd25f850182610faf565b50505050565b5f602082019050610feb5f830184610fbe565b92915050565b5f81519050610fff81610af9565b92915050565b5f6020828403121561101a57611019610903565b5b5f61102784828501610ff1565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f611064600c83610dff565b915061106f82611030565b602082019050919050565b5f6020820190508181035f83015261109181611058565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6110cc601483610dff565b91506110d782611098565b602082019050919050565b5f6020820190508181035f8301526110f9816110c0565b9050919050565b5f8151905061110e81610c0c565b92915050565b5f6020828403121561112957611128610903565b5b5f61113684828501611100565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f611173600683610dff565b915061117e8261113f565b602082019050919050565b5f6020820190508181035f8301526111a081611167565b9050919050565b5f819050919050565b6111c16111bc8261090b565b6111a7565b82525050565b5f819050919050565b6111e16111dc82610b87565b6111c7565b82525050565b5f8160601b9050919050565b5f6111fd826111e7565b9050919050565b5f61120e826111f3565b9050919050565b61122661122182610bfb565b611204565b82525050565b5f61123782866111b0565b60208201915061124782856111d0565b6002820191506112578284611215565b601482019150819050949350505050565b61127181610b87565b82525050565b61128081610bfb565b82525050565b5f6060820190506112995f830186610d6b565b6112a66020830185611268565b6112b36040830184611277565b949350505050565b5f819050919050565b6112cd816112bb565b81146112d7575f5ffd5b50565b5f815190506112e8816112c4565b92915050565b5f6020828403121561130357611302610903565b5b5f611310848285016112da565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f61134d600f83610dff565b915061135882611319565b602082019050919050565b5f6020820190508181035f83015261137a81611341565b9050919050565b5f81519050919050565b5f81905092915050565b5f61139f82611381565b6113a9818561138b565b93506113b9818560208601610e91565b80840191505092915050565b5f6113d08284611395565b915081905092915050565b5f6113e582611381565b6113ef8185610dff565b93506113ff818560208601610e91565b61140881610971565b840191505092915050565b5f6020820190508181035f83015261142b81846113db565b905092915050565b5f61144561144084610c86565b6109df565b9050828152602081018484840111156114615761146061096d565b5b61146c848285610e91565b509392505050565b5f82601f83011261148857611487610969565b5b8151611498848260208601611433565b91505092915050565b5f602082840312156114b6576114b5610903565b5b5f82015167ffffffffffffffff8111156114d3576114d2610907565b5b6114df84828501611474565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61151c600c83610dff565b9150611527826114e8565b602082019050919050565b5f6020820190508181035f83015261154981611510565b905091905056fea2646970667358221220cf4e683be87368d3d249175e8c416ebdb3928dae67bb586945f4f9798c59c2a664736f6c634300081c0033", } // PrecompileTestABI is the input ABI used to generate the binding from. @@ -265,6 +270,27 @@ func (_PrecompileTest *PrecompileTestTransactorSession) EchoingFallback(input [] return _PrecompileTest.Contract.EchoingFallback(&_PrecompileTest.TransactOpts, input) } +// Extract is a paid mutator transaction binding the contract method 0xad8108a4. +// +// Solidity: function Extract((int256) x) returns() +func (_PrecompileTest *PrecompileTestTransactor) Extract(opts *bind.TransactOpts, x IPrecompileWrapper) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "Extract", x) +} + +// Extract is a paid mutator transaction binding the contract method 0xad8108a4. +// +// Solidity: function Extract((int256) x) returns() +func (_PrecompileTest *PrecompileTestSession) Extract(x IPrecompileWrapper) (*types.Transaction, error) { + return _PrecompileTest.Contract.Extract(&_PrecompileTest.TransactOpts, x) +} + +// Extract is a paid mutator transaction binding the contract method 0xad8108a4. +// +// Solidity: function Extract((int256) x) returns() +func (_PrecompileTest *PrecompileTestTransactorSession) Extract(x IPrecompileWrapper) (*types.Transaction, error) { + return _PrecompileTest.Contract.Extract(&_PrecompileTest.TransactOpts, x) +} + // HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. // // Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() diff --git a/libevm/precompilegen/gen_test.go b/libevm/precompilegen/gen_test.go index 597873bd5475..12a348523de7 100644 --- a/libevm/precompilegen/gen_test.go +++ b/libevm/precompilegen/gen_test.go @@ -114,6 +114,14 @@ func TestGeneratedPrecompile(t *testing.T) { }, wantCalledEvent: "Echo(string)", }, + { + transact: func() (*types.Transaction, error) { + return suite.Extract(IPrecompileWrapper{ + Val: rng.BigUint64(), + }) + }, + wantCalledEvent: "Extract(...)", + }, { transact: func() (*types.Transaction, error) { return suite.HashPacked(rng.BigUint64(), [2]byte{42, 42}, rng.Address()) From 268790e9c98af469ef07ac3f5ba90de417bf669a Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Wed, 13 Nov 2024 11:34:38 +0000 Subject: [PATCH 05/22] refactor: move `vm.Selector` etc. to `abi` package --- accounts/abi/selector.libevm.go | 75 +++++++++++++++++++ core/vm/contracts.libevm.go | 54 +------------ libevm/precompilegen/gen.go | 7 +- libevm/precompilegen/precompile.go.tmpl | 10 +-- .../precompilegen/testprecompile/generated.go | 18 ++--- 5 files changed, 95 insertions(+), 69 deletions(-) create mode 100644 accounts/abi/selector.libevm.go diff --git a/accounts/abi/selector.libevm.go b/accounts/abi/selector.libevm.go new file mode 100644 index 000000000000..6405bb7c6ac6 --- /dev/null +++ b/accounts/abi/selector.libevm.go @@ -0,0 +1,75 @@ +// Copyright 2024 the libevm authors. +// +// The libevm additions to go-ethereum are free software: you can redistribute +// them and/or modify them under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The libevm additions are distributed in the hope that they will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see +// . + +package abi + +import ( + "encoding/binary" + "fmt" +) + +// SelectorByteLen is the number of bytes in an ABI function selector. +const SelectorByteLen = 4 + +// A Selector is an ABI function selector. It is a uint32 instead of a [4]byte +// to allow for simpler hex literals. +type Selector uint32 + +// String returns a hex encoding of `s`. +func (s Selector) String() string { + b := make([]byte, 4) + binary.BigEndian.PutUint32(b, uint32(s)) + return fmt.Sprintf("%#x", b) +} + +// ExtractSelector returns the first 4 bytes of the slice as a Selector. It +// assumes that its input is of sufficient length. +func ExtractSelector(data []byte) Selector { + return Selector(binary.BigEndian.Uint32(data[:4])) +} + +// Selector returns the Method's ID as a Selector. +func (m Method) Selector() Selector { + return ExtractSelector(m.ID) +} + +// MethodsBySelector maps 4-byte ABI selectors to the corresponding method +// representation. The key MUST be equivalent to the value's [Method.Selector]. +type MethodsBySelector map[Selector]Method + +// BySelector returns the the [Method]s keyed by their Selectors. +func (a *ABI) MethodsBySelector() MethodsBySelector { + ms := make(MethodsBySelector) + for _, m := range a.Methods { + ms[m.Selector()] = m + } + return ms +} + +// FindSelector extracts the Selector from `data` and, if it exists in `m`, +// returns it. The returned boolean functions as for regular map lookups. Unlike +// [ExtractSelector], FindSelector confirms that `data` has at least 4 bytes, +// treating invalid inputs as not found. +func (m MethodsBySelector) FindSelector(data []byte) (Selector, bool) { + if len(data) < SelectorByteLen { + return 0, false + } + sel := ExtractSelector(data) + if _, ok := m[sel]; !ok { + return 0, false + } + return sel, true +} diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index 57016f91296d..92dde058fa0c 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -17,13 +17,11 @@ package vm import ( - "encoding/binary" "fmt" "math/big" "github.com/holiman/uint256" - "github.com/ava-labs/libevm/accounts/abi" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/types" "github.com/ava-labs/libevm/libevm" @@ -202,56 +200,10 @@ var ( } ) -// SelectorByteLen is the number of bytes in an ABI function selector. -const SelectorByteLen = 4 - -// A Selector is an ABI function selector. It is a uint32 instead of a [4]byte -// to allow for simpler hex literals. -type Selector uint32 - -// String returns a hex encoding of `s`. -func (s Selector) String() string { - b := make([]byte, 4) - binary.BigEndian.PutUint32(b, uint32(s)) - return fmt.Sprintf("%#x", b) -} - -// ExtractSelector returns the first 4 bytes of the slice as a Selector. It -// assumes that its input is of sufficient length. -func ExtractSelector(data []byte) Selector { - return Selector(binary.BigEndian.Uint32(data[:4])) -} - -// MethodsBySelector maps 4-byte ABI selectors to the corresponding method -// representation. The key MUST be equivalent to the value's [abi.Method.ID]. -type MethodsBySelector map[Selector]abi.Method - -// BySelector remaps the Methods to be keyed by their Selectors. -func BySelector(methods map[string]abi.Method) MethodsBySelector { - ms := make(MethodsBySelector) - for _, m := range methods { - ms[ExtractSelector(m.ID)] = m - } - return ms -} - -// FindSelector extracts the Selector from `data` and, if it exists in `m`, -// returns it. The returned boolean functions as for regular map lookups. Unlike -// [ExtractSelector], FindSelector confirms that `data` has at least 4 bytes, -// treating invalid inputs as not found. -func (m MethodsBySelector) FindSelector(data []byte) (Selector, bool) { - if len(data) < SelectorByteLen { - return 0, false - } - sel := ExtractSelector(data) - if _, ok := m[sel]; !ok { - return 0, false - } - return sel, true -} - // A RevertError is an error that couples [ErrExecutionReverted] with the EVM -// return buffer. TODO(arr4n): explain use with precompilegen contracts. +// return buffer. Although not used in vanilla geth, it can be returned by a +// libevm `precompilegen` method implementation to circumvent regular argument +// packing. type RevertError []byte // Error is equivalent to the respective method on [ErrExecutionReverted]. diff --git a/libevm/precompilegen/gen.go b/libevm/precompilegen/gen.go index 18da3a8b6d6e..5210f39b84aa 100644 --- a/libevm/precompilegen/gen.go +++ b/libevm/precompilegen/gen.go @@ -30,7 +30,6 @@ import ( "text/template" "github.com/ava-labs/libevm/accounts/abi" - "github.com/ava-labs/libevm/core/vm" _ "embed" ) @@ -134,10 +133,10 @@ func signature(m abi.Method) string { } // interfaceID returns the EIP-165 interface ID of the methods. -func interfaceID(a abi.ABI) vm.Selector { - var id vm.Selector +func interfaceID(a abi.ABI) abi.Selector { + var id abi.Selector for _, m := range a.Methods { - id ^= vm.ExtractSelector(m.ID) + id ^= m.Selector() } return id } diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index 51428166b991..b57048112704 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -33,8 +33,8 @@ var ( _ *big.Int = nil _ *common.Address = nil - methods vm.MethodsBySelector - dispatchers map[vm.Selector]methodDispatcher + methods abi.MethodsBySelector + dispatchers map[abi.Selector]methodDispatcher ) const abiJSON = `{{.JSON}}` @@ -44,10 +44,10 @@ func init() { if err != nil { panic(err.Error()) } - methods = vm.BySelector(parsed.Methods) + methods = parsed.MethodsBySelector() var d dispatch - dispatchers = map[vm.Selector]methodDispatcher{ + dispatchers = map[abi.Selector]methodDispatcher{ {{range methods .ABI}}{{hex .ID}}: d.{{.Name}}, {{end}} } @@ -88,7 +88,7 @@ func (dispatch) {{.Name}}(impl Contract, env vm.PrecompileEnvironment, input []b method := methods[{{hex .ID}}] {{if gt (len .Inputs) 0}} - inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err } diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index 5a702d91b8f8..4c645554fea4 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -54,8 +54,8 @@ var ( _ *big.Int = nil _ *common.Address = nil - methods vm.MethodsBySelector - dispatchers map[vm.Selector]methodDispatcher + methods abi.MethodsBySelector + dispatchers map[abi.Selector]methodDispatcher ) const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]` @@ -65,10 +65,10 @@ func init() { if err != nil { panic(err.Error()) } - methods = vm.BySelector(parsed.Methods) + methods = parsed.MethodsBySelector() var d dispatch - dispatchers = map[vm.Selector]methodDispatcher{ + dispatchers = map[abi.Selector]methodDispatcher{ 0x34d6d9be: d.Echo, 0xdb84d7c0: d.Echo0, 0xad8108a4: d.Extract, @@ -111,7 +111,7 @@ type dispatch struct{} func (dispatch) Echo(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0x34d6d9be] - inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err } @@ -130,7 +130,7 @@ func (dispatch) Echo(impl Contract, env vm.PrecompileEnvironment, input []byte) func (dispatch) Echo0(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0xdb84d7c0] - inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err } @@ -149,7 +149,7 @@ func (dispatch) Echo0(impl Contract, env vm.PrecompileEnvironment, input []byte) func (dispatch) Extract(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0xad8108a4] - inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err } @@ -170,7 +170,7 @@ func (dispatch) Extract(impl Contract, env vm.PrecompileEnvironment, input []byt func (dispatch) HashPacked(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0xd7cc1f37] - inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err } @@ -191,7 +191,7 @@ func (dispatch) HashPacked(impl Contract, env vm.PrecompileEnvironment, input [] func (dispatch) RevertWith(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0xa93cbd97] - inputs, err := method.Inputs.Unpack(input[vm.SelectorByteLen:]) + inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err } From e841e39c57c2bdb0be8bf011bea517194e8fca83 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 14 Nov 2024 13:55:01 +0000 Subject: [PATCH 06/22] chore: remove unnecessary `require` argument --- libevm/precompilegen/gen_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevm/precompilegen/gen_test.go b/libevm/precompilegen/gen_test.go index 12a348523de7..34656d03ec58 100644 --- a/libevm/precompilegen/gen_test.go +++ b/libevm/precompilegen/gen_test.go @@ -159,7 +159,7 @@ func TestGeneratedPrecompile(t *testing.T) { require.Lenf(t, rcpt.Logs, 1, "%T.Logs", rcpt) called, err := test.ParseCalled(*rcpt.Logs[0]) - require.NoErrorf(t, err, "%T.ParseCalled(...)", test, err) + require.NoErrorf(t, err, "%T.ParseCalled(...)", test) assert.Equal(t, tt.wantCalledEvent, called.Arg0, "function name emitted with `Called` event") }) } From 4fc6bcc0a1b6e329096cf899d797804d5e5ca210 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 11:50:30 +0000 Subject: [PATCH 07/22] chore: file renaming and deletion --- libevm/precompilegen/.gitignore | 4 +++- libevm/precompilegen/IPrecompile.abi | 1 - libevm/precompilegen/PrecompileTest.abi | 1 - libevm/precompilegen/PrecompileTest.bin | 1 - libevm/precompilegen/{gen.go => main.go} | 0 libevm/precompilegen/{gen_test.go => main_test.go} | 2 ++ 6 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 libevm/precompilegen/IPrecompile.abi delete mode 100644 libevm/precompilegen/PrecompileTest.abi delete mode 100644 libevm/precompilegen/PrecompileTest.bin rename libevm/precompilegen/{gen.go => main.go} (100%) rename libevm/precompilegen/{gen_test.go => main_test.go} (98%) diff --git a/libevm/precompilegen/.gitignore b/libevm/precompilegen/.gitignore index dcc4b4f7fe81..ba75a4ee7f65 100644 --- a/libevm/precompilegen/.gitignore +++ b/libevm/precompilegen/.gitignore @@ -1 +1,3 @@ -IPrecompile.bin +*.abi +*.bin + diff --git a/libevm/precompilegen/IPrecompile.abi b/libevm/precompilegen/IPrecompile.abi deleted file mode 100644 index 93403c2815f9..000000000000 --- a/libevm/precompilegen/IPrecompile.abi +++ /dev/null @@ -1 +0,0 @@ -[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/PrecompileTest.abi b/libevm/precompilegen/PrecompileTest.abi deleted file mode 100644 index 26976dc1914f..000000000000 --- a/libevm/precompilegen/PrecompileTest.abi +++ /dev/null @@ -1 +0,0 @@ -[{"inputs":[{"internalType":"contract IPrecompile","name":"_precompile","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"func","type":"string"}],"name":"Called","type":"event"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"x","type":"string"}],"name":"Echo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"}],"name":"EchoingFallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"x","type":"tuple"}],"name":"Extract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"bytes2","name":"y","type":"bytes2"},{"internalType":"address","name":"z","type":"address"}],"name":"HashPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"err","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/libevm/precompilegen/PrecompileTest.bin b/libevm/precompilegen/PrecompileTest.bin deleted file mode 100644 index b98d329aa25e..000000000000 --- a/libevm/precompilegen/PrecompileTest.bin +++ /dev/null @@ -1 +0,0 @@ -60a060405234801561000f575f5ffd5b506040516116d43803806116d4833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161158661014e5f395f81816101340152818161021401528181610378015281816104b2015281816105a0015281816105d7015281816106ea01526107f501526115865ff3fe608060405234801561000f575f5ffd5b506004361061007b575f3560e01c8063b4a8180811610059578063b4a81808146100d3578063c62c692f146100ef578063d7cc1f37146100f9578063db84d7c0146101155761007b565b806334d6d9be1461007f578063a93cbd971461009b578063ad8108a4146100b7575b5f5ffd5b6100996004803603810190610094919061093e565b610131565b005b6100b560048036038101906100b09190610aa5565b610210565b005b6100d160048036038101906100cc9190610b5c565b610376565b005b6100ed60048036038101906100e89190610aa5565b610458565b005b6100f761059e565b005b610113600480360381019061010e9190610c36565b6106bd565b005b61012f600480360381019061012a9190610d24565b6107cc565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161018b9190610d7a565b602060405180830381865afa1580156101a6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101ca9190610da7565b146101d8576101d7610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161020590610e59565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102629190610ed7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102cc9190610f31565b5f604051808303815f865af19150503d805f8114610305576040519150601f19603f3d011682016040523d82523d5f602084013e61030a565b606091505b5091509150811561031e5761031d610dd2565b5b828051906020012081805190602001201461033c5761033b610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161036990610f91565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016103cf9190610fd8565b602060405180830381865afa1580156103ea573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061040e9190611005565b815f0151146104205761041f610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161044d9061107a565b60405180910390a150565b5f5f8260405160240161046b9190610ed7565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516104f59190610f31565b5f60405180830381855afa9150503d805f811461052d576040519150601f19603f3d011682016040523d82523d5f602084013e610532565b606091505b50915091508161054557610544610dd2565b5b828051906020012081805190602001201461056357610562610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610590906110e2565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561063e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106629190611114565b73ffffffffffffffffffffffffffffffffffffffff161461068657610685610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106b390611189565b60405180910390a1565b8282826040516020016106d29392919061122c565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161074593929190611286565b602060405180830381865afa158015610760573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061078491906112ee565b1461079257610791610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107bf90611363565b60405180910390a1505050565b806040516020016107dd91906113c5565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b815260040161084c9190611413565b5f60405180830381865afa158015610866573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061088e91906114a1565b60405160200161089e91906113c5565b60405160208183030381529060405280519060200120146108c2576108c1610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108ef90611532565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61091d8161090b565b8114610927575f5ffd5b50565b5f8135905061093881610914565b92915050565b5f6020828403121561095357610952610903565b5b5f6109608482850161092a565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6109b782610971565b810181811067ffffffffffffffff821117156109d6576109d5610981565b5b80604052505050565b5f6109e86108fa565b90506109f482826109ae565b919050565b5f67ffffffffffffffff821115610a1357610a12610981565b5b610a1c82610971565b9050602081019050919050565b828183375f83830152505050565b5f610a49610a44846109f9565b6109df565b905082815260208101848484011115610a6557610a6461096d565b5b610a70848285610a29565b509392505050565b5f82601f830112610a8c57610a8b610969565b5b8135610a9c848260208601610a37565b91505092915050565b5f60208284031215610aba57610ab9610903565b5b5f82013567ffffffffffffffff811115610ad757610ad6610907565b5b610ae384828501610a78565b91505092915050565b5f5ffd5b5f819050919050565b610b0281610af0565b8114610b0c575f5ffd5b50565b5f81359050610b1d81610af9565b92915050565b5f60208284031215610b3857610b37610aec565b5b610b4260206109df565b90505f610b5184828501610b0f565b5f8301525092915050565b5f60208284031215610b7157610b70610903565b5b5f610b7e84828501610b23565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610bbb81610b87565b8114610bc5575f5ffd5b50565b5f81359050610bd681610bb2565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c0582610bdc565b9050919050565b610c1581610bfb565b8114610c1f575f5ffd5b50565b5f81359050610c3081610c0c565b92915050565b5f5f5f60608486031215610c4d57610c4c610903565b5b5f610c5a8682870161092a565b9350506020610c6b86828701610bc8565b9250506040610c7c86828701610c22565b9150509250925092565b5f67ffffffffffffffff821115610ca057610c9f610981565b5b610ca982610971565b9050602081019050919050565b5f610cc8610cc384610c86565b6109df565b905082815260208101848484011115610ce457610ce361096d565b5b610cef848285610a29565b509392505050565b5f82601f830112610d0b57610d0a610969565b5b8135610d1b848260208601610cb6565b91505092915050565b5f60208284031215610d3957610d38610903565b5b5f82013567ffffffffffffffff811115610d5657610d55610907565b5b610d6284828501610cf7565b91505092915050565b610d748161090b565b82525050565b5f602082019050610d8d5f830184610d6b565b92915050565b5f81519050610da181610914565b92915050565b5f60208284031215610dbc57610dbb610903565b5b5f610dc984828501610d93565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610e43600d83610dff565b9150610e4e82610e0f565b602082019050919050565b5f6020820190508181035f830152610e7081610e37565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610ea982610e77565b610eb38185610e81565b9350610ec3818560208601610e91565b610ecc81610971565b840191505092915050565b5f6020820190508181035f830152610eef8184610e9f565b905092915050565b5f81905092915050565b5f610f0b82610e77565b610f158185610ef7565b9350610f25818560208601610e91565b80840191505092915050565b5f610f3c8284610f01565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610f7b600f83610dff565b9150610f8682610f47565b602082019050919050565b5f6020820190508181035f830152610fa881610f6f565b9050919050565b610fb881610af0565b82525050565b602082015f820151610fd25f850182610faf565b50505050565b5f602082019050610feb5f830184610fbe565b92915050565b5f81519050610fff81610af9565b92915050565b5f6020828403121561101a57611019610903565b5b5f61102784828501610ff1565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f611064600c83610dff565b915061106f82611030565b602082019050919050565b5f6020820190508181035f83015261109181611058565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6110cc601483610dff565b91506110d782611098565b602082019050919050565b5f6020820190508181035f8301526110f9816110c0565b9050919050565b5f8151905061110e81610c0c565b92915050565b5f6020828403121561112957611128610903565b5b5f61113684828501611100565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f611173600683610dff565b915061117e8261113f565b602082019050919050565b5f6020820190508181035f8301526111a081611167565b9050919050565b5f819050919050565b6111c16111bc8261090b565b6111a7565b82525050565b5f819050919050565b6111e16111dc82610b87565b6111c7565b82525050565b5f8160601b9050919050565b5f6111fd826111e7565b9050919050565b5f61120e826111f3565b9050919050565b61122661122182610bfb565b611204565b82525050565b5f61123782866111b0565b60208201915061124782856111d0565b6002820191506112578284611215565b601482019150819050949350505050565b61127181610b87565b82525050565b61128081610bfb565b82525050565b5f6060820190506112995f830186610d6b565b6112a66020830185611268565b6112b36040830184611277565b949350505050565b5f819050919050565b6112cd816112bb565b81146112d7575f5ffd5b50565b5f815190506112e8816112c4565b92915050565b5f6020828403121561130357611302610903565b5b5f611310848285016112da565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f61134d600f83610dff565b915061135882611319565b602082019050919050565b5f6020820190508181035f83015261137a81611341565b9050919050565b5f81519050919050565b5f81905092915050565b5f61139f82611381565b6113a9818561138b565b93506113b9818560208601610e91565b80840191505092915050565b5f6113d08284611395565b915081905092915050565b5f6113e582611381565b6113ef8185610dff565b93506113ff818560208601610e91565b61140881610971565b840191505092915050565b5f6020820190508181035f83015261142b81846113db565b905092915050565b5f61144561144084610c86565b6109df565b9050828152602081018484840111156114615761146061096d565b5b61146c848285610e91565b509392505050565b5f82601f83011261148857611487610969565b5b8151611498848260208601611433565b91505092915050565b5f602082840312156114b6576114b5610903565b5b5f82015167ffffffffffffffff8111156114d3576114d2610907565b5b6114df84828501611474565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61151c600c83610dff565b9150611527826114e8565b602082019050919050565b5f6020820190508181035f83015261154981611510565b905091905056fea2646970667358221220cf4e683be87368d3d249175e8c416ebdb3928dae67bb586945f4f9798c59c2a664736f6c634300081c0033 \ No newline at end of file diff --git a/libevm/precompilegen/gen.go b/libevm/precompilegen/main.go similarity index 100% rename from libevm/precompilegen/gen.go rename to libevm/precompilegen/main.go diff --git a/libevm/precompilegen/gen_test.go b/libevm/precompilegen/main_test.go similarity index 98% rename from libevm/precompilegen/gen_test.go rename to libevm/precompilegen/main_test.go index a7477a21c5ff..33c39c01fda1 100644 --- a/libevm/precompilegen/gen_test.go +++ b/libevm/precompilegen/main_test.go @@ -39,6 +39,8 @@ import ( "github.com/ava-labs/libevm/params" ) +// Note that the .abi and .bin files are .gitignored as only the generated Go +// files are necessary. //go:generate solc -o ./ --overwrite --abi --bin Test.sol //go:generate go run . -in IPrecompile.abi -out ./testprecompile/generated.go -package testprecompile //go:generate go run ../../cmd/abigen --abi PrecompileTest.abi --bin PrecompileTest.bin --pkg main --out ./abigen.gen_test.go --type PrecompileTest From 9f392aedc9fdbda8913072c1dee1a40c5af2723c Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 12:05:34 +0000 Subject: [PATCH 08/22] chore: `go:generate` workflow in `ethereum/solc` container --- .github/workflows/go.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index db48851ef50c..9673d0e7f5f8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,6 +29,7 @@ jobs: env: EXCLUDE_REGEX: 'ava-labs/libevm/(accounts/usbwallet/trezor)$' runs-on: ubuntu-latest + container: ethereum/solc:0.8.28 steps: - uses: actions/checkout@v4 - name: Set up Go From 31e9a9a836279fadc5066951333b7d366b46895a Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 12:15:05 +0000 Subject: [PATCH 09/22] chore: fight with GH Actions and Docker... en garde! --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9673d0e7f5f8..53064492244f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,7 +29,7 @@ jobs: env: EXCLUDE_REGEX: 'ava-labs/libevm/(accounts/usbwallet/trezor)$' runs-on: ubuntu-latest - container: ethereum/solc:0.8.28 + container: ethereum/solc:0.8.28-alpine steps: - uses: actions/checkout@v4 - name: Set up Go From 1442e0fb61e34ca6270fdaf21a5ad219eaa18010 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 12:34:42 +0000 Subject: [PATCH 10/22] chore: install `solc` via `apt` instead --- .github/workflows/go.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 53064492244f..6785b8e55cb7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,8 +29,13 @@ jobs: env: EXCLUDE_REGEX: 'ava-labs/libevm/(accounts/usbwallet/trezor)$' runs-on: ubuntu-latest - container: ethereum/solc:0.8.28-alpine steps: + - name: Install solc + run: | + sudo add-apt-repository ppa:ethereum/ethereum + sudo apt update + sudo apt install solc=0.8.28 + - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 From 34f134b5b8e6ece0df1415fe3f882dbc43afa7e0 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 12:36:19 +0000 Subject: [PATCH 11/22] fix: `apt` `solc` version --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6785b8e55cb7..fe2723fa4bee 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -34,7 +34,7 @@ jobs: run: | sudo add-apt-repository ppa:ethereum/ethereum sudo apt update - sudo apt install solc=0.8.28 + sudo apt install solc=1:0.8.28-0ubuntu1 - uses: actions/checkout@v4 - name: Set up Go From 85dc08904adadae614cefacdebedc5353b6e68d2 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 12:38:35 +0000 Subject: [PATCH 12/22] chore: `apt list` in workflow; I hate GH Actions --- .github/workflows/go.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fe2723fa4bee..3287a7c9c328 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -34,7 +34,8 @@ jobs: run: | sudo add-apt-repository ppa:ethereum/ethereum sudo apt update - sudo apt install solc=1:0.8.28-0ubuntu1 + sudo apt list -a solc + sudo apt install solc=1:0.8.28-0ubuntu1~noble - uses: actions/checkout@v4 - name: Set up Go From 49f23123226429c0fb6951372fb8e8d17e04a159 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 19 Dec 2024 18:20:03 +0000 Subject: [PATCH 13/22] feat: `view` and `pure` mutability limitations --- core/vm/contracts.libevm.go | 14 +++- core/vm/environment.libevm.go | 40 ++++++---- libevm/precompilegen/Test.sol | 32 ++++++++ libevm/precompilegen/abigen.gen_test.go | 67 +++++++++++++++- libevm/precompilegen/main_test.go | 40 +++++++++- libevm/precompilegen/precompile.go.tmpl | 17 ++++ .../precompilegen/testprecompile/generated.go | 77 ++++++++++++++++++- 7 files changed, 265 insertions(+), 22 deletions(-) diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index 1325b8a40513..7c866bfa6de9 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -143,12 +143,22 @@ type PrecompileEnvironment interface { Rules() params.Rules // StateDB will be non-nil i.f.f !ReadOnly(). StateDB() StateDB - // ReadOnlyState will always be non-nil. + // ReadOnlyState will be non-nil i.f.f. SetPure() has not been called. ReadOnlyState() libevm.StateReader + // SetReadOnly ensures that all future calls to ReadOnly() will return true. + // Is can be used as a guard against accidental writes when a read-only + // function is invoked with EVM call() instead of staticcall(). + SetReadOnly() + // SetPure ensures that all future calls to ReadOnly() will return true and + // that calls to ReadOnlyState() will return nil. + // TODO(arr4n) DO NOT MERGE: change this and SetReadOnly to return new + // environments. + SetPure() + ReadOnly() bool + IncomingCallType() CallType Addresses() *libevm.AddressContext - ReadOnly() bool // Equivalent to respective methods on [Contract]. Gas() uint64 UseGas(uint64) (hasEnoughGas bool) diff --git a/core/vm/environment.libevm.go b/core/vm/environment.libevm.go index f2b61169d26e..df7f8b9b24d9 100644 --- a/core/vm/environment.libevm.go +++ b/core/vm/environment.libevm.go @@ -33,21 +33,21 @@ import ( var _ PrecompileEnvironment = (*environment)(nil) type environment struct { - evm *EVM - self *Contract - callType CallType + evm *EVM + self *Contract + callType CallType + view, pure bool } func (e *environment) Gas() uint64 { return e.self.Gas } func (e *environment) UseGas(gas uint64) bool { return e.self.UseGas(gas) } func (e *environment) Value() *uint256.Int { return new(uint256.Int).Set(e.self.Value()) } -func (e *environment) ChainConfig() *params.ChainConfig { return e.evm.chainConfig } -func (e *environment) Rules() params.Rules { return e.evm.chainRules } -func (e *environment) ReadOnlyState() libevm.StateReader { return e.evm.StateDB } -func (e *environment) IncomingCallType() CallType { return e.callType } -func (e *environment) BlockNumber() *big.Int { return new(big.Int).Set(e.evm.Context.BlockNumber) } -func (e *environment) BlockTime() uint64 { return e.evm.Context.Time } +func (e *environment) ChainConfig() *params.ChainConfig { return e.evm.chainConfig } +func (e *environment) Rules() params.Rules { return e.evm.chainRules } +func (e *environment) IncomingCallType() CallType { return e.callType } +func (e *environment) BlockNumber() *big.Int { return new(big.Int).Set(e.evm.Context.BlockNumber) } +func (e *environment) BlockTime() uint64 { return e.evm.Context.Time } func (e *environment) refundGas(add uint64) error { gas, overflow := math.SafeAdd(e.self.Gas, add) @@ -58,6 +58,9 @@ func (e *environment) refundGas(add uint64) error { return nil } +func (e *environment) SetReadOnly() { e.view = true } +func (e *environment) SetPure() { e.pure = true } + func (e *environment) ReadOnly() bool { // A switch statement provides clearer code coverage for difficult-to-test // cases. @@ -69,17 +72,18 @@ func (e *environment) ReadOnly() bool { return true case e.evm.interpreter.readOnly: return true + case e.view || e.pure: + return true default: return false } } -func (e *environment) Addresses() *libevm.AddressContext { - return &libevm.AddressContext{ - Origin: e.evm.Origin, - Caller: e.self.CallerAddress, - Self: e.self.Address(), +func (e *environment) ReadOnlyState() libevm.StateReader { + if e.pure { + return nil } + return e.evm.StateDB } func (e *environment) StateDB() StateDB { @@ -89,6 +93,14 @@ func (e *environment) StateDB() StateDB { return e.evm.StateDB } +func (e *environment) Addresses() *libevm.AddressContext { + return &libevm.AddressContext{ + Origin: e.evm.Origin, + Caller: e.self.CallerAddress, + Self: e.self.Address(), + } +} + func (e *environment) BlockHeader() (types.Header, error) { hdr := e.evm.Context.Header if hdr == nil { diff --git a/libevm/precompilegen/Test.sol b/libevm/precompilegen/Test.sol index 3b7ae27bde4b..e6490dc37748 100644 --- a/libevm/precompilegen/Test.sol +++ b/libevm/precompilegen/Test.sol @@ -18,6 +18,12 @@ interface IPrecompile { function Self() external view returns (address); function RevertWith(bytes memory) external; + + function View() external view returns (bool canReadState, bool canWriteState); + + function Pure() external pure returns (bool canReadState, bool canWriteState); + + function NeitherViewNorPure() external returns (bool canReadState, bool canWriteState); } /// @dev Testing contract to exercise the implementaiton of `IPrecompile`. @@ -75,4 +81,30 @@ contract PrecompileTest { emit Called("EchoingFallback(...)"); } + + function assertReadOnly(bytes4 selector, bool expectCanReadState, bool expectCanWriteState) internal { + // We use a low-level call() here to ensure that the Solidity compiler + // doesn't issue a staticcall() to view/pure functions as this would + // hide our forcing of a read-only state. + (bool ok, bytes memory ret) = address(precompile).call(abi.encodeWithSelector(selector)); + assert(ok); + (bool canReadState, bool canWriteState) = abi.decode(ret, (bool, bool)); + assert(canReadState == expectCanReadState); + assert(canWriteState == expectCanWriteState); + } + + function View() external { + assertReadOnly(IPrecompile.View.selector, true, false); + emit Called("View()"); + } + + function Pure() external { + assertReadOnly(IPrecompile.Pure.selector, false, false); + emit Called("Pure()"); + } + + function NeitherViewNorPure() external { + assertReadOnly(IPrecompile.NeitherViewNorPure.selector, true, true); + emit Called("NeitherViewNorPure()"); + } } diff --git a/libevm/precompilegen/abigen.gen_test.go b/libevm/precompilegen/abigen.gen_test.go index 226a67d4dd76..4f44c1021092 100644 --- a/libevm/precompilegen/abigen.gen_test.go +++ b/libevm/precompilegen/abigen.gen_test.go @@ -36,8 +36,8 @@ type IPrecompileWrapper struct { // PrecompileTestMetaData contains all meta data concerning the PrecompileTest contract. var PrecompileTestMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561000f575f5ffd5b506040516116d43803806116d4833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b60805161158661014e5f395f81816101340152818161021401528181610378015281816104b2015281816105a0015281816105d7015281816106ea01526107f501526115865ff3fe608060405234801561000f575f5ffd5b506004361061007b575f3560e01c8063b4a8180811610059578063b4a81808146100d3578063c62c692f146100ef578063d7cc1f37146100f9578063db84d7c0146101155761007b565b806334d6d9be1461007f578063a93cbd971461009b578063ad8108a4146100b7575b5f5ffd5b6100996004803603810190610094919061093e565b610131565b005b6100b560048036038101906100b09190610aa5565b610210565b005b6100d160048036038101906100cc9190610b5c565b610376565b005b6100ed60048036038101906100e89190610aa5565b610458565b005b6100f761059e565b005b610113600480360381019061010e9190610c36565b6106bd565b005b61012f600480360381019061012a9190610d24565b6107cc565b005b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161018b9190610d7a565b602060405180830381865afa1580156101a6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101ca9190610da7565b146101d8576101d7610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161020590610e59565b60405180910390a150565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016102629190610ed7565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516102cc9190610f31565b5f604051808303815f865af19150503d805f8114610305576040519150601f19603f3d011682016040523d82523d5f602084013e61030a565b606091505b5091509150811561031e5761031d610dd2565b5b828051906020012081805190602001201461033c5761033b610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161036990610f91565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016103cf9190610fd8565b602060405180830381865afa1580156103ea573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061040e9190611005565b815f0151146104205761041f610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161044d9061107a565b60405180910390a150565b5f5f8260405160240161046b9190610ed7565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516104f59190610f31565b5f60405180830381855afa9150503d805f811461052d576040519150601f19603f3d011682016040523d82523d5f602084013e610532565b606091505b50915091508161054557610544610dd2565b5b828051906020012081805190602001201461056357610562610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610590906110e2565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561063e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106629190611114565b73ffffffffffffffffffffffffffffffffffffffff161461068657610685610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516106b390611189565b60405180910390a1565b8282826040516020016106d29392919061122c565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161074593929190611286565b602060405180830381865afa158015610760573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061078491906112ee565b1461079257610791610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107bf90611363565b60405180910390a1505050565b806040516020016107dd91906113c5565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b815260040161084c9190611413565b5f60405180830381865afa158015610866573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061088e91906114a1565b60405160200161089e91906113c5565b60405160208183030381529060405280519060200120146108c2576108c1610dd2565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108ef90611532565b60405180910390a150565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61091d8161090b565b8114610927575f5ffd5b50565b5f8135905061093881610914565b92915050565b5f6020828403121561095357610952610903565b5b5f6109608482850161092a565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6109b782610971565b810181811067ffffffffffffffff821117156109d6576109d5610981565b5b80604052505050565b5f6109e86108fa565b90506109f482826109ae565b919050565b5f67ffffffffffffffff821115610a1357610a12610981565b5b610a1c82610971565b9050602081019050919050565b828183375f83830152505050565b5f610a49610a44846109f9565b6109df565b905082815260208101848484011115610a6557610a6461096d565b5b610a70848285610a29565b509392505050565b5f82601f830112610a8c57610a8b610969565b5b8135610a9c848260208601610a37565b91505092915050565b5f60208284031215610aba57610ab9610903565b5b5f82013567ffffffffffffffff811115610ad757610ad6610907565b5b610ae384828501610a78565b91505092915050565b5f5ffd5b5f819050919050565b610b0281610af0565b8114610b0c575f5ffd5b50565b5f81359050610b1d81610af9565b92915050565b5f60208284031215610b3857610b37610aec565b5b610b4260206109df565b90505f610b5184828501610b0f565b5f8301525092915050565b5f60208284031215610b7157610b70610903565b5b5f610b7e84828501610b23565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610bbb81610b87565b8114610bc5575f5ffd5b50565b5f81359050610bd681610bb2565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c0582610bdc565b9050919050565b610c1581610bfb565b8114610c1f575f5ffd5b50565b5f81359050610c3081610c0c565b92915050565b5f5f5f60608486031215610c4d57610c4c610903565b5b5f610c5a8682870161092a565b9350506020610c6b86828701610bc8565b9250506040610c7c86828701610c22565b9150509250925092565b5f67ffffffffffffffff821115610ca057610c9f610981565b5b610ca982610971565b9050602081019050919050565b5f610cc8610cc384610c86565b6109df565b905082815260208101848484011115610ce457610ce361096d565b5b610cef848285610a29565b509392505050565b5f82601f830112610d0b57610d0a610969565b5b8135610d1b848260208601610cb6565b91505092915050565b5f60208284031215610d3957610d38610903565b5b5f82013567ffffffffffffffff811115610d5657610d55610907565b5b610d6284828501610cf7565b91505092915050565b610d748161090b565b82525050565b5f602082019050610d8d5f830184610d6b565b92915050565b5f81519050610da181610914565b92915050565b5f60208284031215610dbc57610dbb610903565b5b5f610dc984828501610d93565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f82825260208201905092915050565b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f610e43600d83610dff565b9150610e4e82610e0f565b602082019050919050565b5f6020820190508181035f830152610e7081610e37565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610ea982610e77565b610eb38185610e81565b9350610ec3818560208601610e91565b610ecc81610971565b840191505092915050565b5f6020820190508181035f830152610eef8184610e9f565b905092915050565b5f81905092915050565b5f610f0b82610e77565b610f158185610ef7565b9350610f25818560208601610e91565b80840191505092915050565b5f610f3c8284610f01565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f610f7b600f83610dff565b9150610f8682610f47565b602082019050919050565b5f6020820190508181035f830152610fa881610f6f565b9050919050565b610fb881610af0565b82525050565b602082015f820151610fd25f850182610faf565b50505050565b5f602082019050610feb5f830184610fbe565b92915050565b5f81519050610fff81610af9565b92915050565b5f6020828403121561101a57611019610903565b5b5f61102784828501610ff1565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f611064600c83610dff565b915061106f82611030565b602082019050919050565b5f6020820190508181035f83015261109181611058565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6110cc601483610dff565b91506110d782611098565b602082019050919050565b5f6020820190508181035f8301526110f9816110c0565b9050919050565b5f8151905061110e81610c0c565b92915050565b5f6020828403121561112957611128610903565b5b5f61113684828501611100565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f611173600683610dff565b915061117e8261113f565b602082019050919050565b5f6020820190508181035f8301526111a081611167565b9050919050565b5f819050919050565b6111c16111bc8261090b565b6111a7565b82525050565b5f819050919050565b6111e16111dc82610b87565b6111c7565b82525050565b5f8160601b9050919050565b5f6111fd826111e7565b9050919050565b5f61120e826111f3565b9050919050565b61122661122182610bfb565b611204565b82525050565b5f61123782866111b0565b60208201915061124782856111d0565b6002820191506112578284611215565b601482019150819050949350505050565b61127181610b87565b82525050565b61128081610bfb565b82525050565b5f6060820190506112995f830186610d6b565b6112a66020830185611268565b6112b36040830184611277565b949350505050565b5f819050919050565b6112cd816112bb565b81146112d7575f5ffd5b50565b5f815190506112e8816112c4565b92915050565b5f6020828403121561130357611302610903565b5b5f611310848285016112da565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f61134d600f83610dff565b915061135882611319565b602082019050919050565b5f6020820190508181035f83015261137a81611341565b9050919050565b5f81519050919050565b5f81905092915050565b5f61139f82611381565b6113a9818561138b565b93506113b9818560208601610e91565b80840191505092915050565b5f6113d08284611395565b915081905092915050565b5f6113e582611381565b6113ef8185610dff565b93506113ff818560208601610e91565b61140881610971565b840191505092915050565b5f6020820190508181035f83015261142b81846113db565b905092915050565b5f61144561144084610c86565b6109df565b9050828152602081018484840111156114615761146061096d565b5b61146c848285610e91565b509392505050565b5f82601f83011261148857611487610969565b5b8151611498848260208601611433565b91505092915050565b5f602082840312156114b6576114b5610903565b5b5f82015167ffffffffffffffff8111156114d3576114d2610907565b5b6114df84828501611474565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61151c600c83610dff565b9150611527826114e8565b602082019050919050565b5f6020820190508181035f83015261154981611510565b905091905056fea2646970667358221220cf4e683be87368d3d249175e8c416ebdb3928dae67bb586945f4f9798c59c2a664736f6c634300081c0033", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561000f575f5ffd5b50604051611ae8380380611ae8833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b6080516119936101555f395f81816101bd015281816102e70152818161044b0152818161058501528181610673015281816106aa015281816107bd015281816108c80152610a1a01526119935ff3fe608060405234801561000f575f5ffd5b506004361061009c575f3560e01c8063b4a8180811610064578063b4a8180814610108578063c62c692f14610124578063d7cc1f371461012e578063db84d7c01461014a578063f5ad2fb8146101665761009c565b80631686f265146100a057806334d6d9be146100aa578063a7263000146100c6578063a93cbd97146100d0578063ad8108a4146100ec575b5f5ffd5b6100a8610170565b005b6100c460048036038101906100bf9190610ba0565b6101ba565b005b6100ce610299565b005b6100ea60048036038101906100e59190610d07565b6102e3565b005b61010660048036038101906101019190610dbe565b610449565b005b610122600480360381019061011d9190610d07565b61052b565b005b61012c610671565b005b61014860048036038101906101439190610e98565b610790565b005b610164600480360381019061015f9190610f86565b61089f565b005b61016e6109cd565b005b610183631686f26560e01b60015f610a16565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101b090611027565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016102149190611054565b602060405180830381865afa15801561022f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102539190611081565b14610261576102606110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161028e90611123565b60405180910390a150565b6102ac63a726300060e01b600180610a16565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102d99061118b565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016103359190611209565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161039f9190611263565b5f604051808303815f865af19150503d805f81146103d8576040519150601f19603f3d011682016040523d82523d5f602084013e6103dd565b606091505b509150915081156103f1576103f06110ac565b5b828051906020012081805190602001201461040f5761040e6110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161043c906112c3565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016104a2919061130a565b602060405180830381865afa1580156104bd573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104e19190611337565b815f0151146104f3576104f26110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610520906113ac565b60405180910390a150565b5f5f8260405160240161053e9190611209565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516105c89190611263565b5f60405180830381855afa9150503d805f8114610600576040519150601f19603f3d011682016040523d82523d5f602084013e610605565b606091505b509150915081610618576106176110ac565b5b8280519060200120818051906020012014610636576106356110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161066390611414565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610711573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107359190611446565b73ffffffffffffffffffffffffffffffffffffffff1614610759576107586110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610786906114bb565b60405180910390a1565b8282826040516020016107a59392919061155e565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610818939291906115b8565b602060405180830381865afa158015610833573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108579190611620565b14610865576108646110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161089290611695565b60405180910390a1505050565b806040516020016108b091906116f7565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b815260040161091f9190611745565b5f60405180830381865afa158015610939573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061096191906117d3565b60405160200161097191906116f7565b6040516020818303038152906040528051906020012014610995576109946110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516109c290611864565b60405180910390a150565b6109df63f5ad2fb860e01b5f5f610a16565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610a0c906118cc565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610ac09190611263565b5f604051808303815f865af19150503d805f8114610af9576040519150601f19603f3d011682016040523d82523d5f602084013e610afe565b606091505b509150915081610b1157610b106110ac565b5b5f5f82806020019051810190610b27919061191f565b9150915085151582151514610b3f57610b3e6110ac565b5b84151581151514610b5357610b526110ac565b5b50505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610b7f81610b6d565b8114610b89575f5ffd5b50565b5f81359050610b9a81610b76565b92915050565b5f60208284031215610bb557610bb4610b65565b5b5f610bc284828501610b8c565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610c1982610bd3565b810181811067ffffffffffffffff82111715610c3857610c37610be3565b5b80604052505050565b5f610c4a610b5c565b9050610c568282610c10565b919050565b5f67ffffffffffffffff821115610c7557610c74610be3565b5b610c7e82610bd3565b9050602081019050919050565b828183375f83830152505050565b5f610cab610ca684610c5b565b610c41565b905082815260208101848484011115610cc757610cc6610bcf565b5b610cd2848285610c8b565b509392505050565b5f82601f830112610cee57610ced610bcb565b5b8135610cfe848260208601610c99565b91505092915050565b5f60208284031215610d1c57610d1b610b65565b5b5f82013567ffffffffffffffff811115610d3957610d38610b69565b5b610d4584828501610cda565b91505092915050565b5f5ffd5b5f819050919050565b610d6481610d52565b8114610d6e575f5ffd5b50565b5f81359050610d7f81610d5b565b92915050565b5f60208284031215610d9a57610d99610d4e565b5b610da46020610c41565b90505f610db384828501610d71565b5f8301525092915050565b5f60208284031215610dd357610dd2610b65565b5b5f610de084828501610d85565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610e1d81610de9565b8114610e27575f5ffd5b50565b5f81359050610e3881610e14565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610e6782610e3e565b9050919050565b610e7781610e5d565b8114610e81575f5ffd5b50565b5f81359050610e9281610e6e565b92915050565b5f5f5f60608486031215610eaf57610eae610b65565b5b5f610ebc86828701610b8c565b9350506020610ecd86828701610e2a565b9250506040610ede86828701610e84565b9150509250925092565b5f67ffffffffffffffff821115610f0257610f01610be3565b5b610f0b82610bd3565b9050602081019050919050565b5f610f2a610f2584610ee8565b610c41565b905082815260208101848484011115610f4657610f45610bcf565b5b610f51848285610c8b565b509392505050565b5f82601f830112610f6d57610f6c610bcb565b5b8135610f7d848260208601610f18565b91505092915050565b5f60208284031215610f9b57610f9a610b65565b5b5f82013567ffffffffffffffff811115610fb857610fb7610b69565b5b610fc484828501610f59565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f611011600683610fcd565b915061101c82610fdd565b602082019050919050565b5f6020820190508181035f83015261103e81611005565b9050919050565b61104e81610b6d565b82525050565b5f6020820190506110675f830184611045565b92915050565b5f8151905061107b81610b76565b92915050565b5f6020828403121561109657611095610b65565b5b5f6110a38482850161106d565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f61110d600d83610fcd565b9150611118826110d9565b602082019050919050565b5f6020820190508181035f83015261113a81611101565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f611175601483610fcd565b915061118082611141565b602082019050919050565b5f6020820190508181035f8301526111a281611169565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f6111db826111a9565b6111e581856111b3565b93506111f58185602086016111c3565b6111fe81610bd3565b840191505092915050565b5f6020820190508181035f83015261122181846111d1565b905092915050565b5f81905092915050565b5f61123d826111a9565b6112478185611229565b93506112578185602086016111c3565b80840191505092915050565b5f61126e8284611233565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f6112ad600f83610fcd565b91506112b882611279565b602082019050919050565b5f6020820190508181035f8301526112da816112a1565b9050919050565b6112ea81610d52565b82525050565b602082015f8201516113045f8501826112e1565b50505050565b5f60208201905061131d5f8301846112f0565b92915050565b5f8151905061133181610d5b565b92915050565b5f6020828403121561134c5761134b610b65565b5b5f61135984828501611323565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f611396600c83610fcd565b91506113a182611362565b602082019050919050565b5f6020820190508181035f8301526113c38161138a565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6113fe601483610fcd565b9150611409826113ca565b602082019050919050565b5f6020820190508181035f83015261142b816113f2565b9050919050565b5f8151905061144081610e6e565b92915050565b5f6020828403121561145b5761145a610b65565b5b5f61146884828501611432565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6114a5600683610fcd565b91506114b082611471565b602082019050919050565b5f6020820190508181035f8301526114d281611499565b9050919050565b5f819050919050565b6114f36114ee82610b6d565b6114d9565b82525050565b5f819050919050565b61151361150e82610de9565b6114f9565b82525050565b5f8160601b9050919050565b5f61152f82611519565b9050919050565b5f61154082611525565b9050919050565b61155861155382610e5d565b611536565b82525050565b5f61156982866114e2565b6020820191506115798285611502565b6002820191506115898284611547565b601482019150819050949350505050565b6115a381610de9565b82525050565b6115b281610e5d565b82525050565b5f6060820190506115cb5f830186611045565b6115d8602083018561159a565b6115e560408301846115a9565b949350505050565b5f819050919050565b6115ff816115ed565b8114611609575f5ffd5b50565b5f8151905061161a816115f6565b92915050565b5f6020828403121561163557611634610b65565b5b5f6116428482850161160c565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f61167f600f83610fcd565b915061168a8261164b565b602082019050919050565b5f6020820190508181035f8301526116ac81611673565b9050919050565b5f81519050919050565b5f81905092915050565b5f6116d1826116b3565b6116db81856116bd565b93506116eb8185602086016111c3565b80840191505092915050565b5f61170282846116c7565b915081905092915050565b5f611717826116b3565b6117218185610fcd565b93506117318185602086016111c3565b61173a81610bd3565b840191505092915050565b5f6020820190508181035f83015261175d818461170d565b905092915050565b5f61177761177284610ee8565b610c41565b90508281526020810184848401111561179357611792610bcf565b5b61179e8482856111c3565b509392505050565b5f82601f8301126117ba576117b9610bcb565b5b81516117ca848260208601611765565b91505092915050565b5f602082840312156117e8576117e7610b65565b5b5f82015167ffffffffffffffff81111561180557611804610b69565b5b611811848285016117a6565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61184e600c83610fcd565b91506118598261181a565b602082019050919050565b5f6020820190508181035f83015261187b81611842565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f6118b6600683610fcd565b91506118c182611882565b602082019050919050565b5f6020820190508181035f8301526118e3816118aa565b9050919050565b5f8115159050919050565b6118fe816118ea565b8114611908575f5ffd5b50565b5f81519050611919816118f5565b92915050565b5f5f6040838503121561193557611934610b65565b5b5f6119428582860161190b565b92505060206119538582860161190b565b915050925092905056fea26469706673582212206fbd1578963795306db34fa421e0e514e3e99979c9760a9b6f393505a99b5b3864736f6c634300081c0033", } // PrecompileTestABI is the input ABI used to generate the binding from. @@ -312,6 +312,48 @@ func (_PrecompileTest *PrecompileTestTransactorSession) HashPacked(x *big.Int, y return _PrecompileTest.Contract.HashPacked(&_PrecompileTest.TransactOpts, x, y, z) } +// NeitherViewNorPure is a paid mutator transaction binding the contract method 0xa7263000. +// +// Solidity: function NeitherViewNorPure() returns() +func (_PrecompileTest *PrecompileTestTransactor) NeitherViewNorPure(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "NeitherViewNorPure") +} + +// NeitherViewNorPure is a paid mutator transaction binding the contract method 0xa7263000. +// +// Solidity: function NeitherViewNorPure() returns() +func (_PrecompileTest *PrecompileTestSession) NeitherViewNorPure() (*types.Transaction, error) { + return _PrecompileTest.Contract.NeitherViewNorPure(&_PrecompileTest.TransactOpts) +} + +// NeitherViewNorPure is a paid mutator transaction binding the contract method 0xa7263000. +// +// Solidity: function NeitherViewNorPure() returns() +func (_PrecompileTest *PrecompileTestTransactorSession) NeitherViewNorPure() (*types.Transaction, error) { + return _PrecompileTest.Contract.NeitherViewNorPure(&_PrecompileTest.TransactOpts) +} + +// Pure is a paid mutator transaction binding the contract method 0xf5ad2fb8. +// +// Solidity: function Pure() returns() +func (_PrecompileTest *PrecompileTestTransactor) Pure(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "Pure") +} + +// Pure is a paid mutator transaction binding the contract method 0xf5ad2fb8. +// +// Solidity: function Pure() returns() +func (_PrecompileTest *PrecompileTestSession) Pure() (*types.Transaction, error) { + return _PrecompileTest.Contract.Pure(&_PrecompileTest.TransactOpts) +} + +// Pure is a paid mutator transaction binding the contract method 0xf5ad2fb8. +// +// Solidity: function Pure() returns() +func (_PrecompileTest *PrecompileTestTransactorSession) Pure() (*types.Transaction, error) { + return _PrecompileTest.Contract.Pure(&_PrecompileTest.TransactOpts) +} + // RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. // // Solidity: function RevertWith(bytes err) returns() @@ -354,6 +396,27 @@ func (_PrecompileTest *PrecompileTestTransactorSession) Self() (*types.Transacti return _PrecompileTest.Contract.Self(&_PrecompileTest.TransactOpts) } +// View is a paid mutator transaction binding the contract method 0x1686f265. +// +// Solidity: function View() returns() +func (_PrecompileTest *PrecompileTestTransactor) View(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "View") +} + +// View is a paid mutator transaction binding the contract method 0x1686f265. +// +// Solidity: function View() returns() +func (_PrecompileTest *PrecompileTestSession) View() (*types.Transaction, error) { + return _PrecompileTest.Contract.View(&_PrecompileTest.TransactOpts) +} + +// View is a paid mutator transaction binding the contract method 0x1686f265. +// +// Solidity: function View() returns() +func (_PrecompileTest *PrecompileTestTransactorSession) View() (*types.Transaction, error) { + return _PrecompileTest.Contract.View(&_PrecompileTest.TransactOpts) +} + // PrecompileTestCalledIterator is returned from FilterCalled and is used to iterate over the raw logs and unpacked data for Called events raised by the PrecompileTest contract. type PrecompileTestCalledIterator struct { Event *PrecompileTestCalled // Event containing the contract specifics and raw log diff --git a/libevm/precompilegen/main_test.go b/libevm/precompilegen/main_test.go index 33c39c01fda1..0b2ef5155602 100644 --- a/libevm/precompilegen/main_test.go +++ b/libevm/precompilegen/main_test.go @@ -148,6 +148,24 @@ func TestGeneratedPrecompile(t *testing.T) { }, wantCalledEvent: "EchoingFallback(...)", }, + { + transact: func() (*types.Transaction, error) { + return suite.View() + }, + wantCalledEvent: "View()", + }, + { + transact: func() (*types.Transaction, error) { + return suite.Pure() + }, + wantCalledEvent: "Pure()", + }, + { + transact: func() (*types.Transaction, error) { + return suite.NeitherViewNorPure() + }, + wantCalledEvent: "NeitherViewNorPure()", + }, } for _, tt := range tests { @@ -157,7 +175,7 @@ func TestGeneratedPrecompile(t *testing.T) { sim.Commit() rcpt := successfulTxReceipt(ctx, t, client, tx) - require.Equalf(t, uint64(1), rcpt.Status, "%T.Status (i.e. transaction included)", rcpt) + require.Equalf(t, uint64(1), rcpt.Status, "%T.Status (i.e. transaction executed without error)", rcpt) require.Lenf(t, rcpt.Logs, 1, "%T.Logs", rcpt) called, err := test.ParseCalled(*rcpt.Logs[0]) @@ -210,3 +228,23 @@ func (contract) RevertWith(env vm.PrecompileEnvironment, x []byte) error { func (contract) Self(env vm.PrecompileEnvironment) (common.Address, error) { return env.Addresses().Self, nil } + +func canReadState(env vm.PrecompileEnvironment) bool { + return env.ReadOnlyState() != nil +} + +func canWriteState(env vm.PrecompileEnvironment) bool { + return env.StateDB() != nil +} + +func (contract) View(env vm.PrecompileEnvironment) (bool, bool, error) { + return canReadState(env), canWriteState(env), nil +} + +func (contract) Pure(env vm.PrecompileEnvironment) (bool, bool, error) { + return canReadState(env), canWriteState(env), nil +} + +func (contract) NeitherViewNorPure(env vm.PrecompileEnvironment) (bool, bool, error) { + return canReadState(env), canWriteState(env), nil +} diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index 67278ed366c4..309ddb7ad34d 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -5,6 +5,7 @@ package {{.Package}} // Code generated by precompilegen. DO NOT EDIT. import ( + "fmt" "math/big" "strings" @@ -67,6 +68,22 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err if !ok { return p.impl.Fallback(env, input) } + + switch m := methods[selector]; m.StateMutability { + case "nonpayable": + if !env.Value().IsZero() { + return nil, vm.RevertError("non-payable") + } + case "payable": + case "pure": + env.SetPure() + case "view": + env.SetReadOnly() + default: + // If this happens then `precompilegen` needs to be extended. + return nil, vm.RevertError(fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig)) + } + ret, err := dispatchers[selector](p.impl, env, input) switch err := err.(type) { case nil: diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index 695e90bffae5..95f65a2b3a98 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -1,10 +1,11 @@ // Package testprecompile is a generated package for creating EVM precompiles -// conforming to the EIP-165 interface ID 0xfa0fcd55. +// conforming to the EIP-165 interface ID 0xbe022088. package testprecompile // Code generated by precompilegen. DO NOT EDIT. import ( + "fmt" "math/big" "strings" @@ -14,7 +15,7 @@ import ( ) // A Contract is an implementation of a precompiled contract conforming to the -// EIP-165 interface ID 0xfa0fcd55. +// EIP-165 interface ID 0xbe022088. type Contract interface { // Fallback implements a fallback function, called if the method selector // fails to match any other method. @@ -38,6 +39,14 @@ type Contract interface { // function HashPacked(uint256 , bytes2 , address ) view returns(bytes32) HashPacked(vm.PrecompileEnvironment, *big.Int, [2]uint8, common.Address) ([32]uint8, error) + // NeitherViewNorPure implements the function with selector 0xa7263000: + // function NeitherViewNorPure() returns(bool canReadState, bool canWriteState) + NeitherViewNorPure(vm.PrecompileEnvironment) (bool, bool, error) + + // Pure implements the function with selector 0xf5ad2fb8: + // function Pure() pure returns(bool canReadState, bool canWriteState) + Pure(vm.PrecompileEnvironment) (bool, bool, error) + // RevertWith implements the function with selector 0xa93cbd97: // function RevertWith(bytes ) returns() RevertWith(vm.PrecompileEnvironment, []uint8) error @@ -45,6 +54,10 @@ type Contract interface { // Self implements the function with selector 0xc62c692f: // function Self() view returns(address) Self(vm.PrecompileEnvironment) (common.Address, error) + + // View implements the function with selector 0x1686f265: + // function View() view returns(bool canReadState, bool canWriteState) + View(vm.PrecompileEnvironment) (bool, bool, error) } type methodDispatcher = func(Contract, vm.PrecompileEnvironment, []byte) ([]byte, error) @@ -58,7 +71,7 @@ var ( dispatchers map[abi.Selector]methodDispatcher ) -const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]` +const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NeitherViewNorPure","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Pure","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"View","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"view","type":"function"}]` func init() { parsed, err := abi.JSON(strings.NewReader(abiJSON)) @@ -73,8 +86,11 @@ func init() { 0xdb84d7c0: d.Echo0, 0xad8108a4: d.Extract, 0xd7cc1f37: d.HashPacked, + 0xa7263000: d.NeitherViewNorPure, + 0xf5ad2fb8: d.Pure, 0xa93cbd97: d.RevertWith, 0xc62c692f: d.Self, + 0x1686f265: d.View, } } @@ -92,6 +108,22 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err if !ok { return p.impl.Fallback(env, input) } + + switch m := methods[selector]; m.StateMutability { + case "nonpayable": + if !env.Value().IsZero() { + return nil, vm.RevertError("non-payable") + } + case "payable": + case "pure": + env.SetPure() + case "view": + env.SetReadOnly() + default: + // If this happens then `precompilegen` needs to be extended. + return nil, vm.RevertError(fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig)) + } + ret, err := dispatchers[selector](p.impl, env, input) switch err := err.(type) { case nil: @@ -188,6 +220,32 @@ func (dispatch) HashPacked(impl Contract, env vm.PrecompileEnvironment, input [] } } +func (dispatch) NeitherViewNorPure(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xa7263000] + + { + o0, o1, err := impl.NeitherViewNorPure(env) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0, o1) + } +} + +func (dispatch) Pure(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0xf5ad2fb8] + + { + o0, o1, err := impl.Pure(env) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0, o1) + } +} + func (dispatch) RevertWith(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0xa93cbd97] @@ -219,3 +277,16 @@ func (dispatch) Self(impl Contract, env vm.PrecompileEnvironment, input []byte) return method.Outputs.Pack(o0) } } + +func (dispatch) View(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0x1686f265] + + { + o0, o1, err := impl.View(env) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0, o1) + } +} From 2200b8e3329df6c571ef5701f073357c9bf51751 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 20 Dec 2024 10:47:21 +0000 Subject: [PATCH 14/22] test: payable vs non-payable --- libevm/precompilegen/Test.sol | 17 +++++++- libevm/precompilegen/abigen.gen_test.go | 25 ++++++++++- libevm/precompilegen/main_test.go | 17 ++++++++ libevm/precompilegen/precompile.go.tmpl | 8 ++-- .../precompilegen/testprecompile/generated.go | 41 +++++++++++++++++-- 5 files changed, 98 insertions(+), 10 deletions(-) diff --git a/libevm/precompilegen/Test.sol b/libevm/precompilegen/Test.sol index e6490dc37748..5f9a33ca6c91 100644 --- a/libevm/precompilegen/Test.sol +++ b/libevm/precompilegen/Test.sol @@ -24,13 +24,17 @@ interface IPrecompile { function Pure() external pure returns (bool canReadState, bool canWriteState); function NeitherViewNorPure() external returns (bool canReadState, bool canWriteState); + + function Payable() external payable returns (uint256 value); + + function NonPayable() external; } /// @dev Testing contract to exercise the implementaiton of `IPrecompile`. contract PrecompileTest { IPrecompile immutable precompile; - constructor(IPrecompile _precompile) { + constructor(IPrecompile _precompile) payable { precompile = _precompile; } @@ -107,4 +111,15 @@ contract PrecompileTest { assertReadOnly(IPrecompile.NeitherViewNorPure.selector, true, true); emit Called("NeitherViewNorPure()"); } + + function Transfer() external { + uint256 value = precompile.Payable{value: 42}(); + assert(value == 42); + + (bool ok,) = address(precompile).call{value: 42}(abi.encodeWithSelector(IPrecompile.NonPayable.selector)); + assert(!ok); + // TODO: DO NOT MERGE without checking the return data + + emit Called("Transfer()"); + } } diff --git a/libevm/precompilegen/abigen.gen_test.go b/libevm/precompilegen/abigen.gen_test.go index 4f44c1021092..8dbaa18c3ad6 100644 --- a/libevm/precompilegen/abigen.gen_test.go +++ b/libevm/precompilegen/abigen.gen_test.go @@ -36,8 +36,8 @@ type IPrecompileWrapper struct { // PrecompileTestMetaData contains all meta data concerning the PrecompileTest contract. var PrecompileTestMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561000f575f5ffd5b50604051611ae8380380611ae8833981810160405281019061003191906100da565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff168152505050610105565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100988261006f565b9050919050565b5f6100a98261008e565b9050919050565b6100b98161009f565b81146100c3575f5ffd5b50565b5f815190506100d4816100b0565b92915050565b5f602082840312156100ef576100ee61006b565b5b5f6100fc848285016100c6565b91505092915050565b6080516119936101555f395f81816101bd015281816102e70152818161044b0152818161058501528181610673015281816106aa015281816107bd015281816108c80152610a1a01526119935ff3fe608060405234801561000f575f5ffd5b506004361061009c575f3560e01c8063b4a8180811610064578063b4a8180814610108578063c62c692f14610124578063d7cc1f371461012e578063db84d7c01461014a578063f5ad2fb8146101665761009c565b80631686f265146100a057806334d6d9be146100aa578063a7263000146100c6578063a93cbd97146100d0578063ad8108a4146100ec575b5f5ffd5b6100a8610170565b005b6100c460048036038101906100bf9190610ba0565b6101ba565b005b6100ce610299565b005b6100ea60048036038101906100e59190610d07565b6102e3565b005b61010660048036038101906101019190610dbe565b610449565b005b610122600480360381019061011d9190610d07565b61052b565b005b61012c610671565b005b61014860048036038101906101439190610e98565b610790565b005b610164600480360381019061015f9190610f86565b61089f565b005b61016e6109cd565b005b610183631686f26560e01b60015f610a16565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101b090611027565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016102149190611054565b602060405180830381865afa15801561022f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102539190611081565b14610261576102606110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161028e90611123565b60405180910390a150565b6102ac63a726300060e01b600180610a16565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102d99061118b565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016103359190611209565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161039f9190611263565b5f604051808303815f865af19150503d805f81146103d8576040519150601f19603f3d011682016040523d82523d5f602084013e6103dd565b606091505b509150915081156103f1576103f06110ac565b5b828051906020012081805190602001201461040f5761040e6110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161043c906112c3565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016104a2919061130a565b602060405180830381865afa1580156104bd573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104e19190611337565b815f0151146104f3576104f26110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610520906113ac565b60405180910390a150565b5f5f8260405160240161053e9190611209565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516105c89190611263565b5f60405180830381855afa9150503d805f8114610600576040519150601f19603f3d011682016040523d82523d5f602084013e610605565b606091505b509150915081610618576106176110ac565b5b8280519060200120818051906020012014610636576106356110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161066390611414565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610711573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107359190611446565b73ffffffffffffffffffffffffffffffffffffffff1614610759576107586110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610786906114bb565b60405180910390a1565b8282826040516020016107a59392919061155e565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610818939291906115b8565b602060405180830381865afa158015610833573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108579190611620565b14610865576108646110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161089290611695565b60405180910390a1505050565b806040516020016108b091906116f7565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b815260040161091f9190611745565b5f60405180830381865afa158015610939573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061096191906117d3565b60405160200161097191906116f7565b6040516020818303038152906040528051906020012014610995576109946110ac565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516109c290611864565b60405180910390a150565b6109df63f5ad2fb860e01b5f5f610a16565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610a0c906118cc565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610ac09190611263565b5f604051808303815f865af19150503d805f8114610af9576040519150601f19603f3d011682016040523d82523d5f602084013e610afe565b606091505b509150915081610b1157610b106110ac565b5b5f5f82806020019051810190610b27919061191f565b9150915085151582151514610b3f57610b3e6110ac565b5b84151581151514610b5357610b526110ac565b5b50505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610b7f81610b6d565b8114610b89575f5ffd5b50565b5f81359050610b9a81610b76565b92915050565b5f60208284031215610bb557610bb4610b65565b5b5f610bc284828501610b8c565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610c1982610bd3565b810181811067ffffffffffffffff82111715610c3857610c37610be3565b5b80604052505050565b5f610c4a610b5c565b9050610c568282610c10565b919050565b5f67ffffffffffffffff821115610c7557610c74610be3565b5b610c7e82610bd3565b9050602081019050919050565b828183375f83830152505050565b5f610cab610ca684610c5b565b610c41565b905082815260208101848484011115610cc757610cc6610bcf565b5b610cd2848285610c8b565b509392505050565b5f82601f830112610cee57610ced610bcb565b5b8135610cfe848260208601610c99565b91505092915050565b5f60208284031215610d1c57610d1b610b65565b5b5f82013567ffffffffffffffff811115610d3957610d38610b69565b5b610d4584828501610cda565b91505092915050565b5f5ffd5b5f819050919050565b610d6481610d52565b8114610d6e575f5ffd5b50565b5f81359050610d7f81610d5b565b92915050565b5f60208284031215610d9a57610d99610d4e565b5b610da46020610c41565b90505f610db384828501610d71565b5f8301525092915050565b5f60208284031215610dd357610dd2610b65565b5b5f610de084828501610d85565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b610e1d81610de9565b8114610e27575f5ffd5b50565b5f81359050610e3881610e14565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610e6782610e3e565b9050919050565b610e7781610e5d565b8114610e81575f5ffd5b50565b5f81359050610e9281610e6e565b92915050565b5f5f5f60608486031215610eaf57610eae610b65565b5b5f610ebc86828701610b8c565b9350506020610ecd86828701610e2a565b9250506040610ede86828701610e84565b9150509250925092565b5f67ffffffffffffffff821115610f0257610f01610be3565b5b610f0b82610bd3565b9050602081019050919050565b5f610f2a610f2584610ee8565b610c41565b905082815260208101848484011115610f4657610f45610bcf565b5b610f51848285610c8b565b509392505050565b5f82601f830112610f6d57610f6c610bcb565b5b8135610f7d848260208601610f18565b91505092915050565b5f60208284031215610f9b57610f9a610b65565b5b5f82013567ffffffffffffffff811115610fb857610fb7610b69565b5b610fc484828501610f59565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f611011600683610fcd565b915061101c82610fdd565b602082019050919050565b5f6020820190508181035f83015261103e81611005565b9050919050565b61104e81610b6d565b82525050565b5f6020820190506110675f830184611045565b92915050565b5f8151905061107b81610b76565b92915050565b5f6020828403121561109657611095610b65565b5b5f6110a38482850161106d565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f61110d600d83610fcd565b9150611118826110d9565b602082019050919050565b5f6020820190508181035f83015261113a81611101565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f611175601483610fcd565b915061118082611141565b602082019050919050565b5f6020820190508181035f8301526111a281611169565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f6111db826111a9565b6111e581856111b3565b93506111f58185602086016111c3565b6111fe81610bd3565b840191505092915050565b5f6020820190508181035f83015261122181846111d1565b905092915050565b5f81905092915050565b5f61123d826111a9565b6112478185611229565b93506112578185602086016111c3565b80840191505092915050565b5f61126e8284611233565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f6112ad600f83610fcd565b91506112b882611279565b602082019050919050565b5f6020820190508181035f8301526112da816112a1565b9050919050565b6112ea81610d52565b82525050565b602082015f8201516113045f8501826112e1565b50505050565b5f60208201905061131d5f8301846112f0565b92915050565b5f8151905061133181610d5b565b92915050565b5f6020828403121561134c5761134b610b65565b5b5f61135984828501611323565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f611396600c83610fcd565b91506113a182611362565b602082019050919050565b5f6020820190508181035f8301526113c38161138a565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6113fe601483610fcd565b9150611409826113ca565b602082019050919050565b5f6020820190508181035f83015261142b816113f2565b9050919050565b5f8151905061144081610e6e565b92915050565b5f6020828403121561145b5761145a610b65565b5b5f61146884828501611432565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6114a5600683610fcd565b91506114b082611471565b602082019050919050565b5f6020820190508181035f8301526114d281611499565b9050919050565b5f819050919050565b6114f36114ee82610b6d565b6114d9565b82525050565b5f819050919050565b61151361150e82610de9565b6114f9565b82525050565b5f8160601b9050919050565b5f61152f82611519565b9050919050565b5f61154082611525565b9050919050565b61155861155382610e5d565b611536565b82525050565b5f61156982866114e2565b6020820191506115798285611502565b6002820191506115898284611547565b601482019150819050949350505050565b6115a381610de9565b82525050565b6115b281610e5d565b82525050565b5f6060820190506115cb5f830186611045565b6115d8602083018561159a565b6115e560408301846115a9565b949350505050565b5f819050919050565b6115ff816115ed565b8114611609575f5ffd5b50565b5f8151905061161a816115f6565b92915050565b5f6020828403121561163557611634610b65565b5b5f6116428482850161160c565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f61167f600f83610fcd565b915061168a8261164b565b602082019050919050565b5f6020820190508181035f8301526116ac81611673565b9050919050565b5f81519050919050565b5f81905092915050565b5f6116d1826116b3565b6116db81856116bd565b93506116eb8185602086016111c3565b80840191505092915050565b5f61170282846116c7565b915081905092915050565b5f611717826116b3565b6117218185610fcd565b93506117318185602086016111c3565b61173a81610bd3565b840191505092915050565b5f6020820190508181035f83015261175d818461170d565b905092915050565b5f61177761177284610ee8565b610c41565b90508281526020810184848401111561179357611792610bcf565b5b61179e8482856111c3565b509392505050565b5f82601f8301126117ba576117b9610bcb565b5b81516117ca848260208601611765565b91505092915050565b5f602082840312156117e8576117e7610b65565b5b5f82015167ffffffffffffffff81111561180557611804610b69565b5b611811848285016117a6565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f61184e600c83610fcd565b91506118598261181a565b602082019050919050565b5f6020820190508181035f83015261187b81611842565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f6118b6600683610fcd565b91506118c182611882565b602082019050919050565b5f6020820190508181035f8301526118e3816118aa565b9050919050565b5f8115159050919050565b6118fe816118ea565b8114611908575f5ffd5b50565b5f81519050611919816118f5565b92915050565b5f5f6040838503121561193557611934610b65565b5b5f6119428582860161190b565b92505060206119538582860161190b565b915050925092905056fea26469706673582212206fbd1578963795306db34fa421e0e514e3e99979c9760a9b6f393505a99b5b3864736f6c634300081c0033", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Transfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a0604052604051611d49380380611d49833981810160405281019061002591906100ce565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100f9565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61008c82610063565b9050919050565b5f61009d82610082565b9050919050565b6100ad81610093565b81146100b7575f5ffd5b50565b5f815190506100c8816100a4565b92915050565b5f602082840312156100e3576100e261005f565b5b5f6100f0848285016100ba565b91505092915050565b608051611bf26101575f395f81816101d2015281816102b101528181610356015281816104de015281816106420152818161077c0152818161086a015281816108a1015281816109b401528181610abf0152610c110152611bf25ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610d97565b6101cf565b005b6100d96102ae565b005b6100e3610490565b005b6100ff60048036038101906100fa9190610efe565b6104da565b005b61011b60048036038101906101169190610fb5565b610640565b005b61013760048036038101906101329190610efe565b610722565b005b610141610868565b005b61015d6004803603810190610158919061108f565b610987565b005b6101796004803603810190610174919061117d565b610a96565b005b610183610bc4565b005b610198631686f26560e01b60015f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c59061121e565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b8152600401610229919061124b565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102689190611278565b14610276576102756112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a39061131a565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103409190611278565b9050602a8114610353576103526112a3565b5b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16602a636fb1b0e960e01b604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610405919061138a565b5f6040518083038185875af1925050503d805f811461043f576040519150601f19603f3d011682016040523d82523d5f602084013e610444565b606091505b505090508015610457576104566112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610484906113ea565b60405180910390a15050565b6104a363a726300060e01b600180610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516104d090611452565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161052c91906114b8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610596919061138a565b5f604051808303815f865af19150503d805f81146105cf576040519150601f19603f3d011682016040523d82523d5f602084013e6105d4565b606091505b509150915081156105e8576105e76112a3565b5b8280519060200120818051906020012014610606576106056112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161063390611522565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016106999190611569565b602060405180830381865afa1580156106b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d89190611596565b815f0151146106ea576106e96112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107179061160b565b60405180910390a150565b5f5f8260405160240161073591906114b8565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516107bf919061138a565b5f60405180830381855afa9150503d805f81146107f7576040519150601f19603f3d011682016040523d82523d5f602084013e6107fc565b606091505b50915091508161080f5761080e6112a3565b5b828051906020012081805190602001201461082d5761082c6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161085a90611673565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610908573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061092c91906116a5565b73ffffffffffffffffffffffffffffffffffffffff16146109505761094f6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161097d9061171a565b60405180910390a1565b82828260405160200161099c939291906117bd565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610a0f93929190611817565b602060405180830381865afa158015610a2a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4e919061187f565b14610a5c57610a5b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610a89906118f4565b60405180910390a1505050565b80604051602001610aa79190611956565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610b1691906119a4565b5f60405180830381865afa158015610b30573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610b589190611a32565b604051602001610b689190611956565b6040516020818303038152906040528051906020012014610b8c57610b8b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610bb990611ac3565b60405180910390a150565b610bd663f5ad2fb860e01b5f5f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610c0390611b2b565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610cb7919061138a565b5f604051808303815f865af19150503d805f8114610cf0576040519150601f19603f3d011682016040523d82523d5f602084013e610cf5565b606091505b509150915081610d0857610d076112a3565b5b5f5f82806020019051810190610d1e9190611b7e565b9150915085151582151514610d3657610d356112a3565b5b84151581151514610d4a57610d496112a3565b5b50505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610d7681610d64565b8114610d80575f5ffd5b50565b5f81359050610d9181610d6d565b92915050565b5f60208284031215610dac57610dab610d5c565b5b5f610db984828501610d83565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610e1082610dca565b810181811067ffffffffffffffff82111715610e2f57610e2e610dda565b5b80604052505050565b5f610e41610d53565b9050610e4d8282610e07565b919050565b5f67ffffffffffffffff821115610e6c57610e6b610dda565b5b610e7582610dca565b9050602081019050919050565b828183375f83830152505050565b5f610ea2610e9d84610e52565b610e38565b905082815260208101848484011115610ebe57610ebd610dc6565b5b610ec9848285610e82565b509392505050565b5f82601f830112610ee557610ee4610dc2565b5b8135610ef5848260208601610e90565b91505092915050565b5f60208284031215610f1357610f12610d5c565b5b5f82013567ffffffffffffffff811115610f3057610f2f610d60565b5b610f3c84828501610ed1565b91505092915050565b5f5ffd5b5f819050919050565b610f5b81610f49565b8114610f65575f5ffd5b50565b5f81359050610f7681610f52565b92915050565b5f60208284031215610f9157610f90610f45565b5b610f9b6020610e38565b90505f610faa84828501610f68565b5f8301525092915050565b5f60208284031215610fca57610fc9610d5c565b5b5f610fd784828501610f7c565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61101481610fe0565b811461101e575f5ffd5b50565b5f8135905061102f8161100b565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61105e82611035565b9050919050565b61106e81611054565b8114611078575f5ffd5b50565b5f8135905061108981611065565b92915050565b5f5f5f606084860312156110a6576110a5610d5c565b5b5f6110b386828701610d83565b93505060206110c486828701611021565b92505060406110d58682870161107b565b9150509250925092565b5f67ffffffffffffffff8211156110f9576110f8610dda565b5b61110282610dca565b9050602081019050919050565b5f61112161111c846110df565b610e38565b90508281526020810184848401111561113d5761113c610dc6565b5b611148848285610e82565b509392505050565b5f82601f83011261116457611163610dc2565b5b813561117484826020860161110f565b91505092915050565b5f6020828403121561119257611191610d5c565b5b5f82013567ffffffffffffffff8111156111af576111ae610d60565b5b6111bb84828501611150565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f6112086006836111c4565b9150611213826111d4565b602082019050919050565b5f6020820190508181035f830152611235816111fc565b9050919050565b61124581610d64565b82525050565b5f60208201905061125e5f83018461123c565b92915050565b5f8151905061127281610d6d565b92915050565b5f6020828403121561128d5761128c610d5c565b5b5f61129a84828501611264565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f611304600d836111c4565b915061130f826112d0565b602082019050919050565b5f6020820190508181035f830152611331816112f8565b9050919050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f61136482611338565b61136e8185611342565b935061137e81856020860161134c565b80840191505092915050565b5f611395828461135a565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f6113d4600a836111c4565b91506113df826113a0565b602082019050919050565b5f6020820190508181035f830152611401816113c8565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61143c6014836111c4565b915061144782611408565b602082019050919050565b5f6020820190508181035f83015261146981611430565b9050919050565b5f82825260208201905092915050565b5f61148a82611338565b6114948185611470565b93506114a481856020860161134c565b6114ad81610dca565b840191505092915050565b5f6020820190508181035f8301526114d08184611480565b905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f61150c600f836111c4565b9150611517826114d8565b602082019050919050565b5f6020820190508181035f83015261153981611500565b9050919050565b61154981610f49565b82525050565b602082015f8201516115635f850182611540565b50505050565b5f60208201905061157c5f83018461154f565b92915050565b5f8151905061159081610f52565b92915050565b5f602082840312156115ab576115aa610d5c565b5b5f6115b884828501611582565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f6115f5600c836111c4565b9150611600826115c1565b602082019050919050565b5f6020820190508181035f830152611622816115e9565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f61165d6014836111c4565b915061166882611629565b602082019050919050565b5f6020820190508181035f83015261168a81611651565b9050919050565b5f8151905061169f81611065565b92915050565b5f602082840312156116ba576116b9610d5c565b5b5f6116c784828501611691565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6117046006836111c4565b915061170f826116d0565b602082019050919050565b5f6020820190508181035f830152611731816116f8565b9050919050565b5f819050919050565b61175261174d82610d64565b611738565b82525050565b5f819050919050565b61177261176d82610fe0565b611758565b82525050565b5f8160601b9050919050565b5f61178e82611778565b9050919050565b5f61179f82611784565b9050919050565b6117b76117b282611054565b611795565b82525050565b5f6117c88286611741565b6020820191506117d88285611761565b6002820191506117e882846117a6565b601482019150819050949350505050565b61180281610fe0565b82525050565b61181181611054565b82525050565b5f60608201905061182a5f83018661123c565b61183760208301856117f9565b6118446040830184611808565b949350505050565b5f819050919050565b61185e8161184c565b8114611868575f5ffd5b50565b5f8151905061187981611855565b92915050565b5f6020828403121561189457611893610d5c565b5b5f6118a18482850161186b565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6118de600f836111c4565b91506118e9826118aa565b602082019050919050565b5f6020820190508181035f83015261190b816118d2565b9050919050565b5f81519050919050565b5f81905092915050565b5f61193082611912565b61193a818561191c565b935061194a81856020860161134c565b80840191505092915050565b5f6119618284611926565b915081905092915050565b5f61197682611912565b61198081856111c4565b935061199081856020860161134c565b61199981610dca565b840191505092915050565b5f6020820190508181035f8301526119bc818461196c565b905092915050565b5f6119d66119d1846110df565b610e38565b9050828152602081018484840111156119f2576119f1610dc6565b5b6119fd84828561134c565b509392505050565b5f82601f830112611a1957611a18610dc2565b5b8151611a298482602086016119c4565b91505092915050565b5f60208284031215611a4757611a46610d5c565b5b5f82015167ffffffffffffffff811115611a6457611a63610d60565b5b611a7084828501611a05565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611aad600c836111c4565b9150611ab882611a79565b602082019050919050565b5f6020820190508181035f830152611ada81611aa1565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611b156006836111c4565b9150611b2082611ae1565b602082019050919050565b5f6020820190508181035f830152611b4281611b09565b9050919050565b5f8115159050919050565b611b5d81611b49565b8114611b67575f5ffd5b50565b5f81519050611b7881611b54565b92915050565b5f5f60408385031215611b9457611b93610d5c565b5b5f611ba185828601611b6a565b9250506020611bb285828601611b6a565b915050925092905056fea264697066735822122015cec228d3431d1c7e411919e8c1d0eedf25bb9b34ed83e88e4dbcb442ad811764736f6c634300081c0033", } // PrecompileTestABI is the input ABI used to generate the binding from. @@ -396,6 +396,27 @@ func (_PrecompileTest *PrecompileTestTransactorSession) Self() (*types.Transacti return _PrecompileTest.Contract.Self(&_PrecompileTest.TransactOpts) } +// Transfer is a paid mutator transaction binding the contract method 0x406dade3. +// +// Solidity: function Transfer() returns() +func (_PrecompileTest *PrecompileTestTransactor) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PrecompileTest.contract.Transact(opts, "Transfer") +} + +// Transfer is a paid mutator transaction binding the contract method 0x406dade3. +// +// Solidity: function Transfer() returns() +func (_PrecompileTest *PrecompileTestSession) Transfer() (*types.Transaction, error) { + return _PrecompileTest.Contract.Transfer(&_PrecompileTest.TransactOpts) +} + +// Transfer is a paid mutator transaction binding the contract method 0x406dade3. +// +// Solidity: function Transfer() returns() +func (_PrecompileTest *PrecompileTestTransactorSession) Transfer() (*types.Transaction, error) { + return _PrecompileTest.Contract.Transfer(&_PrecompileTest.TransactOpts) +} + // View is a paid mutator transaction binding the contract method 0x1686f265. // // Solidity: function View() returns() diff --git a/libevm/precompilegen/main_test.go b/libevm/precompilegen/main_test.go index 0b2ef5155602..50388e410b4d 100644 --- a/libevm/precompilegen/main_test.go +++ b/libevm/precompilegen/main_test.go @@ -89,12 +89,15 @@ func TestGeneratedPrecompile(t *testing.T) { txOpts, err := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) require.NoError(t, err, "bind.NewKeyedTransactorWithChainID(..., 1337)") txOpts.GasLimit = 30e6 + txOpts.Value = big.NewInt(1e9) client := sim.Client() _, tx, test, err := DeployPrecompileTest(txOpts, client, precompile) require.NoError(t, err, "DeployPrecompileTest(...)") sim.Commit() successfulTxReceipt(ctx, t, client, tx) + + txOpts.Value = nil suite := &PrecompileTestSession{ Contract: test, TransactOpts: *txOpts, @@ -166,6 +169,12 @@ func TestGeneratedPrecompile(t *testing.T) { }, wantCalledEvent: "NeitherViewNorPure()", }, + { + transact: func() (*types.Transaction, error) { + return suite.Transfer() + }, + wantCalledEvent: "Transfer()", + }, } for _, tt := range tests { @@ -248,3 +257,11 @@ func (contract) Pure(env vm.PrecompileEnvironment) (bool, bool, error) { func (contract) NeitherViewNorPure(env vm.PrecompileEnvironment) (bool, bool, error) { return canReadState(env), canWriteState(env), nil } + +func (contract) Payable(env vm.PrecompileEnvironment) (*big.Int, error) { + return env.Value().ToBig(), nil +} + +func (contract) NonPayable(env vm.PrecompileEnvironment) error { + return nil +} diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index 309ddb7ad34d..c2963ba6f2b3 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -102,9 +102,11 @@ type dispatch struct{} {{range methods .ABI}} func (dispatch) {{.Name}}(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + {{if or (gt (len .Inputs) 0) (gt (len .Outputs) 0) -}} method := methods[{{hex .ID}}] + {{- end}} - {{if gt (len .Inputs) 0}} + {{if gt (len .Inputs) 0 -}} inputs, err := method.Inputs.Unpack(input[abi.SelectorByteLen:]) if err != nil { return nil, err @@ -112,7 +114,7 @@ func (dispatch) {{.Name}}(impl Contract, env vm.PrecompileEnvironment, input []b {{- range $i, $in := .Inputs}} i{{$i}} := inputs[{{$i}}].({{type $in}}) {{- end}} - {{end}} + {{- end}} { {{args "o" (len .Outputs) false true}} := impl.{{.Name}}({{args "i" (len .Inputs) true false}}) @@ -123,7 +125,7 @@ func (dispatch) {{.Name}}(impl Contract, env vm.PrecompileEnvironment, input []b return method.Outputs.Pack({{args "o" (len .Outputs) false false}}) {{- else -}} return nil, nil - {{end}} + {{- end}} } } {{end}} \ No newline at end of file diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index 95f65a2b3a98..66d7460cd72a 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -1,5 +1,5 @@ // Package testprecompile is a generated package for creating EVM precompiles -// conforming to the EIP-165 interface ID 0xbe022088. +// conforming to the EIP-165 interface ID 0xcacc24d1. package testprecompile // Code generated by precompilegen. DO NOT EDIT. @@ -15,7 +15,7 @@ import ( ) // A Contract is an implementation of a precompiled contract conforming to the -// EIP-165 interface ID 0xbe022088. +// EIP-165 interface ID 0xcacc24d1. type Contract interface { // Fallback implements a fallback function, called if the method selector // fails to match any other method. @@ -43,6 +43,14 @@ type Contract interface { // function NeitherViewNorPure() returns(bool canReadState, bool canWriteState) NeitherViewNorPure(vm.PrecompileEnvironment) (bool, bool, error) + // NonPayable implements the function with selector 0x6fb1b0e9: + // function NonPayable() returns() + NonPayable(vm.PrecompileEnvironment) error + + // Payable implements the function with selector 0x1b7fb4b0: + // function Payable() payable returns(uint256 value) + Payable(vm.PrecompileEnvironment) (*big.Int, error) + // Pure implements the function with selector 0xf5ad2fb8: // function Pure() pure returns(bool canReadState, bool canWriteState) Pure(vm.PrecompileEnvironment) (bool, bool, error) @@ -71,7 +79,7 @@ var ( dispatchers map[abi.Selector]methodDispatcher ) -const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NeitherViewNorPure","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Pure","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"View","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"view","type":"function"}]` +const abiJSON = `[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"Echo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"Echo","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"int256","name":"val","type":"int256"}],"internalType":"struct IPrecompile.Wrapper","name":"","type":"tuple"}],"name":"Extract","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes2","name":"","type":"bytes2"},{"internalType":"address","name":"","type":"address"}],"name":"HashPacked","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NeitherViewNorPure","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"NonPayable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Payable","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"Pure","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"RevertWith","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Self","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"View","outputs":[{"internalType":"bool","name":"canReadState","type":"bool"},{"internalType":"bool","name":"canWriteState","type":"bool"}],"stateMutability":"view","type":"function"}]` func init() { parsed, err := abi.JSON(strings.NewReader(abiJSON)) @@ -87,6 +95,8 @@ func init() { 0xad8108a4: d.Extract, 0xd7cc1f37: d.HashPacked, 0xa7263000: d.NeitherViewNorPure, + 0x6fb1b0e9: d.NonPayable, + 0x1b7fb4b0: d.Payable, 0xf5ad2fb8: d.Pure, 0xa93cbd97: d.RevertWith, 0xc62c692f: d.Self, @@ -233,6 +243,30 @@ func (dispatch) NeitherViewNorPure(impl Contract, env vm.PrecompileEnvironment, } } +func (dispatch) NonPayable(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + + { + err := impl.NonPayable(env) + if err != nil { + return nil, err + } + return nil, nil + } +} + +func (dispatch) Payable(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { + method := methods[0x1b7fb4b0] + + { + o0, err := impl.Payable(env) + if err != nil { + return nil, err + } + + return method.Outputs.Pack(o0) + } +} + func (dispatch) Pure(impl Contract, env vm.PrecompileEnvironment, input []byte) ([]byte, error) { method := methods[0xf5ad2fb8] @@ -261,7 +295,6 @@ func (dispatch) RevertWith(impl Contract, env vm.PrecompileEnvironment, input [] return nil, err } return nil, nil - } } From 08e498530a0c8162f256c792bc95b2d684440036 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 20 Dec 2024 18:16:22 +0000 Subject: [PATCH 15/22] refactor: split `IPrecompile` and `TestSuite` contracts + move tests --- .../{ => testprecompile}/.gitignore | 0 .../testprecompile/IPrecompile.sol | 31 ++ .../TestSuite.sol} | 33 +- .../generated_test.go} | 21 +- .../suite.abigen_test.go} | 326 +++++++++--------- 5 files changed, 207 insertions(+), 204 deletions(-) rename libevm/precompilegen/{ => testprecompile}/.gitignore (100%) create mode 100644 libevm/precompilegen/testprecompile/IPrecompile.sol rename libevm/precompilegen/{Test.sol => testprecompile/TestSuite.sol} (76%) rename libevm/precompilegen/{main_test.go => testprecompile/generated_test.go} (91%) rename libevm/precompilegen/{abigen.gen_test.go => testprecompile/suite.abigen_test.go} (67%) diff --git a/libevm/precompilegen/.gitignore b/libevm/precompilegen/testprecompile/.gitignore similarity index 100% rename from libevm/precompilegen/.gitignore rename to libevm/precompilegen/testprecompile/.gitignore diff --git a/libevm/precompilegen/testprecompile/IPrecompile.sol b/libevm/precompilegen/testprecompile/IPrecompile.sol new file mode 100644 index 000000000000..65de9086f700 --- /dev/null +++ b/libevm/precompilegen/testprecompile/IPrecompile.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: LGPL-3.0 +pragma solidity 0.8.28; + +/// @dev Interface of precompiled contract for implementation via `precompilegen`. +interface IPrecompile { + function Echo(string memory) external view returns (string memory); + + function Echo(uint256) external view returns (uint256); + + function HashPacked(uint256, bytes2, address) external view returns (bytes32); + + struct Wrapper { + int256 val; + } + + function Extract(Wrapper memory) external view returns (int256); + + function Self() external view returns (address); + + function RevertWith(bytes memory) external; + + function View() external view returns (bool canReadState, bool canWriteState); + + function Pure() external pure returns (bool canReadState, bool canWriteState); + + function NeitherViewNorPure() external returns (bool canReadState, bool canWriteState); + + function Payable() external payable returns (uint256 value); + + function NonPayable() external; +} diff --git a/libevm/precompilegen/Test.sol b/libevm/precompilegen/testprecompile/TestSuite.sol similarity index 76% rename from libevm/precompilegen/Test.sol rename to libevm/precompilegen/testprecompile/TestSuite.sol index 5f9a33ca6c91..49ae1b48d685 100644 --- a/libevm/precompilegen/Test.sol +++ b/libevm/precompilegen/testprecompile/TestSuite.sol @@ -1,37 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0 pragma solidity 0.8.28; -/// @dev Interface of precompiled contract for implementation via `precompilegen`. -interface IPrecompile { - function Echo(string memory) external view returns (string memory); +import {IPrecompile} from "./IPrecompile.sol"; - function Echo(uint256) external view returns (uint256); - - function HashPacked(uint256, bytes2, address) external view returns (bytes32); - - struct Wrapper { - int256 val; - } - - function Extract(Wrapper memory) external view returns (int256); - - function Self() external view returns (address); - - function RevertWith(bytes memory) external; - - function View() external view returns (bool canReadState, bool canWriteState); - - function Pure() external pure returns (bool canReadState, bool canWriteState); - - function NeitherViewNorPure() external returns (bool canReadState, bool canWriteState); - - function Payable() external payable returns (uint256 value); - - function NonPayable() external; -} - -/// @dev Testing contract to exercise the implementaiton of `IPrecompile`. -contract PrecompileTest { +/// @dev Testing contract to exercise the Go implementaiton of `IPrecompile`. +contract TestSuite { IPrecompile immutable precompile; constructor(IPrecompile _precompile) payable { diff --git a/libevm/precompilegen/main_test.go b/libevm/precompilegen/testprecompile/generated_test.go similarity index 91% rename from libevm/precompilegen/main_test.go rename to libevm/precompilegen/testprecompile/generated_test.go index 50388e410b4d..40b02af2e58c 100644 --- a/libevm/precompilegen/main_test.go +++ b/libevm/precompilegen/testprecompile/generated_test.go @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see // . -package main +package testprecompile import ( "context" @@ -34,16 +34,15 @@ import ( "github.com/ava-labs/libevm/libevm" "github.com/ava-labs/libevm/libevm/ethtest" "github.com/ava-labs/libevm/libevm/hookstest" - "github.com/ava-labs/libevm/libevm/precompilegen/testprecompile" "github.com/ava-labs/libevm/node" "github.com/ava-labs/libevm/params" ) // Note that the .abi and .bin files are .gitignored as only the generated Go // files are necessary. -//go:generate solc -o ./ --overwrite --abi --bin Test.sol -//go:generate go run . -in IPrecompile.abi -out ./testprecompile/generated.go -package testprecompile -//go:generate go run ../../cmd/abigen --abi PrecompileTest.abi --bin PrecompileTest.bin --pkg main --out ./abigen.gen_test.go --type PrecompileTest +//go:generate solc -o ./ --overwrite --abi --bin IPrecompile.sol TestSuite.sol +//go:generate go run ../ -in IPrecompile.abi -out ./generated.go -package testprecompile +//go:generate go run ../../../cmd/abigen --abi TestSuite.abi --bin TestSuite.bin --pkg testprecompile --out ./suite.abigen_test.go --type TestSuite func successfulTxReceipt(ctx context.Context, tb testing.TB, client bind.DeployBackend, tx *types.Transaction) *types.Receipt { tb.Helper() @@ -60,7 +59,7 @@ func TestGeneratedPrecompile(t *testing.T) { hooks := &hookstest.Stub{ PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ - precompile: testprecompile.New(contract{}), + precompile: New(contract{}), }, } extras := hookstest.Register(t, params.Extras[*hookstest.Stub, *hookstest.Stub]{ @@ -92,13 +91,13 @@ func TestGeneratedPrecompile(t *testing.T) { txOpts.Value = big.NewInt(1e9) client := sim.Client() - _, tx, test, err := DeployPrecompileTest(txOpts, client, precompile) - require.NoError(t, err, "DeployPrecompileTest(...)") + _, tx, test, err := DeployTestSuite(txOpts, client, precompile) + require.NoError(t, err, "DeployTestSuite(...)") sim.Commit() successfulTxReceipt(ctx, t, client, tx) txOpts.Value = nil - suite := &PrecompileTestSession{ + suite := &TestSuiteSession{ Contract: test, TransactOpts: *txOpts, } @@ -196,11 +195,11 @@ func TestGeneratedPrecompile(t *testing.T) { type contract struct{} -var _ testprecompile.Contract = contract{} +var _ Contract = contract{} func (contract) Fallback(env vm.PrecompileEnvironment, callData []byte) ([]byte, error) { // Note the test-suite assumption of the fallback's behaviour: - var _ = (*PrecompileTest).EchoingFallback + var _ = (*TestSuite).EchoingFallback return callData, nil } diff --git a/libevm/precompilegen/abigen.gen_test.go b/libevm/precompilegen/testprecompile/suite.abigen_test.go similarity index 67% rename from libevm/precompilegen/abigen.gen_test.go rename to libevm/precompilegen/testprecompile/suite.abigen_test.go index 8dbaa18c3ad6..f21ba1b4f3a0 100644 --- a/libevm/precompilegen/abigen.gen_test.go +++ b/libevm/precompilegen/testprecompile/suite.abigen_test.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package main +package testprecompile import ( "errors" @@ -34,23 +34,23 @@ type IPrecompileWrapper struct { Val *big.Int } -// PrecompileTestMetaData contains all meta data concerning the PrecompileTest contract. -var PrecompileTestMetaData = &bind.MetaData{ +// TestSuiteMetaData contains all meta data concerning the TestSuite contract. +var TestSuiteMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Transfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a0604052604051611d49380380611d49833981810160405281019061002591906100ce565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100f9565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61008c82610063565b9050919050565b5f61009d82610082565b9050919050565b6100ad81610093565b81146100b7575f5ffd5b50565b5f815190506100c8816100a4565b92915050565b5f602082840312156100e3576100e261005f565b5b5f6100f0848285016100ba565b91505092915050565b608051611bf26101575f395f81816101d2015281816102b101528181610356015281816104de015281816106420152818161077c0152818161086a015281816108a1015281816109b401528181610abf0152610c110152611bf25ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610d97565b6101cf565b005b6100d96102ae565b005b6100e3610490565b005b6100ff60048036038101906100fa9190610efe565b6104da565b005b61011b60048036038101906101169190610fb5565b610640565b005b61013760048036038101906101329190610efe565b610722565b005b610141610868565b005b61015d6004803603810190610158919061108f565b610987565b005b6101796004803603810190610174919061117d565b610a96565b005b610183610bc4565b005b610198631686f26560e01b60015f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c59061121e565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b8152600401610229919061124b565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102689190611278565b14610276576102756112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a39061131a565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103409190611278565b9050602a8114610353576103526112a3565b5b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16602a636fb1b0e960e01b604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610405919061138a565b5f6040518083038185875af1925050503d805f811461043f576040519150601f19603f3d011682016040523d82523d5f602084013e610444565b606091505b505090508015610457576104566112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610484906113ea565b60405180910390a15050565b6104a363a726300060e01b600180610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516104d090611452565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161052c91906114b8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610596919061138a565b5f604051808303815f865af19150503d805f81146105cf576040519150601f19603f3d011682016040523d82523d5f602084013e6105d4565b606091505b509150915081156105e8576105e76112a3565b5b8280519060200120818051906020012014610606576106056112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161063390611522565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016106999190611569565b602060405180830381865afa1580156106b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d89190611596565b815f0151146106ea576106e96112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107179061160b565b60405180910390a150565b5f5f8260405160240161073591906114b8565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516107bf919061138a565b5f60405180830381855afa9150503d805f81146107f7576040519150601f19603f3d011682016040523d82523d5f602084013e6107fc565b606091505b50915091508161080f5761080e6112a3565b5b828051906020012081805190602001201461082d5761082c6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161085a90611673565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610908573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061092c91906116a5565b73ffffffffffffffffffffffffffffffffffffffff16146109505761094f6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161097d9061171a565b60405180910390a1565b82828260405160200161099c939291906117bd565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610a0f93929190611817565b602060405180830381865afa158015610a2a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4e919061187f565b14610a5c57610a5b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610a89906118f4565b60405180910390a1505050565b80604051602001610aa79190611956565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610b1691906119a4565b5f60405180830381865afa158015610b30573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610b589190611a32565b604051602001610b689190611956565b6040516020818303038152906040528051906020012014610b8c57610b8b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610bb990611ac3565b60405180910390a150565b610bd663f5ad2fb860e01b5f5f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610c0390611b2b565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610cb7919061138a565b5f604051808303815f865af19150503d805f8114610cf0576040519150601f19603f3d011682016040523d82523d5f602084013e610cf5565b606091505b509150915081610d0857610d076112a3565b5b5f5f82806020019051810190610d1e9190611b7e565b9150915085151582151514610d3657610d356112a3565b5b84151581151514610d4a57610d496112a3565b5b50505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610d7681610d64565b8114610d80575f5ffd5b50565b5f81359050610d9181610d6d565b92915050565b5f60208284031215610dac57610dab610d5c565b5b5f610db984828501610d83565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610e1082610dca565b810181811067ffffffffffffffff82111715610e2f57610e2e610dda565b5b80604052505050565b5f610e41610d53565b9050610e4d8282610e07565b919050565b5f67ffffffffffffffff821115610e6c57610e6b610dda565b5b610e7582610dca565b9050602081019050919050565b828183375f83830152505050565b5f610ea2610e9d84610e52565b610e38565b905082815260208101848484011115610ebe57610ebd610dc6565b5b610ec9848285610e82565b509392505050565b5f82601f830112610ee557610ee4610dc2565b5b8135610ef5848260208601610e90565b91505092915050565b5f60208284031215610f1357610f12610d5c565b5b5f82013567ffffffffffffffff811115610f3057610f2f610d60565b5b610f3c84828501610ed1565b91505092915050565b5f5ffd5b5f819050919050565b610f5b81610f49565b8114610f65575f5ffd5b50565b5f81359050610f7681610f52565b92915050565b5f60208284031215610f9157610f90610f45565b5b610f9b6020610e38565b90505f610faa84828501610f68565b5f8301525092915050565b5f60208284031215610fca57610fc9610d5c565b5b5f610fd784828501610f7c565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61101481610fe0565b811461101e575f5ffd5b50565b5f8135905061102f8161100b565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61105e82611035565b9050919050565b61106e81611054565b8114611078575f5ffd5b50565b5f8135905061108981611065565b92915050565b5f5f5f606084860312156110a6576110a5610d5c565b5b5f6110b386828701610d83565b93505060206110c486828701611021565b92505060406110d58682870161107b565b9150509250925092565b5f67ffffffffffffffff8211156110f9576110f8610dda565b5b61110282610dca565b9050602081019050919050565b5f61112161111c846110df565b610e38565b90508281526020810184848401111561113d5761113c610dc6565b5b611148848285610e82565b509392505050565b5f82601f83011261116457611163610dc2565b5b813561117484826020860161110f565b91505092915050565b5f6020828403121561119257611191610d5c565b5b5f82013567ffffffffffffffff8111156111af576111ae610d60565b5b6111bb84828501611150565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f6112086006836111c4565b9150611213826111d4565b602082019050919050565b5f6020820190508181035f830152611235816111fc565b9050919050565b61124581610d64565b82525050565b5f60208201905061125e5f83018461123c565b92915050565b5f8151905061127281610d6d565b92915050565b5f6020828403121561128d5761128c610d5c565b5b5f61129a84828501611264565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f611304600d836111c4565b915061130f826112d0565b602082019050919050565b5f6020820190508181035f830152611331816112f8565b9050919050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f61136482611338565b61136e8185611342565b935061137e81856020860161134c565b80840191505092915050565b5f611395828461135a565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f6113d4600a836111c4565b91506113df826113a0565b602082019050919050565b5f6020820190508181035f830152611401816113c8565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61143c6014836111c4565b915061144782611408565b602082019050919050565b5f6020820190508181035f83015261146981611430565b9050919050565b5f82825260208201905092915050565b5f61148a82611338565b6114948185611470565b93506114a481856020860161134c565b6114ad81610dca565b840191505092915050565b5f6020820190508181035f8301526114d08184611480565b905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f61150c600f836111c4565b9150611517826114d8565b602082019050919050565b5f6020820190508181035f83015261153981611500565b9050919050565b61154981610f49565b82525050565b602082015f8201516115635f850182611540565b50505050565b5f60208201905061157c5f83018461154f565b92915050565b5f8151905061159081610f52565b92915050565b5f602082840312156115ab576115aa610d5c565b5b5f6115b884828501611582565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f6115f5600c836111c4565b9150611600826115c1565b602082019050919050565b5f6020820190508181035f830152611622816115e9565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f61165d6014836111c4565b915061166882611629565b602082019050919050565b5f6020820190508181035f83015261168a81611651565b9050919050565b5f8151905061169f81611065565b92915050565b5f602082840312156116ba576116b9610d5c565b5b5f6116c784828501611691565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6117046006836111c4565b915061170f826116d0565b602082019050919050565b5f6020820190508181035f830152611731816116f8565b9050919050565b5f819050919050565b61175261174d82610d64565b611738565b82525050565b5f819050919050565b61177261176d82610fe0565b611758565b82525050565b5f8160601b9050919050565b5f61178e82611778565b9050919050565b5f61179f82611784565b9050919050565b6117b76117b282611054565b611795565b82525050565b5f6117c88286611741565b6020820191506117d88285611761565b6002820191506117e882846117a6565b601482019150819050949350505050565b61180281610fe0565b82525050565b61181181611054565b82525050565b5f60608201905061182a5f83018661123c565b61183760208301856117f9565b6118446040830184611808565b949350505050565b5f819050919050565b61185e8161184c565b8114611868575f5ffd5b50565b5f8151905061187981611855565b92915050565b5f6020828403121561189457611893610d5c565b5b5f6118a18482850161186b565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6118de600f836111c4565b91506118e9826118aa565b602082019050919050565b5f6020820190508181035f83015261190b816118d2565b9050919050565b5f81519050919050565b5f81905092915050565b5f61193082611912565b61193a818561191c565b935061194a81856020860161134c565b80840191505092915050565b5f6119618284611926565b915081905092915050565b5f61197682611912565b61198081856111c4565b935061199081856020860161134c565b61199981610dca565b840191505092915050565b5f6020820190508181035f8301526119bc818461196c565b905092915050565b5f6119d66119d1846110df565b610e38565b9050828152602081018484840111156119f2576119f1610dc6565b5b6119fd84828561134c565b509392505050565b5f82601f830112611a1957611a18610dc2565b5b8151611a298482602086016119c4565b91505092915050565b5f60208284031215611a4757611a46610d5c565b5b5f82015167ffffffffffffffff811115611a6457611a63610d60565b5b611a7084828501611a05565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611aad600c836111c4565b9150611ab882611a79565b602082019050919050565b5f6020820190508181035f830152611ada81611aa1565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611b156006836111c4565b9150611b2082611ae1565b602082019050919050565b5f6020820190508181035f830152611b4281611b09565b9050919050565b5f8115159050919050565b611b5d81611b49565b8114611b67575f5ffd5b50565b5f81519050611b7881611b54565b92915050565b5f5f60408385031215611b9457611b93610d5c565b5b5f611ba185828601611b6a565b9250506020611bb285828601611b6a565b915050925092905056fea264697066735822122015cec228d3431d1c7e411919e8c1d0eedf25bb9b34ed83e88e4dbcb442ad811764736f6c634300081c0033", + Bin: "0x60a0604052604051611d49380380611d49833981810160405281019061002591906100ce565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100f9565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61008c82610063565b9050919050565b5f61009d82610082565b9050919050565b6100ad81610093565b81146100b7575f5ffd5b50565b5f815190506100c8816100a4565b92915050565b5f602082840312156100e3576100e261005f565b5b5f6100f0848285016100ba565b91505092915050565b608051611bf26101575f395f81816101d2015281816102b101528181610356015281816104de015281816106420152818161077c0152818161086a015281816108a1015281816109b401528181610abf0152610c110152611bf25ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610d97565b6101cf565b005b6100d96102ae565b005b6100e3610490565b005b6100ff60048036038101906100fa9190610efe565b6104da565b005b61011b60048036038101906101169190610fb5565b610640565b005b61013760048036038101906101329190610efe565b610722565b005b610141610868565b005b61015d6004803603810190610158919061108f565b610987565b005b6101796004803603810190610174919061117d565b610a96565b005b610183610bc4565b005b610198631686f26560e01b60015f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c59061121e565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b8152600401610229919061124b565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102689190611278565b14610276576102756112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a39061131a565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103409190611278565b9050602a8114610353576103526112a3565b5b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16602a636fb1b0e960e01b604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610405919061138a565b5f6040518083038185875af1925050503d805f811461043f576040519150601f19603f3d011682016040523d82523d5f602084013e610444565b606091505b505090508015610457576104566112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610484906113ea565b60405180910390a15050565b6104a363a726300060e01b600180610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516104d090611452565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161052c91906114b8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610596919061138a565b5f604051808303815f865af19150503d805f81146105cf576040519150601f19603f3d011682016040523d82523d5f602084013e6105d4565b606091505b509150915081156105e8576105e76112a3565b5b8280519060200120818051906020012014610606576106056112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161063390611522565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016106999190611569565b602060405180830381865afa1580156106b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d89190611596565b815f0151146106ea576106e96112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107179061160b565b60405180910390a150565b5f5f8260405160240161073591906114b8565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516107bf919061138a565b5f60405180830381855afa9150503d805f81146107f7576040519150601f19603f3d011682016040523d82523d5f602084013e6107fc565b606091505b50915091508161080f5761080e6112a3565b5b828051906020012081805190602001201461082d5761082c6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161085a90611673565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610908573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061092c91906116a5565b73ffffffffffffffffffffffffffffffffffffffff16146109505761094f6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161097d9061171a565b60405180910390a1565b82828260405160200161099c939291906117bd565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610a0f93929190611817565b602060405180830381865afa158015610a2a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4e919061187f565b14610a5c57610a5b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610a89906118f4565b60405180910390a1505050565b80604051602001610aa79190611956565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610b1691906119a4565b5f60405180830381865afa158015610b30573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610b589190611a32565b604051602001610b689190611956565b6040516020818303038152906040528051906020012014610b8c57610b8b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610bb990611ac3565b60405180910390a150565b610bd663f5ad2fb860e01b5f5f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610c0390611b2b565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610cb7919061138a565b5f604051808303815f865af19150503d805f8114610cf0576040519150601f19603f3d011682016040523d82523d5f602084013e610cf5565b606091505b509150915081610d0857610d076112a3565b5b5f5f82806020019051810190610d1e9190611b7e565b9150915085151582151514610d3657610d356112a3565b5b84151581151514610d4a57610d496112a3565b5b50505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610d7681610d64565b8114610d80575f5ffd5b50565b5f81359050610d9181610d6d565b92915050565b5f60208284031215610dac57610dab610d5c565b5b5f610db984828501610d83565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610e1082610dca565b810181811067ffffffffffffffff82111715610e2f57610e2e610dda565b5b80604052505050565b5f610e41610d53565b9050610e4d8282610e07565b919050565b5f67ffffffffffffffff821115610e6c57610e6b610dda565b5b610e7582610dca565b9050602081019050919050565b828183375f83830152505050565b5f610ea2610e9d84610e52565b610e38565b905082815260208101848484011115610ebe57610ebd610dc6565b5b610ec9848285610e82565b509392505050565b5f82601f830112610ee557610ee4610dc2565b5b8135610ef5848260208601610e90565b91505092915050565b5f60208284031215610f1357610f12610d5c565b5b5f82013567ffffffffffffffff811115610f3057610f2f610d60565b5b610f3c84828501610ed1565b91505092915050565b5f5ffd5b5f819050919050565b610f5b81610f49565b8114610f65575f5ffd5b50565b5f81359050610f7681610f52565b92915050565b5f60208284031215610f9157610f90610f45565b5b610f9b6020610e38565b90505f610faa84828501610f68565b5f8301525092915050565b5f60208284031215610fca57610fc9610d5c565b5b5f610fd784828501610f7c565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61101481610fe0565b811461101e575f5ffd5b50565b5f8135905061102f8161100b565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61105e82611035565b9050919050565b61106e81611054565b8114611078575f5ffd5b50565b5f8135905061108981611065565b92915050565b5f5f5f606084860312156110a6576110a5610d5c565b5b5f6110b386828701610d83565b93505060206110c486828701611021565b92505060406110d58682870161107b565b9150509250925092565b5f67ffffffffffffffff8211156110f9576110f8610dda565b5b61110282610dca565b9050602081019050919050565b5f61112161111c846110df565b610e38565b90508281526020810184848401111561113d5761113c610dc6565b5b611148848285610e82565b509392505050565b5f82601f83011261116457611163610dc2565b5b813561117484826020860161110f565b91505092915050565b5f6020828403121561119257611191610d5c565b5b5f82013567ffffffffffffffff8111156111af576111ae610d60565b5b6111bb84828501611150565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f6112086006836111c4565b9150611213826111d4565b602082019050919050565b5f6020820190508181035f830152611235816111fc565b9050919050565b61124581610d64565b82525050565b5f60208201905061125e5f83018461123c565b92915050565b5f8151905061127281610d6d565b92915050565b5f6020828403121561128d5761128c610d5c565b5b5f61129a84828501611264565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f611304600d836111c4565b915061130f826112d0565b602082019050919050565b5f6020820190508181035f830152611331816112f8565b9050919050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f61136482611338565b61136e8185611342565b935061137e81856020860161134c565b80840191505092915050565b5f611395828461135a565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f6113d4600a836111c4565b91506113df826113a0565b602082019050919050565b5f6020820190508181035f830152611401816113c8565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61143c6014836111c4565b915061144782611408565b602082019050919050565b5f6020820190508181035f83015261146981611430565b9050919050565b5f82825260208201905092915050565b5f61148a82611338565b6114948185611470565b93506114a481856020860161134c565b6114ad81610dca565b840191505092915050565b5f6020820190508181035f8301526114d08184611480565b905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f61150c600f836111c4565b9150611517826114d8565b602082019050919050565b5f6020820190508181035f83015261153981611500565b9050919050565b61154981610f49565b82525050565b602082015f8201516115635f850182611540565b50505050565b5f60208201905061157c5f83018461154f565b92915050565b5f8151905061159081610f52565b92915050565b5f602082840312156115ab576115aa610d5c565b5b5f6115b884828501611582565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f6115f5600c836111c4565b9150611600826115c1565b602082019050919050565b5f6020820190508181035f830152611622816115e9565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f61165d6014836111c4565b915061166882611629565b602082019050919050565b5f6020820190508181035f83015261168a81611651565b9050919050565b5f8151905061169f81611065565b92915050565b5f602082840312156116ba576116b9610d5c565b5b5f6116c784828501611691565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6117046006836111c4565b915061170f826116d0565b602082019050919050565b5f6020820190508181035f830152611731816116f8565b9050919050565b5f819050919050565b61175261174d82610d64565b611738565b82525050565b5f819050919050565b61177261176d82610fe0565b611758565b82525050565b5f8160601b9050919050565b5f61178e82611778565b9050919050565b5f61179f82611784565b9050919050565b6117b76117b282611054565b611795565b82525050565b5f6117c88286611741565b6020820191506117d88285611761565b6002820191506117e882846117a6565b601482019150819050949350505050565b61180281610fe0565b82525050565b61181181611054565b82525050565b5f60608201905061182a5f83018661123c565b61183760208301856117f9565b6118446040830184611808565b949350505050565b5f819050919050565b61185e8161184c565b8114611868575f5ffd5b50565b5f8151905061187981611855565b92915050565b5f6020828403121561189457611893610d5c565b5b5f6118a18482850161186b565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6118de600f836111c4565b91506118e9826118aa565b602082019050919050565b5f6020820190508181035f83015261190b816118d2565b9050919050565b5f81519050919050565b5f81905092915050565b5f61193082611912565b61193a818561191c565b935061194a81856020860161134c565b80840191505092915050565b5f6119618284611926565b915081905092915050565b5f61197682611912565b61198081856111c4565b935061199081856020860161134c565b61199981610dca565b840191505092915050565b5f6020820190508181035f8301526119bc818461196c565b905092915050565b5f6119d66119d1846110df565b610e38565b9050828152602081018484840111156119f2576119f1610dc6565b5b6119fd84828561134c565b509392505050565b5f82601f830112611a1957611a18610dc2565b5b8151611a298482602086016119c4565b91505092915050565b5f60208284031215611a4757611a46610d5c565b5b5f82015167ffffffffffffffff811115611a6457611a63610d60565b5b611a7084828501611a05565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611aad600c836111c4565b9150611ab882611a79565b602082019050919050565b5f6020820190508181035f830152611ada81611aa1565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611b156006836111c4565b9150611b2082611ae1565b602082019050919050565b5f6020820190508181035f830152611b4281611b09565b9050919050565b5f8115159050919050565b611b5d81611b49565b8114611b67575f5ffd5b50565b5f81519050611b7881611b54565b92915050565b5f5f60408385031215611b9457611b93610d5c565b5b5f611ba185828601611b6a565b9250506020611bb285828601611b6a565b915050925092905056fea2646970667358221220a17f2af7577357b66480c1cde39be2a37f66d1ac61be6fdd33d4fc9936e7f34264736f6c634300081c0033", } -// PrecompileTestABI is the input ABI used to generate the binding from. -// Deprecated: Use PrecompileTestMetaData.ABI instead. -var PrecompileTestABI = PrecompileTestMetaData.ABI +// TestSuiteABI is the input ABI used to generate the binding from. +// Deprecated: Use TestSuiteMetaData.ABI instead. +var TestSuiteABI = TestSuiteMetaData.ABI -// PrecompileTestBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use PrecompileTestMetaData.Bin instead. -var PrecompileTestBin = PrecompileTestMetaData.Bin +// TestSuiteBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use TestSuiteMetaData.Bin instead. +var TestSuiteBin = TestSuiteMetaData.Bin -// DeployPrecompileTest deploys a new Ethereum contract, binding an instance of PrecompileTest to it. -func DeployPrecompileTest(auth *bind.TransactOpts, backend bind.ContractBackend, _precompile common.Address) (common.Address, *types.Transaction, *PrecompileTest, error) { - parsed, err := PrecompileTestMetaData.GetAbi() +// DeployTestSuite deploys a new Ethereum contract, binding an instance of TestSuite to it. +func DeployTestSuite(auth *bind.TransactOpts, backend bind.ContractBackend, _precompile common.Address) (common.Address, *types.Transaction, *TestSuite, error) { + parsed, err := TestSuiteMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err } @@ -58,111 +58,111 @@ func DeployPrecompileTest(auth *bind.TransactOpts, backend bind.ContractBackend, return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(PrecompileTestBin), backend, _precompile) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(TestSuiteBin), backend, _precompile) if err != nil { return common.Address{}, nil, nil, err } - return address, tx, &PrecompileTest{PrecompileTestCaller: PrecompileTestCaller{contract: contract}, PrecompileTestTransactor: PrecompileTestTransactor{contract: contract}, PrecompileTestFilterer: PrecompileTestFilterer{contract: contract}}, nil + return address, tx, &TestSuite{TestSuiteCaller: TestSuiteCaller{contract: contract}, TestSuiteTransactor: TestSuiteTransactor{contract: contract}, TestSuiteFilterer: TestSuiteFilterer{contract: contract}}, nil } -// PrecompileTest is an auto generated Go binding around an Ethereum contract. -type PrecompileTest struct { - PrecompileTestCaller // Read-only binding to the contract - PrecompileTestTransactor // Write-only binding to the contract - PrecompileTestFilterer // Log filterer for contract events +// TestSuite is an auto generated Go binding around an Ethereum contract. +type TestSuite struct { + TestSuiteCaller // Read-only binding to the contract + TestSuiteTransactor // Write-only binding to the contract + TestSuiteFilterer // Log filterer for contract events } -// PrecompileTestCaller is an auto generated read-only Go binding around an Ethereum contract. -type PrecompileTestCaller struct { +// TestSuiteCaller is an auto generated read-only Go binding around an Ethereum contract. +type TestSuiteCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// PrecompileTestTransactor is an auto generated write-only Go binding around an Ethereum contract. -type PrecompileTestTransactor struct { +// TestSuiteTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TestSuiteTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// PrecompileTestFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type PrecompileTestFilterer struct { +// TestSuiteFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TestSuiteFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// PrecompileTestSession is an auto generated Go binding around an Ethereum contract, +// TestSuiteSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. -type PrecompileTestSession struct { - Contract *PrecompileTest // Generic contract binding to set the session for +type TestSuiteSession struct { + Contract *TestSuite // Generic contract binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// PrecompileTestCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// TestSuiteCallerSession is an auto generated read-only Go binding around an Ethereum contract, // with pre-set call options. -type PrecompileTestCallerSession struct { - Contract *PrecompileTestCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session +type TestSuiteCallerSession struct { + Contract *TestSuiteCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session } -// PrecompileTestTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// TestSuiteTransactorSession is an auto generated write-only Go binding around an Ethereum contract, // with pre-set transact options. -type PrecompileTestTransactorSession struct { - Contract *PrecompileTestTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +type TestSuiteTransactorSession struct { + Contract *TestSuiteTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// PrecompileTestRaw is an auto generated low-level Go binding around an Ethereum contract. -type PrecompileTestRaw struct { - Contract *PrecompileTest // Generic contract binding to access the raw methods on +// TestSuiteRaw is an auto generated low-level Go binding around an Ethereum contract. +type TestSuiteRaw struct { + Contract *TestSuite // Generic contract binding to access the raw methods on } -// PrecompileTestCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type PrecompileTestCallerRaw struct { - Contract *PrecompileTestCaller // Generic read-only contract binding to access the raw methods on +// TestSuiteCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TestSuiteCallerRaw struct { + Contract *TestSuiteCaller // Generic read-only contract binding to access the raw methods on } -// PrecompileTestTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type PrecompileTestTransactorRaw struct { - Contract *PrecompileTestTransactor // Generic write-only contract binding to access the raw methods on +// TestSuiteTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TestSuiteTransactorRaw struct { + Contract *TestSuiteTransactor // Generic write-only contract binding to access the raw methods on } -// NewPrecompileTest creates a new instance of PrecompileTest, bound to a specific deployed contract. -func NewPrecompileTest(address common.Address, backend bind.ContractBackend) (*PrecompileTest, error) { - contract, err := bindPrecompileTest(address, backend, backend, backend) +// NewTestSuite creates a new instance of TestSuite, bound to a specific deployed contract. +func NewTestSuite(address common.Address, backend bind.ContractBackend) (*TestSuite, error) { + contract, err := bindTestSuite(address, backend, backend, backend) if err != nil { return nil, err } - return &PrecompileTest{PrecompileTestCaller: PrecompileTestCaller{contract: contract}, PrecompileTestTransactor: PrecompileTestTransactor{contract: contract}, PrecompileTestFilterer: PrecompileTestFilterer{contract: contract}}, nil + return &TestSuite{TestSuiteCaller: TestSuiteCaller{contract: contract}, TestSuiteTransactor: TestSuiteTransactor{contract: contract}, TestSuiteFilterer: TestSuiteFilterer{contract: contract}}, nil } -// NewPrecompileTestCaller creates a new read-only instance of PrecompileTest, bound to a specific deployed contract. -func NewPrecompileTestCaller(address common.Address, caller bind.ContractCaller) (*PrecompileTestCaller, error) { - contract, err := bindPrecompileTest(address, caller, nil, nil) +// NewTestSuiteCaller creates a new read-only instance of TestSuite, bound to a specific deployed contract. +func NewTestSuiteCaller(address common.Address, caller bind.ContractCaller) (*TestSuiteCaller, error) { + contract, err := bindTestSuite(address, caller, nil, nil) if err != nil { return nil, err } - return &PrecompileTestCaller{contract: contract}, nil + return &TestSuiteCaller{contract: contract}, nil } -// NewPrecompileTestTransactor creates a new write-only instance of PrecompileTest, bound to a specific deployed contract. -func NewPrecompileTestTransactor(address common.Address, transactor bind.ContractTransactor) (*PrecompileTestTransactor, error) { - contract, err := bindPrecompileTest(address, nil, transactor, nil) +// NewTestSuiteTransactor creates a new write-only instance of TestSuite, bound to a specific deployed contract. +func NewTestSuiteTransactor(address common.Address, transactor bind.ContractTransactor) (*TestSuiteTransactor, error) { + contract, err := bindTestSuite(address, nil, transactor, nil) if err != nil { return nil, err } - return &PrecompileTestTransactor{contract: contract}, nil + return &TestSuiteTransactor{contract: contract}, nil } -// NewPrecompileTestFilterer creates a new log filterer instance of PrecompileTest, bound to a specific deployed contract. -func NewPrecompileTestFilterer(address common.Address, filterer bind.ContractFilterer) (*PrecompileTestFilterer, error) { - contract, err := bindPrecompileTest(address, nil, nil, filterer) +// NewTestSuiteFilterer creates a new log filterer instance of TestSuite, bound to a specific deployed contract. +func NewTestSuiteFilterer(address common.Address, filterer bind.ContractFilterer) (*TestSuiteFilterer, error) { + contract, err := bindTestSuite(address, nil, nil, filterer) if err != nil { return nil, err } - return &PrecompileTestFilterer{contract: contract}, nil + return &TestSuiteFilterer{contract: contract}, nil } -// bindPrecompileTest binds a generic wrapper to an already deployed contract. -func bindPrecompileTest(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := PrecompileTestMetaData.GetAbi() +// bindTestSuite binds a generic wrapper to an already deployed contract. +func bindTestSuite(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := TestSuiteMetaData.GetAbi() if err != nil { return nil, err } @@ -173,274 +173,274 @@ func bindPrecompileTest(address common.Address, caller bind.ContractCaller, tran // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_PrecompileTest *PrecompileTestRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _PrecompileTest.Contract.PrecompileTestCaller.contract.Call(opts, result, method, params...) +func (_TestSuite *TestSuiteRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TestSuite.Contract.TestSuiteCaller.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_PrecompileTest *PrecompileTestRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.Contract.PrecompileTestTransactor.contract.Transfer(opts) +func (_TestSuite *TestSuiteRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.Contract.TestSuiteTransactor.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_PrecompileTest *PrecompileTestRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _PrecompileTest.Contract.PrecompileTestTransactor.contract.Transact(opts, method, params...) +func (_TestSuite *TestSuiteRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TestSuite.Contract.TestSuiteTransactor.contract.Transact(opts, method, params...) } // Call invokes the (constant) contract method with params as input values and // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_PrecompileTest *PrecompileTestCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _PrecompileTest.Contract.contract.Call(opts, result, method, params...) +func (_TestSuite *TestSuiteCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TestSuite.Contract.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_PrecompileTest *PrecompileTestTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.Contract.contract.Transfer(opts) +func (_TestSuite *TestSuiteTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.Contract.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_PrecompileTest *PrecompileTestTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _PrecompileTest.Contract.contract.Transact(opts, method, params...) +func (_TestSuite *TestSuiteTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TestSuite.Contract.contract.Transact(opts, method, params...) } // Echo is a paid mutator transaction binding the contract method 0x34d6d9be. // // Solidity: function Echo(uint256 x) returns() -func (_PrecompileTest *PrecompileTestTransactor) Echo(opts *bind.TransactOpts, x *big.Int) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "Echo", x) +func (_TestSuite *TestSuiteTransactor) Echo(opts *bind.TransactOpts, x *big.Int) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "Echo", x) } // Echo is a paid mutator transaction binding the contract method 0x34d6d9be. // // Solidity: function Echo(uint256 x) returns() -func (_PrecompileTest *PrecompileTestSession) Echo(x *big.Int) (*types.Transaction, error) { - return _PrecompileTest.Contract.Echo(&_PrecompileTest.TransactOpts, x) +func (_TestSuite *TestSuiteSession) Echo(x *big.Int) (*types.Transaction, error) { + return _TestSuite.Contract.Echo(&_TestSuite.TransactOpts, x) } // Echo is a paid mutator transaction binding the contract method 0x34d6d9be. // // Solidity: function Echo(uint256 x) returns() -func (_PrecompileTest *PrecompileTestTransactorSession) Echo(x *big.Int) (*types.Transaction, error) { - return _PrecompileTest.Contract.Echo(&_PrecompileTest.TransactOpts, x) +func (_TestSuite *TestSuiteTransactorSession) Echo(x *big.Int) (*types.Transaction, error) { + return _TestSuite.Contract.Echo(&_TestSuite.TransactOpts, x) } // Echo0 is a paid mutator transaction binding the contract method 0xdb84d7c0. // // Solidity: function Echo(string x) returns() -func (_PrecompileTest *PrecompileTestTransactor) Echo0(opts *bind.TransactOpts, x string) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "Echo0", x) +func (_TestSuite *TestSuiteTransactor) Echo0(opts *bind.TransactOpts, x string) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "Echo0", x) } // Echo0 is a paid mutator transaction binding the contract method 0xdb84d7c0. // // Solidity: function Echo(string x) returns() -func (_PrecompileTest *PrecompileTestSession) Echo0(x string) (*types.Transaction, error) { - return _PrecompileTest.Contract.Echo0(&_PrecompileTest.TransactOpts, x) +func (_TestSuite *TestSuiteSession) Echo0(x string) (*types.Transaction, error) { + return _TestSuite.Contract.Echo0(&_TestSuite.TransactOpts, x) } // Echo0 is a paid mutator transaction binding the contract method 0xdb84d7c0. // // Solidity: function Echo(string x) returns() -func (_PrecompileTest *PrecompileTestTransactorSession) Echo0(x string) (*types.Transaction, error) { - return _PrecompileTest.Contract.Echo0(&_PrecompileTest.TransactOpts, x) +func (_TestSuite *TestSuiteTransactorSession) Echo0(x string) (*types.Transaction, error) { + return _TestSuite.Contract.Echo0(&_TestSuite.TransactOpts, x) } // EchoingFallback is a paid mutator transaction binding the contract method 0xb4a81808. // // Solidity: function EchoingFallback(bytes input) returns() -func (_PrecompileTest *PrecompileTestTransactor) EchoingFallback(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "EchoingFallback", input) +func (_TestSuite *TestSuiteTransactor) EchoingFallback(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "EchoingFallback", input) } // EchoingFallback is a paid mutator transaction binding the contract method 0xb4a81808. // // Solidity: function EchoingFallback(bytes input) returns() -func (_PrecompileTest *PrecompileTestSession) EchoingFallback(input []byte) (*types.Transaction, error) { - return _PrecompileTest.Contract.EchoingFallback(&_PrecompileTest.TransactOpts, input) +func (_TestSuite *TestSuiteSession) EchoingFallback(input []byte) (*types.Transaction, error) { + return _TestSuite.Contract.EchoingFallback(&_TestSuite.TransactOpts, input) } // EchoingFallback is a paid mutator transaction binding the contract method 0xb4a81808. // // Solidity: function EchoingFallback(bytes input) returns() -func (_PrecompileTest *PrecompileTestTransactorSession) EchoingFallback(input []byte) (*types.Transaction, error) { - return _PrecompileTest.Contract.EchoingFallback(&_PrecompileTest.TransactOpts, input) +func (_TestSuite *TestSuiteTransactorSession) EchoingFallback(input []byte) (*types.Transaction, error) { + return _TestSuite.Contract.EchoingFallback(&_TestSuite.TransactOpts, input) } // Extract is a paid mutator transaction binding the contract method 0xad8108a4. // // Solidity: function Extract((int256) x) returns() -func (_PrecompileTest *PrecompileTestTransactor) Extract(opts *bind.TransactOpts, x IPrecompileWrapper) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "Extract", x) +func (_TestSuite *TestSuiteTransactor) Extract(opts *bind.TransactOpts, x IPrecompileWrapper) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "Extract", x) } // Extract is a paid mutator transaction binding the contract method 0xad8108a4. // // Solidity: function Extract((int256) x) returns() -func (_PrecompileTest *PrecompileTestSession) Extract(x IPrecompileWrapper) (*types.Transaction, error) { - return _PrecompileTest.Contract.Extract(&_PrecompileTest.TransactOpts, x) +func (_TestSuite *TestSuiteSession) Extract(x IPrecompileWrapper) (*types.Transaction, error) { + return _TestSuite.Contract.Extract(&_TestSuite.TransactOpts, x) } // Extract is a paid mutator transaction binding the contract method 0xad8108a4. // // Solidity: function Extract((int256) x) returns() -func (_PrecompileTest *PrecompileTestTransactorSession) Extract(x IPrecompileWrapper) (*types.Transaction, error) { - return _PrecompileTest.Contract.Extract(&_PrecompileTest.TransactOpts, x) +func (_TestSuite *TestSuiteTransactorSession) Extract(x IPrecompileWrapper) (*types.Transaction, error) { + return _TestSuite.Contract.Extract(&_TestSuite.TransactOpts, x) } // HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. // // Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() -func (_PrecompileTest *PrecompileTestTransactor) HashPacked(opts *bind.TransactOpts, x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "HashPacked", x, y, z) +func (_TestSuite *TestSuiteTransactor) HashPacked(opts *bind.TransactOpts, x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "HashPacked", x, y, z) } // HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. // // Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() -func (_PrecompileTest *PrecompileTestSession) HashPacked(x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { - return _PrecompileTest.Contract.HashPacked(&_PrecompileTest.TransactOpts, x, y, z) +func (_TestSuite *TestSuiteSession) HashPacked(x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { + return _TestSuite.Contract.HashPacked(&_TestSuite.TransactOpts, x, y, z) } // HashPacked is a paid mutator transaction binding the contract method 0xd7cc1f37. // // Solidity: function HashPacked(uint256 x, bytes2 y, address z) returns() -func (_PrecompileTest *PrecompileTestTransactorSession) HashPacked(x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { - return _PrecompileTest.Contract.HashPacked(&_PrecompileTest.TransactOpts, x, y, z) +func (_TestSuite *TestSuiteTransactorSession) HashPacked(x *big.Int, y [2]byte, z common.Address) (*types.Transaction, error) { + return _TestSuite.Contract.HashPacked(&_TestSuite.TransactOpts, x, y, z) } // NeitherViewNorPure is a paid mutator transaction binding the contract method 0xa7263000. // // Solidity: function NeitherViewNorPure() returns() -func (_PrecompileTest *PrecompileTestTransactor) NeitherViewNorPure(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "NeitherViewNorPure") +func (_TestSuite *TestSuiteTransactor) NeitherViewNorPure(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "NeitherViewNorPure") } // NeitherViewNorPure is a paid mutator transaction binding the contract method 0xa7263000. // // Solidity: function NeitherViewNorPure() returns() -func (_PrecompileTest *PrecompileTestSession) NeitherViewNorPure() (*types.Transaction, error) { - return _PrecompileTest.Contract.NeitherViewNorPure(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteSession) NeitherViewNorPure() (*types.Transaction, error) { + return _TestSuite.Contract.NeitherViewNorPure(&_TestSuite.TransactOpts) } // NeitherViewNorPure is a paid mutator transaction binding the contract method 0xa7263000. // // Solidity: function NeitherViewNorPure() returns() -func (_PrecompileTest *PrecompileTestTransactorSession) NeitherViewNorPure() (*types.Transaction, error) { - return _PrecompileTest.Contract.NeitherViewNorPure(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteTransactorSession) NeitherViewNorPure() (*types.Transaction, error) { + return _TestSuite.Contract.NeitherViewNorPure(&_TestSuite.TransactOpts) } // Pure is a paid mutator transaction binding the contract method 0xf5ad2fb8. // // Solidity: function Pure() returns() -func (_PrecompileTest *PrecompileTestTransactor) Pure(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "Pure") +func (_TestSuite *TestSuiteTransactor) Pure(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "Pure") } // Pure is a paid mutator transaction binding the contract method 0xf5ad2fb8. // // Solidity: function Pure() returns() -func (_PrecompileTest *PrecompileTestSession) Pure() (*types.Transaction, error) { - return _PrecompileTest.Contract.Pure(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteSession) Pure() (*types.Transaction, error) { + return _TestSuite.Contract.Pure(&_TestSuite.TransactOpts) } // Pure is a paid mutator transaction binding the contract method 0xf5ad2fb8. // // Solidity: function Pure() returns() -func (_PrecompileTest *PrecompileTestTransactorSession) Pure() (*types.Transaction, error) { - return _PrecompileTest.Contract.Pure(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteTransactorSession) Pure() (*types.Transaction, error) { + return _TestSuite.Contract.Pure(&_TestSuite.TransactOpts) } // RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. // // Solidity: function RevertWith(bytes err) returns() -func (_PrecompileTest *PrecompileTestTransactor) RevertWith(opts *bind.TransactOpts, err []byte) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "RevertWith", err) +func (_TestSuite *TestSuiteTransactor) RevertWith(opts *bind.TransactOpts, err []byte) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "RevertWith", err) } // RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. // // Solidity: function RevertWith(bytes err) returns() -func (_PrecompileTest *PrecompileTestSession) RevertWith(err []byte) (*types.Transaction, error) { - return _PrecompileTest.Contract.RevertWith(&_PrecompileTest.TransactOpts, err) +func (_TestSuite *TestSuiteSession) RevertWith(err []byte) (*types.Transaction, error) { + return _TestSuite.Contract.RevertWith(&_TestSuite.TransactOpts, err) } // RevertWith is a paid mutator transaction binding the contract method 0xa93cbd97. // // Solidity: function RevertWith(bytes err) returns() -func (_PrecompileTest *PrecompileTestTransactorSession) RevertWith(err []byte) (*types.Transaction, error) { - return _PrecompileTest.Contract.RevertWith(&_PrecompileTest.TransactOpts, err) +func (_TestSuite *TestSuiteTransactorSession) RevertWith(err []byte) (*types.Transaction, error) { + return _TestSuite.Contract.RevertWith(&_TestSuite.TransactOpts, err) } // Self is a paid mutator transaction binding the contract method 0xc62c692f. // // Solidity: function Self() returns() -func (_PrecompileTest *PrecompileTestTransactor) Self(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "Self") +func (_TestSuite *TestSuiteTransactor) Self(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "Self") } // Self is a paid mutator transaction binding the contract method 0xc62c692f. // // Solidity: function Self() returns() -func (_PrecompileTest *PrecompileTestSession) Self() (*types.Transaction, error) { - return _PrecompileTest.Contract.Self(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteSession) Self() (*types.Transaction, error) { + return _TestSuite.Contract.Self(&_TestSuite.TransactOpts) } // Self is a paid mutator transaction binding the contract method 0xc62c692f. // // Solidity: function Self() returns() -func (_PrecompileTest *PrecompileTestTransactorSession) Self() (*types.Transaction, error) { - return _PrecompileTest.Contract.Self(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteTransactorSession) Self() (*types.Transaction, error) { + return _TestSuite.Contract.Self(&_TestSuite.TransactOpts) } // Transfer is a paid mutator transaction binding the contract method 0x406dade3. // // Solidity: function Transfer() returns() -func (_PrecompileTest *PrecompileTestTransactor) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "Transfer") +func (_TestSuite *TestSuiteTransactor) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "Transfer") } // Transfer is a paid mutator transaction binding the contract method 0x406dade3. // // Solidity: function Transfer() returns() -func (_PrecompileTest *PrecompileTestSession) Transfer() (*types.Transaction, error) { - return _PrecompileTest.Contract.Transfer(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteSession) Transfer() (*types.Transaction, error) { + return _TestSuite.Contract.Transfer(&_TestSuite.TransactOpts) } // Transfer is a paid mutator transaction binding the contract method 0x406dade3. // // Solidity: function Transfer() returns() -func (_PrecompileTest *PrecompileTestTransactorSession) Transfer() (*types.Transaction, error) { - return _PrecompileTest.Contract.Transfer(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteTransactorSession) Transfer() (*types.Transaction, error) { + return _TestSuite.Contract.Transfer(&_TestSuite.TransactOpts) } // View is a paid mutator transaction binding the contract method 0x1686f265. // // Solidity: function View() returns() -func (_PrecompileTest *PrecompileTestTransactor) View(opts *bind.TransactOpts) (*types.Transaction, error) { - return _PrecompileTest.contract.Transact(opts, "View") +func (_TestSuite *TestSuiteTransactor) View(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestSuite.contract.Transact(opts, "View") } // View is a paid mutator transaction binding the contract method 0x1686f265. // // Solidity: function View() returns() -func (_PrecompileTest *PrecompileTestSession) View() (*types.Transaction, error) { - return _PrecompileTest.Contract.View(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteSession) View() (*types.Transaction, error) { + return _TestSuite.Contract.View(&_TestSuite.TransactOpts) } // View is a paid mutator transaction binding the contract method 0x1686f265. // // Solidity: function View() returns() -func (_PrecompileTest *PrecompileTestTransactorSession) View() (*types.Transaction, error) { - return _PrecompileTest.Contract.View(&_PrecompileTest.TransactOpts) +func (_TestSuite *TestSuiteTransactorSession) View() (*types.Transaction, error) { + return _TestSuite.Contract.View(&_TestSuite.TransactOpts) } -// PrecompileTestCalledIterator is returned from FilterCalled and is used to iterate over the raw logs and unpacked data for Called events raised by the PrecompileTest contract. -type PrecompileTestCalledIterator struct { - Event *PrecompileTestCalled // Event containing the contract specifics and raw log +// TestSuiteCalledIterator is returned from FilterCalled and is used to iterate over the raw logs and unpacked data for Called events raised by the TestSuite contract. +type TestSuiteCalledIterator struct { + Event *TestSuiteCalled // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -454,7 +454,7 @@ type PrecompileTestCalledIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *PrecompileTestCalledIterator) Next() bool { +func (it *TestSuiteCalledIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -463,7 +463,7 @@ func (it *PrecompileTestCalledIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(PrecompileTestCalled) + it.Event = new(TestSuiteCalled) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -478,7 +478,7 @@ func (it *PrecompileTestCalledIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(PrecompileTestCalled) + it.Event = new(TestSuiteCalled) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -494,19 +494,19 @@ func (it *PrecompileTestCalledIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *PrecompileTestCalledIterator) Error() error { +func (it *TestSuiteCalledIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *PrecompileTestCalledIterator) Close() error { +func (it *TestSuiteCalledIterator) Close() error { it.sub.Unsubscribe() return nil } -// PrecompileTestCalled represents a Called event raised by the PrecompileTest contract. -type PrecompileTestCalled struct { +// TestSuiteCalled represents a Called event raised by the TestSuite contract. +type TestSuiteCalled struct { Arg0 string Raw types.Log // Blockchain specific contextual infos } @@ -514,21 +514,21 @@ type PrecompileTestCalled struct { // FilterCalled is a free log retrieval operation binding the contract event 0x3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a. // // Solidity: event Called(string func) -func (_PrecompileTest *PrecompileTestFilterer) FilterCalled(opts *bind.FilterOpts) (*PrecompileTestCalledIterator, error) { +func (_TestSuite *TestSuiteFilterer) FilterCalled(opts *bind.FilterOpts) (*TestSuiteCalledIterator, error) { - logs, sub, err := _PrecompileTest.contract.FilterLogs(opts, "Called") + logs, sub, err := _TestSuite.contract.FilterLogs(opts, "Called") if err != nil { return nil, err } - return &PrecompileTestCalledIterator{contract: _PrecompileTest.contract, event: "Called", logs: logs, sub: sub}, nil + return &TestSuiteCalledIterator{contract: _TestSuite.contract, event: "Called", logs: logs, sub: sub}, nil } // WatchCalled is a free log subscription operation binding the contract event 0x3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a. // // Solidity: event Called(string func) -func (_PrecompileTest *PrecompileTestFilterer) WatchCalled(opts *bind.WatchOpts, sink chan<- *PrecompileTestCalled) (event.Subscription, error) { +func (_TestSuite *TestSuiteFilterer) WatchCalled(opts *bind.WatchOpts, sink chan<- *TestSuiteCalled) (event.Subscription, error) { - logs, sub, err := _PrecompileTest.contract.WatchLogs(opts, "Called") + logs, sub, err := _TestSuite.contract.WatchLogs(opts, "Called") if err != nil { return nil, err } @@ -538,8 +538,8 @@ func (_PrecompileTest *PrecompileTestFilterer) WatchCalled(opts *bind.WatchOpts, select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(PrecompileTestCalled) - if err := _PrecompileTest.contract.UnpackLog(event, "Called", log); err != nil { + event := new(TestSuiteCalled) + if err := _TestSuite.contract.UnpackLog(event, "Called", log); err != nil { return err } event.Raw = log @@ -563,9 +563,9 @@ func (_PrecompileTest *PrecompileTestFilterer) WatchCalled(opts *bind.WatchOpts, // ParseCalled is a log parse operation binding the contract event 0x3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a. // // Solidity: event Called(string func) -func (_PrecompileTest *PrecompileTestFilterer) ParseCalled(log types.Log) (*PrecompileTestCalled, error) { - event := new(PrecompileTestCalled) - if err := _PrecompileTest.contract.UnpackLog(event, "Called", log); err != nil { +func (_TestSuite *TestSuiteFilterer) ParseCalled(log types.Log) (*TestSuiteCalled, error) { + event := new(TestSuiteCalled) + if err := _TestSuite.contract.UnpackLog(event, "Called", log); err != nil { return nil, err } event.Raw = log From 495011a741f255cfcefbc8e74d4dffa3c5e6124f Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 20 Dec 2024 19:29:29 +0000 Subject: [PATCH 16/22] test: assert reason for revert when paying non-payable --- libevm/precompilegen/precompile.go.tmpl | 10 ++++--- .../testprecompile/TestSuite.sol | 26 ++++++++++++++++--- .../precompilegen/testprecompile/generated.go | 10 ++++--- .../testprecompile/generated_test.go | 3 ++- .../testprecompile/suite.abigen_test.go | 8 +++--- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index c2963ba6f2b3..2256085e13d9 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -63,6 +63,8 @@ type precompile struct { impl Contract } +const revertBufferWhenNonPayableReceivesValue = "non-payable" + func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, error) { selector, ok := methods.FindSelector(input) if !ok { @@ -72,7 +74,7 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err switch m := methods[selector]; m.StateMutability { case "nonpayable": if !env.Value().IsZero() { - return nil, vm.RevertError("non-payable") + return []byte(revertBufferWhenNonPayableReceivesValue), vm.ErrExecutionReverted } case "payable": case "pure": @@ -80,8 +82,10 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err case "view": env.SetReadOnly() default: - // If this happens then `precompilegen` needs to be extended. - return nil, vm.RevertError(fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig)) + // If this happens then `precompilegen` needs to be extended because the + // Solidity ABI spec changed. + data := fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig) + return []byte(data), vm.ErrExecutionReverted } ret, err := dispatchers[selector](p.impl, env, input) diff --git a/libevm/precompilegen/testprecompile/TestSuite.sol b/libevm/precompilegen/testprecompile/TestSuite.sol index 49ae1b48d685..ab344ba6cfb2 100644 --- a/libevm/precompilegen/testprecompile/TestSuite.sol +++ b/libevm/precompilegen/testprecompile/TestSuite.sol @@ -7,8 +7,12 @@ import {IPrecompile} from "./IPrecompile.sol"; contract TestSuite { IPrecompile immutable precompile; - constructor(IPrecompile _precompile) payable { + /// @dev Expected revert buffer when paying a non-payable function. + string private _expectedNonPayableErrorMsg; + + constructor(IPrecompile _precompile, string memory nonPayableErrorMsg) payable { precompile = _precompile; + _expectedNonPayableErrorMsg = nonPayableErrorMsg; } /// @dev Emitted by each function to prove that it was successfully called. @@ -89,10 +93,24 @@ contract TestSuite { uint256 value = precompile.Payable{value: 42}(); assert(value == 42); - (bool ok,) = address(precompile).call{value: 42}(abi.encodeWithSelector(IPrecompile.NonPayable.selector)); - assert(!ok); - // TODO: DO NOT MERGE without checking the return data + callNonPayable(0, ""); + callNonPayable(1, abi.encodePacked(_expectedNonPayableErrorMsg)); emit Called("Transfer()"); } + + function callNonPayable(uint256 value, bytes memory expectRevertWith) internal { + // We can't use just call `precompile.NonPayable()` directly because + // (a) it's a precompile and (b) it doesn't return values, which means + // that Solidity will perform an EXTCODESIZE check first and revert. + bytes memory selector = abi.encodeWithSelector(IPrecompile.NonPayable.selector); + (bool ok, bytes memory ret) = address(precompile).call{value: value}(selector); + + if (expectRevertWith.length == 0) { + assert(ok); + } else { + assert(!ok); + assert(keccak256(ret) == keccak256(expectRevertWith)); + } + } } diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index 66d7460cd72a..402ae57af8f2 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -113,6 +113,8 @@ type precompile struct { impl Contract } +const revertBufferWhenNonPayableReceivesValue = "non-payable" + func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, error) { selector, ok := methods.FindSelector(input) if !ok { @@ -122,7 +124,7 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err switch m := methods[selector]; m.StateMutability { case "nonpayable": if !env.Value().IsZero() { - return nil, vm.RevertError("non-payable") + return []byte(revertBufferWhenNonPayableReceivesValue), vm.ErrExecutionReverted } case "payable": case "pure": @@ -130,8 +132,10 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err case "view": env.SetReadOnly() default: - // If this happens then `precompilegen` needs to be extended. - return nil, vm.RevertError(fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig)) + // If this happens then `precompilegen` needs to be extended because the + // Solidity ABI spec changed. + data := fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig) + return []byte(data), vm.ErrExecutionReverted } ret, err := dispatchers[selector](p.impl, env, input) diff --git a/libevm/precompilegen/testprecompile/generated_test.go b/libevm/precompilegen/testprecompile/generated_test.go index 40b02af2e58c..42d400a8bc83 100644 --- a/libevm/precompilegen/testprecompile/generated_test.go +++ b/libevm/precompilegen/testprecompile/generated_test.go @@ -13,6 +13,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see // . + package testprecompile import ( @@ -91,7 +92,7 @@ func TestGeneratedPrecompile(t *testing.T) { txOpts.Value = big.NewInt(1e9) client := sim.Client() - _, tx, test, err := DeployTestSuite(txOpts, client, precompile) + _, tx, test, err := DeployTestSuite(txOpts, client, precompile, revertBufferWhenNonPayableReceivesValue) require.NoError(t, err, "DeployTestSuite(...)") sim.Commit() successfulTxReceipt(ctx, t, client, tx) diff --git a/libevm/precompilegen/testprecompile/suite.abigen_test.go b/libevm/precompilegen/testprecompile/suite.abigen_test.go index f21ba1b4f3a0..ef70fd92ad1c 100644 --- a/libevm/precompilegen/testprecompile/suite.abigen_test.go +++ b/libevm/precompilegen/testprecompile/suite.abigen_test.go @@ -36,8 +36,8 @@ type IPrecompileWrapper struct { // TestSuiteMetaData contains all meta data concerning the TestSuite contract. var TestSuiteMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Transfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a0604052604051611d49380380611d49833981810160405281019061002591906100ce565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100f9565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61008c82610063565b9050919050565b5f61009d82610082565b9050919050565b6100ad81610093565b81146100b7575f5ffd5b50565b5f815190506100c8816100a4565b92915050565b5f602082840312156100e3576100e261005f565b5b5f6100f0848285016100ba565b91505092915050565b608051611bf26101575f395f81816101d2015281816102b101528181610356015281816104de015281816106420152818161077c0152818161086a015281816108a1015281816109b401528181610abf0152610c110152611bf25ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610d97565b6101cf565b005b6100d96102ae565b005b6100e3610490565b005b6100ff60048036038101906100fa9190610efe565b6104da565b005b61011b60048036038101906101169190610fb5565b610640565b005b61013760048036038101906101329190610efe565b610722565b005b610141610868565b005b61015d6004803603810190610158919061108f565b610987565b005b6101796004803603810190610174919061117d565b610a96565b005b610183610bc4565b005b610198631686f26560e01b60015f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c59061121e565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b8152600401610229919061124b565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102689190611278565b14610276576102756112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a39061131a565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103409190611278565b9050602a8114610353576103526112a3565b5b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16602a636fb1b0e960e01b604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610405919061138a565b5f6040518083038185875af1925050503d805f811461043f576040519150601f19603f3d011682016040523d82523d5f602084013e610444565b606091505b505090508015610457576104566112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610484906113ea565b60405180910390a15050565b6104a363a726300060e01b600180610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516104d090611452565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161052c91906114b8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610596919061138a565b5f604051808303815f865af19150503d805f81146105cf576040519150601f19603f3d011682016040523d82523d5f602084013e6105d4565b606091505b509150915081156105e8576105e76112a3565b5b8280519060200120818051906020012014610606576106056112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161063390611522565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016106999190611569565b602060405180830381865afa1580156106b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d89190611596565b815f0151146106ea576106e96112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107179061160b565b60405180910390a150565b5f5f8260405160240161073591906114b8565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516107bf919061138a565b5f60405180830381855afa9150503d805f81146107f7576040519150601f19603f3d011682016040523d82523d5f602084013e6107fc565b606091505b50915091508161080f5761080e6112a3565b5b828051906020012081805190602001201461082d5761082c6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161085a90611673565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610908573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061092c91906116a5565b73ffffffffffffffffffffffffffffffffffffffff16146109505761094f6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161097d9061171a565b60405180910390a1565b82828260405160200161099c939291906117bd565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610a0f93929190611817565b602060405180830381865afa158015610a2a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4e919061187f565b14610a5c57610a5b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610a89906118f4565b60405180910390a1505050565b80604051602001610aa79190611956565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610b1691906119a4565b5f60405180830381865afa158015610b30573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610b589190611a32565b604051602001610b689190611956565b6040516020818303038152906040528051906020012014610b8c57610b8b6112a3565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610bb990611ac3565b60405180910390a150565b610bd663f5ad2fb860e01b5f5f610c0d565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610c0390611b2b565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610cb7919061138a565b5f604051808303815f865af19150503d805f8114610cf0576040519150601f19603f3d011682016040523d82523d5f602084013e610cf5565b606091505b509150915081610d0857610d076112a3565b5b5f5f82806020019051810190610d1e9190611b7e565b9150915085151582151514610d3657610d356112a3565b5b84151581151514610d4a57610d496112a3565b5b50505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610d7681610d64565b8114610d80575f5ffd5b50565b5f81359050610d9181610d6d565b92915050565b5f60208284031215610dac57610dab610d5c565b5b5f610db984828501610d83565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610e1082610dca565b810181811067ffffffffffffffff82111715610e2f57610e2e610dda565b5b80604052505050565b5f610e41610d53565b9050610e4d8282610e07565b919050565b5f67ffffffffffffffff821115610e6c57610e6b610dda565b5b610e7582610dca565b9050602081019050919050565b828183375f83830152505050565b5f610ea2610e9d84610e52565b610e38565b905082815260208101848484011115610ebe57610ebd610dc6565b5b610ec9848285610e82565b509392505050565b5f82601f830112610ee557610ee4610dc2565b5b8135610ef5848260208601610e90565b91505092915050565b5f60208284031215610f1357610f12610d5c565b5b5f82013567ffffffffffffffff811115610f3057610f2f610d60565b5b610f3c84828501610ed1565b91505092915050565b5f5ffd5b5f819050919050565b610f5b81610f49565b8114610f65575f5ffd5b50565b5f81359050610f7681610f52565b92915050565b5f60208284031215610f9157610f90610f45565b5b610f9b6020610e38565b90505f610faa84828501610f68565b5f8301525092915050565b5f60208284031215610fca57610fc9610d5c565b5b5f610fd784828501610f7c565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61101481610fe0565b811461101e575f5ffd5b50565b5f8135905061102f8161100b565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61105e82611035565b9050919050565b61106e81611054565b8114611078575f5ffd5b50565b5f8135905061108981611065565b92915050565b5f5f5f606084860312156110a6576110a5610d5c565b5b5f6110b386828701610d83565b93505060206110c486828701611021565b92505060406110d58682870161107b565b9150509250925092565b5f67ffffffffffffffff8211156110f9576110f8610dda565b5b61110282610dca565b9050602081019050919050565b5f61112161111c846110df565b610e38565b90508281526020810184848401111561113d5761113c610dc6565b5b611148848285610e82565b509392505050565b5f82601f83011261116457611163610dc2565b5b813561117484826020860161110f565b91505092915050565b5f6020828403121561119257611191610d5c565b5b5f82013567ffffffffffffffff8111156111af576111ae610d60565b5b6111bb84828501611150565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f6112086006836111c4565b9150611213826111d4565b602082019050919050565b5f6020820190508181035f830152611235816111fc565b9050919050565b61124581610d64565b82525050565b5f60208201905061125e5f83018461123c565b92915050565b5f8151905061127281610d6d565b92915050565b5f6020828403121561128d5761128c610d5c565b5b5f61129a84828501611264565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f611304600d836111c4565b915061130f826112d0565b602082019050919050565b5f6020820190508181035f830152611331816112f8565b9050919050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f61136482611338565b61136e8185611342565b935061137e81856020860161134c565b80840191505092915050565b5f611395828461135a565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f6113d4600a836111c4565b91506113df826113a0565b602082019050919050565b5f6020820190508181035f830152611401816113c8565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61143c6014836111c4565b915061144782611408565b602082019050919050565b5f6020820190508181035f83015261146981611430565b9050919050565b5f82825260208201905092915050565b5f61148a82611338565b6114948185611470565b93506114a481856020860161134c565b6114ad81610dca565b840191505092915050565b5f6020820190508181035f8301526114d08184611480565b905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f61150c600f836111c4565b9150611517826114d8565b602082019050919050565b5f6020820190508181035f83015261153981611500565b9050919050565b61154981610f49565b82525050565b602082015f8201516115635f850182611540565b50505050565b5f60208201905061157c5f83018461154f565b92915050565b5f8151905061159081610f52565b92915050565b5f602082840312156115ab576115aa610d5c565b5b5f6115b884828501611582565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f6115f5600c836111c4565b9150611600826115c1565b602082019050919050565b5f6020820190508181035f830152611622816115e9565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f61165d6014836111c4565b915061166882611629565b602082019050919050565b5f6020820190508181035f83015261168a81611651565b9050919050565b5f8151905061169f81611065565b92915050565b5f602082840312156116ba576116b9610d5c565b5b5f6116c784828501611691565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6117046006836111c4565b915061170f826116d0565b602082019050919050565b5f6020820190508181035f830152611731816116f8565b9050919050565b5f819050919050565b61175261174d82610d64565b611738565b82525050565b5f819050919050565b61177261176d82610fe0565b611758565b82525050565b5f8160601b9050919050565b5f61178e82611778565b9050919050565b5f61179f82611784565b9050919050565b6117b76117b282611054565b611795565b82525050565b5f6117c88286611741565b6020820191506117d88285611761565b6002820191506117e882846117a6565b601482019150819050949350505050565b61180281610fe0565b82525050565b61181181611054565b82525050565b5f60608201905061182a5f83018661123c565b61183760208301856117f9565b6118446040830184611808565b949350505050565b5f819050919050565b61185e8161184c565b8114611868575f5ffd5b50565b5f8151905061187981611855565b92915050565b5f6020828403121561189457611893610d5c565b5b5f6118a18482850161186b565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f6118de600f836111c4565b91506118e9826118aa565b602082019050919050565b5f6020820190508181035f83015261190b816118d2565b9050919050565b5f81519050919050565b5f81905092915050565b5f61193082611912565b61193a818561191c565b935061194a81856020860161134c565b80840191505092915050565b5f6119618284611926565b915081905092915050565b5f61197682611912565b61198081856111c4565b935061199081856020860161134c565b61199981610dca565b840191505092915050565b5f6020820190508181035f8301526119bc818461196c565b905092915050565b5f6119d66119d1846110df565b610e38565b9050828152602081018484840111156119f2576119f1610dc6565b5b6119fd84828561134c565b509392505050565b5f82601f830112611a1957611a18610dc2565b5b8151611a298482602086016119c4565b91505092915050565b5f60208284031215611a4757611a46610d5c565b5b5f82015167ffffffffffffffff811115611a6457611a63610d60565b5b611a7084828501611a05565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611aad600c836111c4565b9150611ab882611a79565b602082019050919050565b5f6020820190508181035f830152611ada81611aa1565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611b156006836111c4565b9150611b2082611ae1565b602082019050919050565b5f6020820190508181035f830152611b4281611b09565b9050919050565b5f8115159050919050565b611b5d81611b49565b8114611b67575f5ffd5b50565b5f81519050611b7881611b54565b92915050565b5f5f60408385031215611b9457611b93610d5c565b5b5f611ba185828601611b6a565b9250506020611bb285828601611b6a565b915050925092905056fea2646970667358221220a17f2af7577357b66480c1cde39be2a37f66d1ac61be6fdd33d4fc9936e7f34264736f6c634300081c0033", + ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nonPayableErrorMsg\",\"type\":\"string\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Transfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60a060405260405161233c38038061233c83398181016040528101906100259190610227565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050805f90816100679190610491565b505050610560565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a982610080565b9050919050565b5f6100ba8261009f565b9050919050565b6100ca816100b0565b81146100d4575f5ffd5b50565b5f815190506100e5816100c1565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610139826100f3565b810181811067ffffffffffffffff8211171561015857610157610103565b5b80604052505050565b5f61016a61006f565b90506101768282610130565b919050565b5f67ffffffffffffffff82111561019557610194610103565b5b61019e826100f3565b9050602081019050919050565b8281835e5f83830152505050565b5f6101cb6101c68461017b565b610161565b9050828152602081018484840111156101e7576101e66100ef565b5b6101f28482856101ab565b509392505050565b5f82601f83011261020e5761020d6100eb565b5b815161021e8482602086016101b9565b91505092915050565b5f5f6040838503121561023d5761023c610078565b5b5f61024a858286016100d7565b925050602083015167ffffffffffffffff81111561026b5761026a61007c565b5b610277858286016101fa565b9150509250929050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806102cf57607f821691505b6020821081036102e2576102e161028b565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026103447fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610309565b61034e8683610309565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61039261038d61038884610366565b61036f565b610366565b9050919050565b5f819050919050565b6103ab83610378565b6103bf6103b782610399565b848454610315565b825550505050565b5f5f905090565b6103d66103c7565b6103e18184846103a2565b505050565b5b81811015610404576103f95f826103ce565b6001810190506103e7565b5050565b601f8211156104495761041a816102e8565b610423846102fa565b81016020851015610432578190505b61044661043e856102fa565b8301826103e6565b50505b505050565b5f82821c905092915050565b5f6104695f198460080261044e565b1980831691505092915050565b5f610481838361045a565b9150826002028217905092915050565b61049a82610281565b67ffffffffffffffff8111156104b3576104b2610103565b5b6104bd82546102b8565b6104c8828285610408565b5f60209050601f8311600181146104f9575f84156104e7578287015190505b6104f18582610476565b865550610558565b601f198416610507866102e8565b5f5b8281101561052e57848901518255600182019150602085019450602081019050610509565b8683101561054b5784890151610547601f89168261045a565b8355505b6001600288020188555050505b505050505050565b608051611d7e6105be5f395f81816101d2015281816102b10152818161041b0152818161057f015281816106b9015281816107a7015281816107de015281816108f1015281816109fc01528181610b4e0152610d020152611d7e5ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610e1e565b6101cf565b005b6100d96102ae565b005b6100e36103cd565b005b6100ff60048036038101906100fa9190610f85565b610417565b005b61011b6004803603810190610116919061103c565b61057d565b005b61013760048036038101906101329190610f85565b61065f565b005b6101416107a5565b005b61015d60048036038101906101589190611116565b6108c4565b005b61017960048036038101906101749190611204565b6109d3565b005b610183610b01565b005b610198631686f26560e01b60015f610b4a565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c5906112a5565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161022991906112d2565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061026891906112ff565b146102765761027561132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a3906113a1565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061034091906112ff565b9050602a81146103535761035261132a565b5b61036b5f60405180602001604052805f815250610c90565b61039560015f60405160200161038191906114b8565b604051602081830303815290604052610c90565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516103c290611518565b60405180910390a150565b6103e063a726300060e01b600180610b4a565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161040d90611580565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161046991906115fe565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104d39190611658565b5f604051808303815f865af19150503d805f811461050c576040519150601f19603f3d011682016040523d82523d5f602084013e610511565b606091505b509150915081156105255761052461132a565b5b82805190602001208180519060200120146105435761054261132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610570906116b8565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016105d691906116ff565b602060405180830381865afa1580156105f1573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610615919061172c565b815f0151146106275761062661132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610654906117a1565b60405180910390a150565b5f5f8260405160240161067291906115fe565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516106fc9190611658565b5f60405180830381855afa9150503d805f8114610734576040519150601f19603f3d011682016040523d82523d5f602084013e610739565b606091505b50915091508161074c5761074b61132a565b5b828051906020012081805190602001201461076a5761076961132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161079790611809565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610845573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610869919061183b565b73ffffffffffffffffffffffffffffffffffffffff161461088d5761088c61132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108ba906118b0565b60405180910390a1565b8282826040516020016108d993929190611953565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161094c939291906119ad565b602060405180830381865afa158015610967573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098b9190611a15565b146109995761099861132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516109c690611a8a565b60405180910390a1505050565b806040516020016109e49190611ae2565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610a539190611b30565b5f60405180830381865afa158015610a6d573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610a959190611bbe565b604051602001610aa59190611ae2565b6040516020818303038152906040528051906020012014610ac957610ac861132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610af690611c4f565b60405180910390a150565b610b1363f5ad2fb860e01b5f5f610b4a565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610b4090611cb7565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610bf49190611658565b5f604051808303815f865af19150503d805f8114610c2d576040519150601f19603f3d011682016040523d82523d5f602084013e610c32565b606091505b509150915081610c4557610c4461132a565b5b5f5f82806020019051810190610c5b9190611d0a565b9150915085151582151514610c7357610c7261132a565b5b84151581151514610c8757610c8661132a565b5b50505050505050565b5f636fb1b0e960e01b604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168584604051610d469190611658565b5f6040518083038185875af1925050503d805f8114610d80576040519150601f19603f3d011682016040523d82523d5f602084013e610d85565b606091505b50915091505f845103610da55781610da057610d9f61132a565b5b610dd3565b8115610db457610db361132a565b5b8380519060200120818051906020012014610dd257610dd161132a565b5b5b5050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610dfd81610deb565b8114610e07575f5ffd5b50565b5f81359050610e1881610df4565b92915050565b5f60208284031215610e3357610e32610de3565b5b5f610e4084828501610e0a565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610e9782610e51565b810181811067ffffffffffffffff82111715610eb657610eb5610e61565b5b80604052505050565b5f610ec8610dda565b9050610ed48282610e8e565b919050565b5f67ffffffffffffffff821115610ef357610ef2610e61565b5b610efc82610e51565b9050602081019050919050565b828183375f83830152505050565b5f610f29610f2484610ed9565b610ebf565b905082815260208101848484011115610f4557610f44610e4d565b5b610f50848285610f09565b509392505050565b5f82601f830112610f6c57610f6b610e49565b5b8135610f7c848260208601610f17565b91505092915050565b5f60208284031215610f9a57610f99610de3565b5b5f82013567ffffffffffffffff811115610fb757610fb6610de7565b5b610fc384828501610f58565b91505092915050565b5f5ffd5b5f819050919050565b610fe281610fd0565b8114610fec575f5ffd5b50565b5f81359050610ffd81610fd9565b92915050565b5f6020828403121561101857611017610fcc565b5b6110226020610ebf565b90505f61103184828501610fef565b5f8301525092915050565b5f6020828403121561105157611050610de3565b5b5f61105e84828501611003565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61109b81611067565b81146110a5575f5ffd5b50565b5f813590506110b681611092565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6110e5826110bc565b9050919050565b6110f5816110db565b81146110ff575f5ffd5b50565b5f81359050611110816110ec565b92915050565b5f5f5f6060848603121561112d5761112c610de3565b5b5f61113a86828701610e0a565b935050602061114b868287016110a8565b925050604061115c86828701611102565b9150509250925092565b5f67ffffffffffffffff8211156111805761117f610e61565b5b61118982610e51565b9050602081019050919050565b5f6111a86111a384611166565b610ebf565b9050828152602081018484840111156111c4576111c3610e4d565b5b6111cf848285610f09565b509392505050565b5f82601f8301126111eb576111ea610e49565b5b81356111fb848260208601611196565b91505092915050565b5f6020828403121561121957611218610de3565b5b5f82013567ffffffffffffffff81111561123657611235610de7565b5b611242848285016111d7565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f61128f60068361124b565b915061129a8261125b565b602082019050919050565b5f6020820190508181035f8301526112bc81611283565b9050919050565b6112cc81610deb565b82525050565b5f6020820190506112e55f8301846112c3565b92915050565b5f815190506112f981610df4565b92915050565b5f6020828403121561131457611313610de3565b5b5f611321848285016112eb565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f61138b600d8361124b565b915061139682611357565b602082019050919050565b5f6020820190508181035f8301526113b88161137f565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061140357607f821691505b602082108103611416576114156113bf565b5b50919050565b5f81905092915050565b5f819050815f5260205f209050919050565b5f8154611444816113ec565b61144e818661141c565b9450600182165f8114611468576001811461147d576114af565b60ff19831686528115158202860193506114af565b61148685611426565b5f5b838110156114a757815481890152600182019150602081019050611488565b838801955050505b50505092915050565b5f6114c38284611438565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f611502600a8361124b565b915061150d826114ce565b602082019050919050565b5f6020820190508181035f83015261152f816114f6565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61156a60148361124b565b915061157582611536565b602082019050919050565b5f6020820190508181035f8301526115978161155e565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f6115d08261159e565b6115da81856115a8565b93506115ea8185602086016115b8565b6115f381610e51565b840191505092915050565b5f6020820190508181035f83015261161681846115c6565b905092915050565b5f81905092915050565b5f6116328261159e565b61163c818561161e565b935061164c8185602086016115b8565b80840191505092915050565b5f6116638284611628565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f6116a2600f8361124b565b91506116ad8261166e565b602082019050919050565b5f6020820190508181035f8301526116cf81611696565b9050919050565b6116df81610fd0565b82525050565b602082015f8201516116f95f8501826116d6565b50505050565b5f6020820190506117125f8301846116e5565b92915050565b5f8151905061172681610fd9565b92915050565b5f6020828403121561174157611740610de3565b5b5f61174e84828501611718565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f61178b600c8361124b565b915061179682611757565b602082019050919050565b5f6020820190508181035f8301526117b88161177f565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6117f360148361124b565b91506117fe826117bf565b602082019050919050565b5f6020820190508181035f830152611820816117e7565b9050919050565b5f81519050611835816110ec565b92915050565b5f602082840312156118505761184f610de3565b5b5f61185d84828501611827565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f61189a60068361124b565b91506118a582611866565b602082019050919050565b5f6020820190508181035f8301526118c78161188e565b9050919050565b5f819050919050565b6118e86118e382610deb565b6118ce565b82525050565b5f819050919050565b61190861190382611067565b6118ee565b82525050565b5f8160601b9050919050565b5f6119248261190e565b9050919050565b5f6119358261191a565b9050919050565b61194d611948826110db565b61192b565b82525050565b5f61195e82866118d7565b60208201915061196e82856118f7565b60028201915061197e828461193c565b601482019150819050949350505050565b61199881611067565b82525050565b6119a7816110db565b82525050565b5f6060820190506119c05f8301866112c3565b6119cd602083018561198f565b6119da604083018461199e565b949350505050565b5f819050919050565b6119f4816119e2565b81146119fe575f5ffd5b50565b5f81519050611a0f816119eb565b92915050565b5f60208284031215611a2a57611a29610de3565b5b5f611a3784828501611a01565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f611a74600f8361124b565b9150611a7f82611a40565b602082019050919050565b5f6020820190508181035f830152611aa181611a68565b9050919050565b5f81519050919050565b5f611abc82611aa8565b611ac6818561141c565b9350611ad68185602086016115b8565b80840191505092915050565b5f611aed8284611ab2565b915081905092915050565b5f611b0282611aa8565b611b0c818561124b565b9350611b1c8185602086016115b8565b611b2581610e51565b840191505092915050565b5f6020820190508181035f830152611b488184611af8565b905092915050565b5f611b62611b5d84611166565b610ebf565b905082815260208101848484011115611b7e57611b7d610e4d565b5b611b898482856115b8565b509392505050565b5f82601f830112611ba557611ba4610e49565b5b8151611bb5848260208601611b50565b91505092915050565b5f60208284031215611bd357611bd2610de3565b5b5f82015167ffffffffffffffff811115611bf057611bef610de7565b5b611bfc84828501611b91565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611c39600c8361124b565b9150611c4482611c05565b602082019050919050565b5f6020820190508181035f830152611c6681611c2d565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611ca160068361124b565b9150611cac82611c6d565b602082019050919050565b5f6020820190508181035f830152611cce81611c95565b9050919050565b5f8115159050919050565b611ce981611cd5565b8114611cf3575f5ffd5b50565b5f81519050611d0481611ce0565b92915050565b5f5f60408385031215611d2057611d1f610de3565b5b5f611d2d85828601611cf6565b9250506020611d3e85828601611cf6565b915050925092905056fea26469706673582212203f8f80491d9ec37e8b661dc7940f888a634de87866cea3d27267b7366c437dc964736f6c634300081c0033", } // TestSuiteABI is the input ABI used to generate the binding from. @@ -49,7 +49,7 @@ var TestSuiteABI = TestSuiteMetaData.ABI var TestSuiteBin = TestSuiteMetaData.Bin // DeployTestSuite deploys a new Ethereum contract, binding an instance of TestSuite to it. -func DeployTestSuite(auth *bind.TransactOpts, backend bind.ContractBackend, _precompile common.Address) (common.Address, *types.Transaction, *TestSuite, error) { +func DeployTestSuite(auth *bind.TransactOpts, backend bind.ContractBackend, _precompile common.Address, nonPayableErrorMsg string) (common.Address, *types.Transaction, *TestSuite, error) { parsed, err := TestSuiteMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -58,7 +58,7 @@ func DeployTestSuite(auth *bind.TransactOpts, backend bind.ContractBackend, _pre return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(TestSuiteBin), backend, _precompile) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(TestSuiteBin), backend, _precompile, nonPayableErrorMsg) if err != nil { return common.Address{}, nil, nil, err } From e494e60368fb0fd6ce6016d98b9e42bb07e14d4b Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 24 Dec 2024 12:08:58 +0000 Subject: [PATCH 17/22] refactor!: fine-grained mutability instead of boolean `ReadOnly()` --- core/vm/contracts.libevm.go | 53 +++++++++++++----- core/vm/contracts.libevm_test.go | 54 ++++++++++--------- core/vm/environment.libevm.go | 44 +++++++++++---- libevm/precompilegen/precompile.go.tmpl | 4 +- .../precompilegen/testprecompile/generated.go | 4 +- 5 files changed, 109 insertions(+), 50 deletions(-) diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index 7c866bfa6de9..67537a820678 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -88,6 +88,32 @@ func (t CallType) OpCode() OpCode { return INVALID } +// StateMutability describes the available state access. +type StateMutability uint + +const ( + unknownStateMutability StateMutability = iota + MutableState + // ReadOnlyState is equivalent to Solidity's "view". + ReadOnlyState + // Pure is a Solidity concept disallowing all access, read or write, to + // state. + Pure +) + +// String returns a human-readable representation of the StateMutability. +func (m StateMutability) String() string { + switch m { + case MutableState: + return "mutable" + case ReadOnlyState: + return "read-only" + case Pure: + return "no state access" + } + return fmt.Sprintf("unknown %T(%[1]d)", m) +} + // run runs the [PrecompiledContract], differentiating between stateful and // regular types, updating `args.gasRemaining` in the stateful case. func (args *evmCallArgs) run(p PrecompiledContract, input []byte) (ret []byte, err error) { @@ -141,21 +167,24 @@ func (p statefulPrecompile) Run([]byte) ([]byte, error) { type PrecompileEnvironment interface { ChainConfig() *params.ChainConfig Rules() params.Rules - // StateDB will be non-nil i.f.f !ReadOnly(). + // StateDB will be non-nil i.f.f StateMutability() returns [MutableState]. StateDB() StateDB - // ReadOnlyState will be non-nil i.f.f. SetPure() has not been called. + // ReadOnlyState will be non-nil i.f.f. StateMutability() does not return + // [Pure]. ReadOnlyState() libevm.StateReader - // SetReadOnly ensures that all future calls to ReadOnly() will return true. - // Is can be used as a guard against accidental writes when a read-only - // function is invoked with EVM call() instead of staticcall(). - SetReadOnly() - // SetPure ensures that all future calls to ReadOnly() will return true and - // that calls to ReadOnlyState() will return nil. - // TODO(arr4n) DO NOT MERGE: change this and SetReadOnly to return new - // environments. - SetPure() - ReadOnly() bool + // StateMutability can infer [MutableState] vs [ReadOnlyState] based on EVM + // context, but [Pure] is a Solidity concept that is enforced by user code. + StateMutability() StateMutability + // AsReadOnly returns a copy of the current environment for which + // StateMutability() returns [ReadOnlyState]. It can be used as a guard + // against accidental writes when a read-only function is invoked with EVM + // call() instead of staticcall(). + AsReadOnly() PrecompileEnvironment + // AsPure returns a copy of the current environment that has no access to + // state; i.e. StateMutability() returns [Pure]. All calls to both StateDB() + // and ReadOnlyState() will return nil. + AsPure() PrecompileEnvironment IncomingCallType() CallType Addresses() *libevm.AddressContext diff --git a/core/vm/contracts.libevm_test.go b/core/vm/contracts.libevm_test.go index 1bb98fac2fa0..6b9fbb8318a6 100644 --- a/core/vm/contracts.libevm_test.go +++ b/core/vm/contracts.libevm_test.go @@ -108,7 +108,7 @@ type statefulPrecompileOutput struct { Addresses *libevm.AddressContext StateValue common.Hash ValueReceived *uint256.Int - ReadOnly bool + Mutability vm.StateMutability BlockNumber, Difficulty *big.Int BlockTime uint64 Input []byte @@ -149,8 +149,8 @@ func TestNewStatefulPrecompile(t *testing.T) { gasCost := rng.Uint64n(gasLimit) run := func(env vm.PrecompileEnvironment, input []byte, suppliedGas uint64) ([]byte, uint64, error) { - if got, want := env.StateDB() != nil, !env.ReadOnly(); got != want { - return nil, 0, fmt.Errorf("PrecompileEnvironment().StateDB() must be non-nil i.f.f. not read-only; got non-nil? %t; want %t", got, want) + if got, want := env.StateDB() != nil, env.StateMutability() == vm.MutableState; got != want { + return nil, 0, fmt.Errorf("PrecompileEnvironment().StateDB() must be non-nil i.f.f. state is mutable; got non-nil? %t; want %t", got, want) } hdr, err := env.BlockHeader() if err != nil { @@ -162,7 +162,7 @@ func TestNewStatefulPrecompile(t *testing.T) { Addresses: env.Addresses(), StateValue: env.ReadOnlyState().GetState(precompile, slot), ValueReceived: env.Value(), - ReadOnly: env.ReadOnly(), + Mutability: env.StateMutability(), BlockNumber: env.BlockNumber(), BlockTime: env.BlockTime(), Difficulty: hdr.Difficulty, @@ -216,8 +216,8 @@ func TestNewStatefulPrecompile(t *testing.T) { wantTransferValue *uint256.Int // Note that this only covers evm.readOnly being true because of the // precompile's call. See TestInheritReadOnly for alternate case. - wantReadOnly bool - wantCallType vm.CallType + wantMutability vm.StateMutability + wantCallType vm.CallType }{ { name: "EVM.Call()", @@ -229,7 +229,7 @@ func TestNewStatefulPrecompile(t *testing.T) { Caller: caller, Self: precompile, }, - wantReadOnly: false, + wantMutability: vm.MutableState, wantTransferValue: transferValue, wantCallType: vm.Call, }, @@ -243,7 +243,7 @@ func TestNewStatefulPrecompile(t *testing.T) { Caller: caller, Self: caller, }, - wantReadOnly: false, + wantMutability: vm.MutableState, wantTransferValue: transferValue, wantCallType: vm.CallCode, }, @@ -257,7 +257,7 @@ func TestNewStatefulPrecompile(t *testing.T) { Caller: eoa, // inherited from caller Self: caller, }, - wantReadOnly: false, + wantMutability: vm.MutableState, wantTransferValue: uint256.NewInt(0), wantCallType: vm.DelegateCall, }, @@ -271,7 +271,7 @@ func TestNewStatefulPrecompile(t *testing.T) { Caller: caller, Self: precompile, }, - wantReadOnly: true, + wantMutability: vm.ReadOnlyState, wantTransferValue: uint256.NewInt(0), wantCallType: vm.StaticCall, }, @@ -284,7 +284,7 @@ func TestNewStatefulPrecompile(t *testing.T) { Addresses: tt.wantAddresses, StateValue: stateValue, ValueReceived: tt.wantTransferValue, - ReadOnly: tt.wantReadOnly, + Mutability: tt.wantMutability, BlockNumber: header.Number, BlockTime: header.Time, Difficulty: header.Difficulty, @@ -334,7 +334,7 @@ func TestInheritReadOnly(t *testing.T) { PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ precompile: vm.NewStatefulPrecompile( func(env vm.PrecompileEnvironment, input []byte) ([]byte, error) { - if env.ReadOnly() { + if env.StateMutability() != vm.MutableState { return []byte{ifReadOnly}, nil } return []byte{ifNotReadOnly}, nil @@ -560,9 +560,9 @@ func TestPrecompileMakeCall(t *testing.T) { }), dest: vm.NewStatefulPrecompile(func(env vm.PrecompileEnvironment, input []byte) (ret []byte, err error) { out := &statefulPrecompileOutput{ - Addresses: env.Addresses(), - ReadOnly: env.ReadOnly(), - Input: input, // expected to be callData + Addresses: env.Addresses(), + Mutability: env.StateMutability(), + Input: input, // expected to be callData } return out.Bytes(), nil }), @@ -591,7 +591,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: sut, Self: dest, }, - Input: precompileCallData, + Input: precompileCallData, + Mutability: vm.MutableState, }, }, { @@ -603,7 +604,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: caller, // overridden by CallOption Self: dest, }, - Input: precompileCallData, + Input: precompileCallData, + Mutability: vm.MutableState, }, }, { @@ -614,7 +616,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: caller, // SUT runs as its own caller because of CALLCODE Self: dest, }, - Input: precompileCallData, + Input: precompileCallData, + Mutability: vm.MutableState, }, }, { @@ -626,7 +629,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: caller, // CallOption is a NOOP Self: dest, }, - Input: precompileCallData, + Input: precompileCallData, + Mutability: vm.MutableState, }, }, { @@ -637,7 +641,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: caller, // as with CALLCODE Self: dest, }, - Input: precompileCallData, + Input: precompileCallData, + Mutability: vm.MutableState, }, }, { @@ -649,7 +654,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: caller, // CallOption is a NOOP Self: dest, }, - Input: precompileCallData, + Input: precompileCallData, + Mutability: vm.MutableState, }, }, { @@ -665,7 +671,7 @@ func TestPrecompileMakeCall(t *testing.T) { // (non-static) CALL, the read-only state is inherited. Yes, // this is _another_ way to get a read-only state, different to // the other tests. - ReadOnly: true, + Mutability: vm.ReadOnlyState, }, }, { @@ -677,8 +683,8 @@ func TestPrecompileMakeCall(t *testing.T) { Caller: caller, // overridden by CallOption Self: dest, }, - Input: precompileCallData, - ReadOnly: true, + Input: precompileCallData, + Mutability: vm.ReadOnlyState, }, }, } diff --git a/core/vm/environment.libevm.go b/core/vm/environment.libevm.go index df7f8b9b24d9..1ee34ad18ca1 100644 --- a/core/vm/environment.libevm.go +++ b/core/vm/environment.libevm.go @@ -17,6 +17,7 @@ package vm import ( + "errors" "fmt" "math/big" @@ -39,6 +40,12 @@ type environment struct { view, pure bool } +func (e *environment) copy() *environment { + // This deliberately does not use field names so that a change in the fields + // will break this code and force it to be reviewed. + return &environment{e.evm, e.self, e.callType, e.view, e.pure} +} + func (e *environment) Gas() uint64 { return e.self.Gas } func (e *environment) UseGas(gas uint64) bool { return e.self.UseGas(gas) } func (e *environment) Value() *uint256.Int { return new(uint256.Int).Set(e.self.Value()) } @@ -58,10 +65,19 @@ func (e *environment) refundGas(add uint64) error { return nil } -func (e *environment) SetReadOnly() { e.view = true } -func (e *environment) SetPure() { e.pure = true } +func (e *environment) AsReadOnly() PrecompileEnvironment { + cp := e.copy() + cp.view = true + return cp +} + +func (e *environment) AsPure() PrecompileEnvironment { + cp := e.copy() + cp.pure = true + return cp +} -func (e *environment) ReadOnly() bool { +func (e *environment) StateMutability() StateMutability { // A switch statement provides clearer code coverage for difficult-to-test // cases. switch { @@ -69,13 +85,15 @@ func (e *environment) ReadOnly() bool { // evm.interpreter.readOnly is only set to true via a call to // EVMInterpreter.Run() so, if a precompile is called directly with // StaticCall(), then readOnly might not be set yet. - return true + return ReadOnlyState case e.evm.interpreter.readOnly: - return true - case e.view || e.pure: - return true + return ReadOnlyState + case e.view: + return ReadOnlyState + case e.pure: + return Pure default: - return false + return MutableState } } @@ -87,7 +105,7 @@ func (e *environment) ReadOnlyState() libevm.StateReader { } func (e *environment) StateDB() StateDB { - if e.ReadOnly() { + if e.StateMutability() != MutableState { return nil } return e.evm.StateDB @@ -117,7 +135,13 @@ func (e *environment) Call(addr common.Address, input []byte, gas uint64, value return e.callContract(Call, addr, input, gas, value, opts...) } +var errPureFunctionMakeCall = errors.New("contract call from pure function") + func (e *environment) callContract(typ CallType, addr common.Address, input []byte, gas uint64, value *uint256.Int, opts ...CallOption) (retData []byte, retErr error) { + if e.StateMutability() == Pure { + return nil, errPureFunctionMakeCall + } + // Depth and read-only setting are handled by [EVMInterpreter.Run], which // isn't used for precompiles, so we need to do it ourselves to maintain the // expected invariants. @@ -126,7 +150,7 @@ func (e *environment) callContract(typ CallType, addr common.Address, input []by in.evm.depth++ defer func() { in.evm.depth-- }() - if e.ReadOnly() && !in.readOnly { // i.e. the precompile was StaticCall()ed + if e.StateMutability() != MutableState && !in.readOnly { // i.e. the precompile was StaticCall()ed in.readOnly = true defer func() { in.readOnly = false }() } diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index 2256085e13d9..ce7069f6e368 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -78,9 +78,9 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err } case "payable": case "pure": - env.SetPure() + env = env.AsPure() case "view": - env.SetReadOnly() + env = env.AsReadOnly() default: // If this happens then `precompilegen` needs to be extended because the // Solidity ABI spec changed. diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index 402ae57af8f2..59a96d329b8d 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -128,9 +128,9 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err } case "payable": case "pure": - env.SetPure() + env = env.AsPure() case "view": - env.SetReadOnly() + env = env.AsReadOnly() default: // If this happens then `precompilegen` needs to be extended because the // Solidity ABI spec changed. From f33c3397f5f69ebd17129ab6001f64dbcbc9d288 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 24 Dec 2024 12:11:21 +0000 Subject: [PATCH 18/22] fix: comment typo --- accounts/abi/selector.libevm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/abi/selector.libevm.go b/accounts/abi/selector.libevm.go index 6405bb7c6ac6..e7b0ddfd03b6 100644 --- a/accounts/abi/selector.libevm.go +++ b/accounts/abi/selector.libevm.go @@ -50,7 +50,7 @@ func (m Method) Selector() Selector { // representation. The key MUST be equivalent to the value's [Method.Selector]. type MethodsBySelector map[Selector]Method -// BySelector returns the the [Method]s keyed by their Selectors. +// MethodsBySelector returns the [Method]s keyed by their Selectors. func (a *ABI) MethodsBySelector() MethodsBySelector { ms := make(MethodsBySelector) for _, m := range a.Methods { From 7a5c68f65ac8f8923bcf85fbdcad559ce2d55efd Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 24 Dec 2024 12:21:42 +0000 Subject: [PATCH 19/22] doc: make `godoc` place `CallType` consts with the type --- core/vm/contracts.libevm.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index 67537a820678..91a84906a6a5 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -57,10 +57,10 @@ type evmCallArgs struct { type CallType OpCode const ( - Call = CallType(CALL) - CallCode = CallType(CALLCODE) - DelegateCall = CallType(DELEGATECALL) - StaticCall = CallType(STATICCALL) + Call CallType = CallType(CALL) + CallCode CallType = CallType(CALLCODE) + DelegateCall CallType = CallType(DELEGATECALL) + StaticCall CallType = CallType(STATICCALL) ) func (t CallType) isValid() bool { From ecac678c53c7cfd3978232bc40255d35c1d12e9c Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 24 Dec 2024 13:05:39 +0000 Subject: [PATCH 20/22] test: `PrecompileEnvironment` mutability limitation --- core/vm/contracts.libevm.go | 17 ++++---- core/vm/contracts.libevm_test.go | 75 ++++++++++++++++++++++++++++++-- core/vm/environment.libevm.go | 5 ++- 3 files changed, 84 insertions(+), 13 deletions(-) diff --git a/core/vm/contracts.libevm.go b/core/vm/contracts.libevm.go index 91a84906a6a5..183c86ca2ce1 100644 --- a/core/vm/contracts.libevm.go +++ b/core/vm/contracts.libevm.go @@ -92,13 +92,13 @@ func (t CallType) OpCode() OpCode { type StateMutability uint const ( - unknownStateMutability StateMutability = iota - MutableState - // ReadOnlyState is equivalent to Solidity's "view". - ReadOnlyState // Pure is a Solidity concept disallowing all access, read or write, to // state. - Pure + Pure StateMutability = iota + 1 + // ReadOnlyState is equivalent to Solidity's "view". + ReadOnlyState + // MutableState can be both read from and written to. + MutableState ) // String returns a human-readable representation of the StateMutability. @@ -177,9 +177,10 @@ type PrecompileEnvironment interface { // context, but [Pure] is a Solidity concept that is enforced by user code. StateMutability() StateMutability // AsReadOnly returns a copy of the current environment for which - // StateMutability() returns [ReadOnlyState]. It can be used as a guard - // against accidental writes when a read-only function is invoked with EVM - // call() instead of staticcall(). + // StateMutability() is at most [ReadOnlyState]; i.e. if mutability is + // already limited to [Pure], AsReadOnly() will not expand access. It can be + // used as a guard against accidental writes when a read-only function is + // invoked with EVM call() instead of staticcall(). AsReadOnly() PrecompileEnvironment // AsPure returns a copy of the current environment that has no access to // state; i.e. StateMutability() returns [Pure]. All calls to both StateDB() diff --git a/core/vm/contracts.libevm_test.go b/core/vm/contracts.libevm_test.go index 6b9fbb8318a6..b38d70e552b9 100644 --- a/core/vm/contracts.libevm_test.go +++ b/core/vm/contracts.libevm_test.go @@ -149,9 +149,6 @@ func TestNewStatefulPrecompile(t *testing.T) { gasCost := rng.Uint64n(gasLimit) run := func(env vm.PrecompileEnvironment, input []byte, suppliedGas uint64) ([]byte, uint64, error) { - if got, want := env.StateDB() != nil, env.StateMutability() == vm.MutableState; got != want { - return nil, 0, fmt.Errorf("PrecompileEnvironment().StateDB() must be non-nil i.f.f. state is mutable; got non-nil? %t; want %t", got, want) - } hdr, err := env.BlockHeader() if err != nil { return nil, 0, err @@ -770,3 +767,75 @@ func ExamplePrecompileEnvironment() { // variable to include it in this example function. _ = actualCaller } + +func TestStateMutability(t *testing.T) { + rng := ethtest.NewPseudoRand(0) + precompile := rng.Address() + chainID := rng.BigUint64() + + const precompileReturn = "precompile executed" + hooks := &hookstest.Stub{ + PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ + precompile: vm.NewStatefulPrecompile(func(env vm.PrecompileEnvironment, input []byte) (ret []byte, err error) { + + tests := []struct { + name string + env vm.PrecompileEnvironment + want vm.StateMutability + }{ + { + name: "incoming argument", + env: env, + want: vm.MutableState, + }, + { + name: "AsReadOnly()", + env: env.AsReadOnly(), + want: vm.ReadOnlyState, + }, + { + name: "AsPure()", + env: env.AsPure(), + want: vm.Pure, + }, + { + name: "AsPure().AsReadOnly() is still pure", + env: env.AsPure().AsReadOnly(), + want: vm.Pure, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + env := tt.env // deliberately shadow the incoming arg + t.Run("mutability_and_access", func(t *testing.T) { + assert.Equal(t, tt.want, env.StateMutability(), "env.StateMutability()") + assert.Equal(t, env.StateDB() != nil, tt.want == vm.MutableState, "env.StateDB() != nil i.f.f. MutableState") + assert.Equal(t, env.ReadOnlyState() != nil, tt.want != vm.Pure, "env.ReadOnlyState() != nil i.f.f !Pure") + }) + + t.Run("environment_unmodified", func(t *testing.T) { + // Each of these demonstrate that the underlying + // copy of the environment propagates everything but + // mutability. + assert.Equal(t, chainID, env.ChainConfig().ChainID, "Chain ID preserved") + assert.Equalf(t, precompile, env.Addresses().Self, "%T preserved", env.Addresses()) + assert.Equalf(t, vm.Call, env.IncomingCallType(), "%T preserved", env.IncomingCallType()) + }) + }) + } + + return []byte(precompileReturn), nil + }), + }, + } + hooks.Register(t) + + _, evm := ethtest.NewZeroEVM(t, ethtest.WithChainConfig(¶ms.ChainConfig{ + ChainID: chainID, + })) + got, _, err := evm.Call(vm.AccountRef{}, precompile, nil, 0, uint256.NewInt(0)) + if got, want := string(got), precompileReturn; err != nil || got != want { + t.Errorf("%T.Call([precompile]) got {%q, %v}; want {%q, nil}", evm, got, err, want) + } +} diff --git a/core/vm/environment.libevm.go b/core/vm/environment.libevm.go index 1ee34ad18ca1..79fe4d09f0cb 100644 --- a/core/vm/environment.libevm.go +++ b/core/vm/environment.libevm.go @@ -81,6 +81,9 @@ func (e *environment) StateMutability() StateMutability { // A switch statement provides clearer code coverage for difficult-to-test // cases. switch { + // cases MUST be ordered from most to least restrictive + case e.pure: + return Pure case e.callType == StaticCall: // evm.interpreter.readOnly is only set to true via a call to // EVMInterpreter.Run() so, if a precompile is called directly with @@ -90,8 +93,6 @@ func (e *environment) StateMutability() StateMutability { return ReadOnlyState case e.view: return ReadOnlyState - case e.pure: - return Pure default: return MutableState } From 7194e1a9b22ed32963972e8633c4b1237ff88e62 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 24 Dec 2024 13:25:39 +0000 Subject: [PATCH 21/22] refactor: reduce nesting of last commit --- core/vm/contracts.libevm_test.go | 105 ++++++++++++++++--------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/core/vm/contracts.libevm_test.go b/core/vm/contracts.libevm_test.go index b38d70e552b9..a547c149f030 100644 --- a/core/vm/contracts.libevm_test.go +++ b/core/vm/contracts.libevm_test.go @@ -770,63 +770,64 @@ func ExamplePrecompileEnvironment() { func TestStateMutability(t *testing.T) { rng := ethtest.NewPseudoRand(0) - precompile := rng.Address() + precompileAddr := rng.Address() chainID := rng.BigUint64() const precompileReturn = "precompile executed" - hooks := &hookstest.Stub{ - PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ - precompile: vm.NewStatefulPrecompile(func(env vm.PrecompileEnvironment, input []byte) (ret []byte, err error) { + precompile := vm.NewStatefulPrecompile(func(env vm.PrecompileEnvironment, input []byte) (ret []byte, err error) { + tests := []struct { + name string + env vm.PrecompileEnvironment + want vm.StateMutability + }{ + { + name: "incoming argument", + env: env, + want: vm.MutableState, + }, + { + name: "AsReadOnly()", + env: env.AsReadOnly(), + want: vm.ReadOnlyState, + }, + { + name: "AsPure()", + env: env.AsPure(), + want: vm.Pure, + }, + { + name: "AsPure().AsReadOnly() is still pure", + env: env.AsPure().AsReadOnly(), + want: vm.Pure, + }, + } - tests := []struct { - name string - env vm.PrecompileEnvironment - want vm.StateMutability - }{ - { - name: "incoming argument", - env: env, - want: vm.MutableState, - }, - { - name: "AsReadOnly()", - env: env.AsReadOnly(), - want: vm.ReadOnlyState, - }, - { - name: "AsPure()", - env: env.AsPure(), - want: vm.Pure, - }, - { - name: "AsPure().AsReadOnly() is still pure", - env: env.AsPure().AsReadOnly(), - want: vm.Pure, - }, - } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + env := tt.env // deliberately shadow the incoming arg + t.Run("mutability_and_access", func(t *testing.T) { + assert.Equal(t, tt.want, env.StateMutability(), "env.StateMutability()") + assert.Equal(t, env.StateDB() != nil, tt.want == vm.MutableState, "env.StateDB() != nil i.f.f. MutableState") + assert.Equal(t, env.ReadOnlyState() != nil, tt.want != vm.Pure, "env.ReadOnlyState() != nil i.f.f !Pure") + }) + + t.Run("environment_unmodified", func(t *testing.T) { + // Each of these demonstrate that the underlying + // copy of the environment propagates everything but + // mutability. + assert.Equal(t, chainID, env.ChainConfig().ChainID, "Chain ID preserved") + assert.Equalf(t, precompileAddr, env.Addresses().Self, "%T preserved", env.Addresses()) + assert.Equalf(t, vm.Call, env.IncomingCallType(), "%T preserved", env.IncomingCallType()) + }) + }) + } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - env := tt.env // deliberately shadow the incoming arg - t.Run("mutability_and_access", func(t *testing.T) { - assert.Equal(t, tt.want, env.StateMutability(), "env.StateMutability()") - assert.Equal(t, env.StateDB() != nil, tt.want == vm.MutableState, "env.StateDB() != nil i.f.f. MutableState") - assert.Equal(t, env.ReadOnlyState() != nil, tt.want != vm.Pure, "env.ReadOnlyState() != nil i.f.f !Pure") - }) - - t.Run("environment_unmodified", func(t *testing.T) { - // Each of these demonstrate that the underlying - // copy of the environment propagates everything but - // mutability. - assert.Equal(t, chainID, env.ChainConfig().ChainID, "Chain ID preserved") - assert.Equalf(t, precompile, env.Addresses().Self, "%T preserved", env.Addresses()) - assert.Equalf(t, vm.Call, env.IncomingCallType(), "%T preserved", env.IncomingCallType()) - }) - }) - } + return []byte(precompileReturn), nil + }) - return []byte(precompileReturn), nil - }), + hooks := &hookstest.Stub{ + PrecompileOverrides: map[common.Address]libevm.PrecompiledContract{ + precompileAddr: precompile, }, } hooks.Register(t) @@ -834,7 +835,7 @@ func TestStateMutability(t *testing.T) { _, evm := ethtest.NewZeroEVM(t, ethtest.WithChainConfig(¶ms.ChainConfig{ ChainID: chainID, })) - got, _, err := evm.Call(vm.AccountRef{}, precompile, nil, 0, uint256.NewInt(0)) + got, _, err := evm.Call(vm.AccountRef{}, precompileAddr, nil, 0, uint256.NewInt(0)) if got, want := string(got), precompileReturn; err != nil || got != want { t.Errorf("%T.Call([precompile]) got {%q, %v}; want {%q, nil}", evm, got, err, want) } From 2780b748e785c93e31ac80742dbe6d23ec03c9c5 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 24 Dec 2024 19:06:58 +0000 Subject: [PATCH 22/22] fix: `view` and `pure` functions revert when paid --- libevm/precompilegen/precompile.go.tmpl | 10 ++++++---- libevm/precompilegen/testprecompile/TestSuite.sol | 15 ++++++++++----- libevm/precompilegen/testprecompile/generated.go | 10 ++++++---- .../testprecompile/suite.abigen_test.go | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/libevm/precompilegen/precompile.go.tmpl b/libevm/precompilegen/precompile.go.tmpl index ce7069f6e368..8633a673a6e0 100644 --- a/libevm/precompilegen/precompile.go.tmpl +++ b/libevm/precompilegen/precompile.go.tmpl @@ -71,12 +71,11 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err return p.impl.Fallback(env, input) } + payable := false switch m := methods[selector]; m.StateMutability { - case "nonpayable": - if !env.Value().IsZero() { - return []byte(revertBufferWhenNonPayableReceivesValue), vm.ErrExecutionReverted - } case "payable": + payable = true + case "nonpayable": case "pure": env = env.AsPure() case "view": @@ -87,6 +86,9 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err data := fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig) return []byte(data), vm.ErrExecutionReverted } + if !payable && !env.Value().IsZero() { + return []byte(revertBufferWhenNonPayableReceivesValue), vm.ErrExecutionReverted + } ret, err := dispatchers[selector](p.impl, env, input) switch err := err.(type) { diff --git a/libevm/precompilegen/testprecompile/TestSuite.sol b/libevm/precompilegen/testprecompile/TestSuite.sol index ab344ba6cfb2..53a05f9de954 100644 --- a/libevm/precompilegen/testprecompile/TestSuite.sol +++ b/libevm/precompilegen/testprecompile/TestSuite.sol @@ -93,18 +93,23 @@ contract TestSuite { uint256 value = precompile.Payable{value: 42}(); assert(value == 42); - callNonPayable(0, ""); - callNonPayable(1, abi.encodePacked(_expectedNonPayableErrorMsg)); + bytes4 nonPayable = IPrecompile.NonPayable.selector; + callNonPayable(nonPayable, 0, ""); + + bytes memory err = abi.encodePacked(_expectedNonPayableErrorMsg); + callNonPayable(nonPayable, 1, err); + callNonPayable(IPrecompile.View.selector, 1, err); + callNonPayable(IPrecompile.Pure.selector, 1, err); emit Called("Transfer()"); } - function callNonPayable(uint256 value, bytes memory expectRevertWith) internal { + function callNonPayable(bytes4 selector, uint256 value, bytes memory expectRevertWith) internal { // We can't use just call `precompile.NonPayable()` directly because // (a) it's a precompile and (b) it doesn't return values, which means // that Solidity will perform an EXTCODESIZE check first and revert. - bytes memory selector = abi.encodeWithSelector(IPrecompile.NonPayable.selector); - (bool ok, bytes memory ret) = address(precompile).call{value: value}(selector); + bytes memory data = abi.encodeWithSelector(selector); + (bool ok, bytes memory ret) = address(precompile).call{value: value}(data); if (expectRevertWith.length == 0) { assert(ok); diff --git a/libevm/precompilegen/testprecompile/generated.go b/libevm/precompilegen/testprecompile/generated.go index 59a96d329b8d..e00f83efa138 100644 --- a/libevm/precompilegen/testprecompile/generated.go +++ b/libevm/precompilegen/testprecompile/generated.go @@ -121,12 +121,11 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err return p.impl.Fallback(env, input) } + payable := false switch m := methods[selector]; m.StateMutability { - case "nonpayable": - if !env.Value().IsZero() { - return []byte(revertBufferWhenNonPayableReceivesValue), vm.ErrExecutionReverted - } case "payable": + payable = true + case "nonpayable": case "pure": env = env.AsPure() case "view": @@ -137,6 +136,9 @@ func (p precompile) run(env vm.PrecompileEnvironment, input []byte) ([]byte, err data := fmt.Sprintf("unsupported state mutability %q on method %s", m.StateMutability, m.Sig) return []byte(data), vm.ErrExecutionReverted } + if !payable && !env.Value().IsZero() { + return []byte(revertBufferWhenNonPayableReceivesValue), vm.ErrExecutionReverted + } ret, err := dispatchers[selector](p.impl, env, input) switch err := err.(type) { diff --git a/libevm/precompilegen/testprecompile/suite.abigen_test.go b/libevm/precompilegen/testprecompile/suite.abigen_test.go index ef70fd92ad1c..480cfc591f0e 100644 --- a/libevm/precompilegen/testprecompile/suite.abigen_test.go +++ b/libevm/precompilegen/testprecompile/suite.abigen_test.go @@ -37,7 +37,7 @@ type IPrecompileWrapper struct { // TestSuiteMetaData contains all meta data concerning the TestSuite contract. var TestSuiteMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"contractIPrecompile\",\"name\":\"_precompile\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"nonPayableErrorMsg\",\"type\":\"string\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"func\",\"type\":\"string\"}],\"name\":\"Called\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"x\",\"type\":\"string\"}],\"name\":\"Echo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"EchoingFallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"int256\",\"name\":\"val\",\"type\":\"int256\"}],\"internalType\":\"structIPrecompile.Wrapper\",\"name\":\"x\",\"type\":\"tuple\"}],\"name\":\"Extract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"bytes2\",\"name\":\"y\",\"type\":\"bytes2\"},{\"internalType\":\"address\",\"name\":\"z\",\"type\":\"address\"}],\"name\":\"HashPacked\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NeitherViewNorPure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Pure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"err\",\"type\":\"bytes\"}],\"name\":\"RevertWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Self\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"Transfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"View\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405260405161233c38038061233c83398181016040528101906100259190610227565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050805f90816100679190610491565b505050610560565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a982610080565b9050919050565b5f6100ba8261009f565b9050919050565b6100ca816100b0565b81146100d4575f5ffd5b50565b5f815190506100e5816100c1565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610139826100f3565b810181811067ffffffffffffffff8211171561015857610157610103565b5b80604052505050565b5f61016a61006f565b90506101768282610130565b919050565b5f67ffffffffffffffff82111561019557610194610103565b5b61019e826100f3565b9050602081019050919050565b8281835e5f83830152505050565b5f6101cb6101c68461017b565b610161565b9050828152602081018484840111156101e7576101e66100ef565b5b6101f28482856101ab565b509392505050565b5f82601f83011261020e5761020d6100eb565b5b815161021e8482602086016101b9565b91505092915050565b5f5f6040838503121561023d5761023c610078565b5b5f61024a858286016100d7565b925050602083015167ffffffffffffffff81111561026b5761026a61007c565b5b610277858286016101fa565b9150509250929050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806102cf57607f821691505b6020821081036102e2576102e161028b565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026103447fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610309565b61034e8683610309565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61039261038d61038884610366565b61036f565b610366565b9050919050565b5f819050919050565b6103ab83610378565b6103bf6103b782610399565b848454610315565b825550505050565b5f5f905090565b6103d66103c7565b6103e18184846103a2565b505050565b5b81811015610404576103f95f826103ce565b6001810190506103e7565b5050565b601f8211156104495761041a816102e8565b610423846102fa565b81016020851015610432578190505b61044661043e856102fa565b8301826103e6565b50505b505050565b5f82821c905092915050565b5f6104695f198460080261044e565b1980831691505092915050565b5f610481838361045a565b9150826002028217905092915050565b61049a82610281565b67ffffffffffffffff8111156104b3576104b2610103565b5b6104bd82546102b8565b6104c8828285610408565b5f60209050601f8311600181146104f9575f84156104e7578287015190505b6104f18582610476565b865550610558565b601f198416610507866102e8565b5f5b8281101561052e57848901518255600182019150602085019450602081019050610509565b8683101561054b5784890151610547601f89168261045a565b8355505b6001600288020188555050505b505050505050565b608051611d7e6105be5f395f81816101d2015281816102b10152818161041b0152818161057f015281816106b9015281816107a7015281816107de015281816108f1015281816109fc01528181610b4e0152610d020152611d7e5ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610e1e565b6101cf565b005b6100d96102ae565b005b6100e36103cd565b005b6100ff60048036038101906100fa9190610f85565b610417565b005b61011b6004803603810190610116919061103c565b61057d565b005b61013760048036038101906101329190610f85565b61065f565b005b6101416107a5565b005b61015d60048036038101906101589190611116565b6108c4565b005b61017960048036038101906101749190611204565b6109d3565b005b610183610b01565b005b610198631686f26560e01b60015f610b4a565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c5906112a5565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b815260040161022991906112d2565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061026891906112ff565b146102765761027561132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a3906113a1565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f8201168201806040525081019061034091906112ff565b9050602a81146103535761035261132a565b5b61036b5f60405180602001604052805f815250610c90565b61039560015f60405160200161038191906114b8565b604051602081830303815290604052610c90565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516103c290611518565b60405180910390a150565b6103e063a726300060e01b600180610b4a565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161040d90611580565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b8460405160240161046991906115fe565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104d39190611658565b5f604051808303815f865af19150503d805f811461050c576040519150601f19603f3d011682016040523d82523d5f602084013e610511565b606091505b509150915081156105255761052461132a565b5b82805190602001208180519060200120146105435761054261132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610570906116b8565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b81526004016105d691906116ff565b602060405180830381865afa1580156105f1573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610615919061172c565b815f0151146106275761062661132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610654906117a1565b60405180910390a150565b5f5f8260405160240161067291906115fe565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16836040516106fc9190611658565b5f60405180830381855afa9150503d805f8114610734576040519150601f19603f3d011682016040523d82523d5f602084013e610739565b606091505b50915091508161074c5761074b61132a565b5b828051906020012081805190602001201461076a5761076961132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161079790611809565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610845573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610869919061183b565b73ffffffffffffffffffffffffffffffffffffffff161461088d5761088c61132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108ba906118b0565b60405180910390a1565b8282826040516020016108d993929190611953565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b815260040161094c939291906119ad565b602060405180830381865afa158015610967573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098b9190611a15565b146109995761099861132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516109c690611a8a565b60405180910390a1505050565b806040516020016109e49190611ae2565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610a539190611b30565b5f60405180830381865afa158015610a6d573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610a959190611bbe565b604051602001610aa59190611ae2565b6040516020818303038152906040528051906020012014610ac957610ac861132a565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610af690611c4f565b60405180910390a150565b610b1363f5ad2fb860e01b5f5f610b4a565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610b4090611cb7565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610bf49190611658565b5f604051808303815f865af19150503d805f8114610c2d576040519150601f19603f3d011682016040523d82523d5f602084013e610c32565b606091505b509150915081610c4557610c4461132a565b5b5f5f82806020019051810190610c5b9190611d0a565b9150915085151582151514610c7357610c7261132a565b5b84151581151514610c8757610c8661132a565b5b50505050505050565b5f636fb1b0e960e01b604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168584604051610d469190611658565b5f6040518083038185875af1925050503d805f8114610d80576040519150601f19603f3d011682016040523d82523d5f602084013e610d85565b606091505b50915091505f845103610da55781610da057610d9f61132a565b5b610dd3565b8115610db457610db361132a565b5b8380519060200120818051906020012014610dd257610dd161132a565b5b5b5050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610dfd81610deb565b8114610e07575f5ffd5b50565b5f81359050610e1881610df4565b92915050565b5f60208284031215610e3357610e32610de3565b5b5f610e4084828501610e0a565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610e9782610e51565b810181811067ffffffffffffffff82111715610eb657610eb5610e61565b5b80604052505050565b5f610ec8610dda565b9050610ed48282610e8e565b919050565b5f67ffffffffffffffff821115610ef357610ef2610e61565b5b610efc82610e51565b9050602081019050919050565b828183375f83830152505050565b5f610f29610f2484610ed9565b610ebf565b905082815260208101848484011115610f4557610f44610e4d565b5b610f50848285610f09565b509392505050565b5f82601f830112610f6c57610f6b610e49565b5b8135610f7c848260208601610f17565b91505092915050565b5f60208284031215610f9a57610f99610de3565b5b5f82013567ffffffffffffffff811115610fb757610fb6610de7565b5b610fc384828501610f58565b91505092915050565b5f5ffd5b5f819050919050565b610fe281610fd0565b8114610fec575f5ffd5b50565b5f81359050610ffd81610fd9565b92915050565b5f6020828403121561101857611017610fcc565b5b6110226020610ebf565b90505f61103184828501610fef565b5f8301525092915050565b5f6020828403121561105157611050610de3565b5b5f61105e84828501611003565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b61109b81611067565b81146110a5575f5ffd5b50565b5f813590506110b681611092565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6110e5826110bc565b9050919050565b6110f5816110db565b81146110ff575f5ffd5b50565b5f81359050611110816110ec565b92915050565b5f5f5f6060848603121561112d5761112c610de3565b5b5f61113a86828701610e0a565b935050602061114b868287016110a8565b925050604061115c86828701611102565b9150509250925092565b5f67ffffffffffffffff8211156111805761117f610e61565b5b61118982610e51565b9050602081019050919050565b5f6111a86111a384611166565b610ebf565b9050828152602081018484840111156111c4576111c3610e4d565b5b6111cf848285610f09565b509392505050565b5f82601f8301126111eb576111ea610e49565b5b81356111fb848260208601611196565b91505092915050565b5f6020828403121561121957611218610de3565b5b5f82013567ffffffffffffffff81111561123657611235610de7565b5b611242848285016111d7565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f61128f60068361124b565b915061129a8261125b565b602082019050919050565b5f6020820190508181035f8301526112bc81611283565b9050919050565b6112cc81610deb565b82525050565b5f6020820190506112e55f8301846112c3565b92915050565b5f815190506112f981610df4565b92915050565b5f6020828403121561131457611313610de3565b5b5f611321848285016112eb565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f61138b600d8361124b565b915061139682611357565b602082019050919050565b5f6020820190508181035f8301526113b88161137f565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061140357607f821691505b602082108103611416576114156113bf565b5b50919050565b5f81905092915050565b5f819050815f5260205f209050919050565b5f8154611444816113ec565b61144e818661141c565b9450600182165f8114611468576001811461147d576114af565b60ff19831686528115158202860193506114af565b61148685611426565b5f5b838110156114a757815481890152600182019150602081019050611488565b838801955050505b50505092915050565b5f6114c38284611438565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f611502600a8361124b565b915061150d826114ce565b602082019050919050565b5f6020820190508181035f83015261152f816114f6565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61156a60148361124b565b915061157582611536565b602082019050919050565b5f6020820190508181035f8301526115978161155e565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f6115d08261159e565b6115da81856115a8565b93506115ea8185602086016115b8565b6115f381610e51565b840191505092915050565b5f6020820190508181035f83015261161681846115c6565b905092915050565b5f81905092915050565b5f6116328261159e565b61163c818561161e565b935061164c8185602086016115b8565b80840191505092915050565b5f6116638284611628565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f6116a2600f8361124b565b91506116ad8261166e565b602082019050919050565b5f6020820190508181035f8301526116cf81611696565b9050919050565b6116df81610fd0565b82525050565b602082015f8201516116f95f8501826116d6565b50505050565b5f6020820190506117125f8301846116e5565b92915050565b5f8151905061172681610fd9565b92915050565b5f6020828403121561174157611740610de3565b5b5f61174e84828501611718565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f61178b600c8361124b565b915061179682611757565b602082019050919050565b5f6020820190508181035f8301526117b88161177f565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f6117f360148361124b565b91506117fe826117bf565b602082019050919050565b5f6020820190508181035f830152611820816117e7565b9050919050565b5f81519050611835816110ec565b92915050565b5f602082840312156118505761184f610de3565b5b5f61185d84828501611827565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f61189a60068361124b565b91506118a582611866565b602082019050919050565b5f6020820190508181035f8301526118c78161188e565b9050919050565b5f819050919050565b6118e86118e382610deb565b6118ce565b82525050565b5f819050919050565b61190861190382611067565b6118ee565b82525050565b5f8160601b9050919050565b5f6119248261190e565b9050919050565b5f6119358261191a565b9050919050565b61194d611948826110db565b61192b565b82525050565b5f61195e82866118d7565b60208201915061196e82856118f7565b60028201915061197e828461193c565b601482019150819050949350505050565b61199881611067565b82525050565b6119a7816110db565b82525050565b5f6060820190506119c05f8301866112c3565b6119cd602083018561198f565b6119da604083018461199e565b949350505050565b5f819050919050565b6119f4816119e2565b81146119fe575f5ffd5b50565b5f81519050611a0f816119eb565b92915050565b5f60208284031215611a2a57611a29610de3565b5b5f611a3784828501611a01565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f611a74600f8361124b565b9150611a7f82611a40565b602082019050919050565b5f6020820190508181035f830152611aa181611a68565b9050919050565b5f81519050919050565b5f611abc82611aa8565b611ac6818561141c565b9350611ad68185602086016115b8565b80840191505092915050565b5f611aed8284611ab2565b915081905092915050565b5f611b0282611aa8565b611b0c818561124b565b9350611b1c8185602086016115b8565b611b2581610e51565b840191505092915050565b5f6020820190508181035f830152611b488184611af8565b905092915050565b5f611b62611b5d84611166565b610ebf565b905082815260208101848484011115611b7e57611b7d610e4d565b5b611b898482856115b8565b509392505050565b5f82601f830112611ba557611ba4610e49565b5b8151611bb5848260208601611b50565b91505092915050565b5f60208284031215611bd357611bd2610de3565b5b5f82015167ffffffffffffffff811115611bf057611bef610de7565b5b611bfc84828501611b91565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611c39600c8361124b565b9150611c4482611c05565b602082019050919050565b5f6020820190508181035f830152611c6681611c2d565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611ca160068361124b565b9150611cac82611c6d565b602082019050919050565b5f6020820190508181035f830152611cce81611c95565b9050919050565b5f8115159050919050565b611ce981611cd5565b8114611cf3575f5ffd5b50565b5f81519050611d0481611ce0565b92915050565b5f5f60408385031215611d2057611d1f610de3565b5b5f611d2d85828601611cf6565b9250506020611d3e85828601611cf6565b915050925092905056fea26469706673582212203f8f80491d9ec37e8b661dc7940f888a634de87866cea3d27267b7366c437dc964736f6c634300081c0033", + Bin: "0x60a060405260405161236f38038061236f83398181016040528101906100259190610227565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050805f90816100679190610491565b505050610560565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a982610080565b9050919050565b5f6100ba8261009f565b9050919050565b6100ca816100b0565b81146100d4575f5ffd5b50565b5f815190506100e5816100c1565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610139826100f3565b810181811067ffffffffffffffff8211171561015857610157610103565b5b80604052505050565b5f61016a61006f565b90506101768282610130565b919050565b5f67ffffffffffffffff82111561019557610194610103565b5b61019e826100f3565b9050602081019050919050565b8281835e5f83830152505050565b5f6101cb6101c68461017b565b610161565b9050828152602081018484840111156101e7576101e66100ef565b5b6101f28482856101ab565b509392505050565b5f82601f83011261020e5761020d6100eb565b5b815161021e8482602086016101b9565b91505092915050565b5f5f6040838503121561023d5761023c610078565b5b5f61024a858286016100d7565b925050602083015167ffffffffffffffff81111561026b5761026a61007c565b5b610277858286016101fa565b9150509250929050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806102cf57607f821691505b6020821081036102e2576102e161028b565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026103447fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610309565b61034e8683610309565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61039261038d61038884610366565b61036f565b610366565b9050919050565b5f819050919050565b6103ab83610378565b6103bf6103b782610399565b848454610315565b825550505050565b5f5f905090565b6103d66103c7565b6103e18184846103a2565b505050565b5b81811015610404576103f95f826103ce565b6001810190506103e7565b5050565b601f8211156104495761041a816102e8565b610423846102fa565b81016020851015610432578190505b61044661043e856102fa565b8301826103e6565b50505b505050565b5f82821c905092915050565b5f6104695f198460080261044e565b1980831691505092915050565b5f610481838361045a565b9150826002028217905092915050565b61049a82610281565b67ffffffffffffffff8111156104b3576104b2610103565b5b6104bd82546102b8565b6104c8828285610408565b5f60209050601f8311600181146104f9575f84156104e7578287015190505b6104f18582610476565b865550610558565b601f198416610507866102e8565b5f5b8281101561052e57848901518255600182019150602085019450602081019050610509565b8683101561054b5784890151610547601f89168261045a565b8355505b6001600288020188555050505b505050505050565b608051611db16105be5f395f81816101d2015281816102b101528181610454015281816105b8015281816106f2015281816107e0015281816108170152818161092a01528181610a3501528181610b870152610d340152611db15ff3fe608060405234801561000f575f5ffd5b50600436106100a7575f3560e01c8063ad8108a41161006f578063ad8108a414610101578063b4a818081461011d578063c62c692f14610139578063d7cc1f3714610143578063db84d7c01461015f578063f5ad2fb81461017b576100a7565b80631686f265146100ab57806334d6d9be146100b5578063406dade3146100d1578063a7263000146100db578063a93cbd97146100e5575b5f5ffd5b6100b3610185565b005b6100cf60048036038101906100ca9190610e51565b6101cf565b005b6100d96102ae565b005b6100e3610406565b005b6100ff60048036038101906100fa9190610fb8565b610450565b005b61011b6004803603810190610116919061106f565b6105b6565b005b61013760048036038101906101329190610fb8565b610698565b005b6101416107de565b005b61015d60048036038101906101589190611149565b6108fd565b005b61017960048036038101906101749190611237565b610a0c565b005b610183610b3a565b005b610198631686f26560e01b60015f610b83565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516101c5906112d8565b60405180910390a1565b807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166334d6d9be836040518263ffffffff1660e01b81526004016102299190611305565b602060405180830381865afa158015610244573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102689190611332565b146102765761027561135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516102a3906113d4565b60405180910390a150565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631b7fb4b0602a6040518263ffffffff1660e01b815260040160206040518083038185885af115801561031b573d5f5f3e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906103409190611332565b9050602a81146103535761035261135d565b5b5f636fb1b0e960e01b9050610377815f60405180602001604052805f815250610cc9565b5f5f60405160200161038991906114eb565b60405160208183030381529060405290506103a682600183610cc9565b6103b9631686f26560e01b600183610cc9565b6103cc63f5ad2fb860e01b600183610cc9565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516103f99061154b565b60405180910390a1505050565b61041963a726300060e01b600180610b83565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610446906115b3565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a93cbd9760e01b846040516024016104a29190611631565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161050c919061168b565b5f604051808303815f865af19150503d805f8114610545576040519150601f19603f3d011682016040523d82523d5f602084013e61054a565b606091505b5091509150811561055e5761055d61135d565b5b828051906020012081805190602001201461057c5761057b61135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516105a9906116eb565b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ad8108a4826040518263ffffffff1660e01b815260040161060f9190611732565b602060405180830381865afa15801561062a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061064e919061175f565b815f0151146106605761065f61135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a60405161068d906117d4565b60405180910390a150565b5f5f826040516024016106ab9190611631565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1683604051610735919061168b565b5f60405180830381855afa9150503d805f811461076d576040519150601f19603f3d011682016040523d82523d5f602084013e610772565b606091505b5091509150816107855761078461135d565b5b82805190602001208180519060200120146107a3576107a261135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516107d09061183c565b60405180910390a150505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663c62c692f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561087e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108a2919061186e565b73ffffffffffffffffffffffffffffffffffffffff16146108c6576108c561135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516108f3906118e3565b60405180910390a1565b82828260405160200161091293929190611986565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d7cc1f378585856040518463ffffffff1660e01b8152600401610985939291906119e0565b602060405180830381865afa1580156109a0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109c49190611a48565b146109d2576109d161135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a6040516109ff90611abd565b60405180910390a1505050565b80604051602001610a1d9190611b15565b604051602081830303815290604052805190602001207f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663db84d7c0836040518263ffffffff1660e01b8152600401610a8c9190611b63565b5f60405180830381865afa158015610aa6573d5f5f3e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610ace9190611bf1565b604051602001610ade9190611b15565b6040516020818303038152906040528051906020012014610b0257610b0161135d565b5b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610b2f90611c82565b60405180910390a150565b610b4c63f5ad2fb860e01b5f5f610b83565b7f3fd5724095fcb65d3b7e6d79ac130db7e9dbf891d59bb0da292d471bc40d564a604051610b7990611cea565b60405180910390a1565b5f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1685604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c2d919061168b565b5f604051808303815f865af19150503d805f8114610c66576040519150601f19603f3d011682016040523d82523d5f602084013e610c6b565b606091505b509150915081610c7e57610c7d61135d565b5b5f5f82806020019051810190610c949190611d3d565b9150915085151582151514610cac57610cab61135d565b5b84151581151514610cc057610cbf61135d565b5b50505050505050565b5f83604051602401604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168584604051610d78919061168b565b5f6040518083038185875af1925050503d805f8114610db2576040519150601f19603f3d011682016040523d82523d5f602084013e610db7565b606091505b50915091505f845103610dd75781610dd257610dd161135d565b5b610e05565b8115610de657610de561135d565b5b8380519060200120818051906020012014610e0457610e0361135d565b5b5b505050505050565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b610e3081610e1e565b8114610e3a575f5ffd5b50565b5f81359050610e4b81610e27565b92915050565b5f60208284031215610e6657610e65610e16565b5b5f610e7384828501610e3d565b91505092915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610eca82610e84565b810181811067ffffffffffffffff82111715610ee957610ee8610e94565b5b80604052505050565b5f610efb610e0d565b9050610f078282610ec1565b919050565b5f67ffffffffffffffff821115610f2657610f25610e94565b5b610f2f82610e84565b9050602081019050919050565b828183375f83830152505050565b5f610f5c610f5784610f0c565b610ef2565b905082815260208101848484011115610f7857610f77610e80565b5b610f83848285610f3c565b509392505050565b5f82601f830112610f9f57610f9e610e7c565b5b8135610faf848260208601610f4a565b91505092915050565b5f60208284031215610fcd57610fcc610e16565b5b5f82013567ffffffffffffffff811115610fea57610fe9610e1a565b5b610ff684828501610f8b565b91505092915050565b5f5ffd5b5f819050919050565b61101581611003565b811461101f575f5ffd5b50565b5f813590506110308161100c565b92915050565b5f6020828403121561104b5761104a610fff565b5b6110556020610ef2565b90505f61106484828501611022565b5f8301525092915050565b5f6020828403121561108457611083610e16565b5b5f61109184828501611036565b91505092915050565b5f7fffff00000000000000000000000000000000000000000000000000000000000082169050919050565b6110ce8161109a565b81146110d8575f5ffd5b50565b5f813590506110e9816110c5565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f611118826110ef565b9050919050565b6111288161110e565b8114611132575f5ffd5b50565b5f813590506111438161111f565b92915050565b5f5f5f606084860312156111605761115f610e16565b5b5f61116d86828701610e3d565b935050602061117e868287016110db565b925050604061118f86828701611135565b9150509250925092565b5f67ffffffffffffffff8211156111b3576111b2610e94565b5b6111bc82610e84565b9050602081019050919050565b5f6111db6111d684611199565b610ef2565b9050828152602081018484840111156111f7576111f6610e80565b5b611202848285610f3c565b509392505050565b5f82601f83011261121e5761121d610e7c565b5b813561122e8482602086016111c9565b91505092915050565b5f6020828403121561124c5761124b610e16565b5b5f82013567ffffffffffffffff81111561126957611268610e1a565b5b6112758482850161120a565b91505092915050565b5f82825260208201905092915050565b7f56696577282900000000000000000000000000000000000000000000000000005f82015250565b5f6112c260068361127e565b91506112cd8261128e565b602082019050919050565b5f6020820190508181035f8301526112ef816112b6565b9050919050565b6112ff81610e1e565b82525050565b5f6020820190506113185f8301846112f6565b92915050565b5f8151905061132c81610e27565b92915050565b5f6020828403121561134757611346610e16565b5b5f6113548482850161131e565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b7f4563686f2875696e7432353629000000000000000000000000000000000000005f82015250565b5f6113be600d8361127e565b91506113c98261138a565b602082019050919050565b5f6020820190508181035f8301526113eb816113b2565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061143657607f821691505b602082108103611449576114486113f2565b5b50919050565b5f81905092915050565b5f819050815f5260205f209050919050565b5f81546114778161141f565b611481818661144f565b9450600182165f811461149b57600181146114b0576114e2565b60ff19831686528115158202860193506114e2565b6114b985611459565b5f5b838110156114da578154818901526001820191506020810190506114bb565b838801955050505b50505092915050565b5f6114f6828461146b565b915081905092915050565b7f5472616e736665722829000000000000000000000000000000000000000000005f82015250565b5f611535600a8361127e565b915061154082611501565b602082019050919050565b5f6020820190508181035f83015261156281611529565b9050919050565b7f4e656974686572566965774e6f725075726528290000000000000000000000005f82015250565b5f61159d60148361127e565b91506115a882611569565b602082019050919050565b5f6020820190508181035f8301526115ca81611591565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f611603826115d1565b61160d81856115db565b935061161d8185602086016115eb565b61162681610e84565b840191505092915050565b5f6020820190508181035f83015261164981846115f9565b905092915050565b5f81905092915050565b5f611665826115d1565b61166f8185611651565b935061167f8185602086016115eb565b80840191505092915050565b5f611696828461165b565b915081905092915050565b7f52657665727457697468282e2e2e2900000000000000000000000000000000005f82015250565b5f6116d5600f8361127e565b91506116e0826116a1565b602082019050919050565b5f6020820190508181035f830152611702816116c9565b9050919050565b61171281611003565b82525050565b602082015f82015161172c5f850182611709565b50505050565b5f6020820190506117455f830184611718565b92915050565b5f815190506117598161100c565b92915050565b5f6020828403121561177457611773610e16565b5b5f6117818482850161174b565b91505092915050565b7f45787472616374282e2e2e2900000000000000000000000000000000000000005f82015250565b5f6117be600c8361127e565b91506117c98261178a565b602082019050919050565b5f6020820190508181035f8301526117eb816117b2565b9050919050565b7f4563686f696e6746616c6c6261636b282e2e2e290000000000000000000000005f82015250565b5f61182660148361127e565b9150611831826117f2565b602082019050919050565b5f6020820190508181035f8301526118538161181a565b9050919050565b5f815190506118688161111f565b92915050565b5f6020828403121561188357611882610e16565b5b5f6118908482850161185a565b91505092915050565b7f53656c66282900000000000000000000000000000000000000000000000000005f82015250565b5f6118cd60068361127e565b91506118d882611899565b602082019050919050565b5f6020820190508181035f8301526118fa816118c1565b9050919050565b5f819050919050565b61191b61191682610e1e565b611901565b82525050565b5f819050919050565b61193b6119368261109a565b611921565b82525050565b5f8160601b9050919050565b5f61195782611941565b9050919050565b5f6119688261194d565b9050919050565b61198061197b8261110e565b61195e565b82525050565b5f611991828661190a565b6020820191506119a1828561192a565b6002820191506119b1828461196f565b601482019150819050949350505050565b6119cb8161109a565b82525050565b6119da8161110e565b82525050565b5f6060820190506119f35f8301866112f6565b611a0060208301856119c2565b611a0d60408301846119d1565b949350505050565b5f819050919050565b611a2781611a15565b8114611a31575f5ffd5b50565b5f81519050611a4281611a1e565b92915050565b5f60208284031215611a5d57611a5c610e16565b5b5f611a6a84828501611a34565b91505092915050565b7f486173685061636b6564282e2e2e2900000000000000000000000000000000005f82015250565b5f611aa7600f8361127e565b9150611ab282611a73565b602082019050919050565b5f6020820190508181035f830152611ad481611a9b565b9050919050565b5f81519050919050565b5f611aef82611adb565b611af9818561144f565b9350611b098185602086016115eb565b80840191505092915050565b5f611b208284611ae5565b915081905092915050565b5f611b3582611adb565b611b3f818561127e565b9350611b4f8185602086016115eb565b611b5881610e84565b840191505092915050565b5f6020820190508181035f830152611b7b8184611b2b565b905092915050565b5f611b95611b9084611199565b610ef2565b905082815260208101848484011115611bb157611bb0610e80565b5b611bbc8482856115eb565b509392505050565b5f82601f830112611bd857611bd7610e7c565b5b8151611be8848260208601611b83565b91505092915050565b5f60208284031215611c0657611c05610e16565b5b5f82015167ffffffffffffffff811115611c2357611c22610e1a565b5b611c2f84828501611bc4565b91505092915050565b7f4563686f28737472696e672900000000000000000000000000000000000000005f82015250565b5f611c6c600c8361127e565b9150611c7782611c38565b602082019050919050565b5f6020820190508181035f830152611c9981611c60565b9050919050565b7f50757265282900000000000000000000000000000000000000000000000000005f82015250565b5f611cd460068361127e565b9150611cdf82611ca0565b602082019050919050565b5f6020820190508181035f830152611d0181611cc8565b9050919050565b5f8115159050919050565b611d1c81611d08565b8114611d26575f5ffd5b50565b5f81519050611d3781611d13565b92915050565b5f5f60408385031215611d5357611d52610e16565b5b5f611d6085828601611d29565b9250506020611d7185828601611d29565b915050925092905056fea2646970667358221220f0b141f0869405a047b6257eeea3f5957b650b4c10613fbb449d8778f8d6986764736f6c634300081c0033", } // TestSuiteABI is the input ABI used to generate the binding from.