From 12ce79ea75be8d77ba49df658c41acea14d8a876 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2024 12:55:27 +0800 Subject: [PATCH 1/5] feat(bindings): update Go contract bindings --- bindings/.githead | 2 +- bindings/gen_lib_proving.go | 33 +-------------------------------- cmd/flags/common.go | 3 ++- cmd/flags/prover.go | 2 +- prover/config.go | 9 ++++----- prover/prover.go | 3 +-- 6 files changed, 10 insertions(+), 42 deletions(-) diff --git a/bindings/.githead b/bindings/.githead index a71157525..c971e4a82 100644 --- a/bindings/.githead +++ b/bindings/.githead @@ -1 +1 @@ -2c63cb0c796495948f1dd887662044397394d852 +03d610d8a94e4f1ef52b4c3e5656ed9081b8585f diff --git a/bindings/gen_lib_proving.go b/bindings/gen_lib_proving.go index dbc4b7f1e..b81e5981e 100644 --- a/bindings/gen_lib_proving.go +++ b/bindings/gen_lib_proving.go @@ -31,7 +31,7 @@ var ( // LibProvingMetaData contains all meta data concerning the LibProving contract. var LibProvingMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"RETURN_LIVENESS_BOND\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"ProvingPaused\",\"inputs\":[{\"name\":\"paused\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TransitionContested\",\"inputs\":[{\"name\":\"blockId\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"tran\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structTaikoData.Transition\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blockHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"graffiti\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"contester\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"contestBond\",\"type\":\"uint96\",\"indexed\":false,\"internalType\":\"uint96\"},{\"name\":\"tier\",\"type\":\"uint16\",\"indexed\":false,\"internalType\":\"uint16\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TransitionProved\",\"inputs\":[{\"name\":\"blockId\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"tran\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structTaikoData.Transition\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blockHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"graffiti\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"prover\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"validityBond\",\"type\":\"uint96\",\"indexed\":false,\"internalType\":\"uint96\"},{\"name\":\"tier\",\"type\":\"uint16\",\"indexed\":false,\"internalType\":\"uint16\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"L1_ALREADY_CONTESTED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_ALREADY_PROVED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_BLOCK_MISMATCH\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_CANNOT_CONTEST\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_BLOCK_ID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_PAUSE_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_TIER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_TRANSITION\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_MISSING_VERIFIER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_NOT_ASSIGNED_PROVER\",\"inputs\":[]}]", + ABI: "[{\"type\":\"event\",\"name\":\"ProvingPaused\",\"inputs\":[{\"name\":\"paused\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TransitionContested\",\"inputs\":[{\"name\":\"blockId\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"tran\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structTaikoData.Transition\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blockHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"graffiti\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"contester\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"contestBond\",\"type\":\"uint96\",\"indexed\":false,\"internalType\":\"uint96\"},{\"name\":\"tier\",\"type\":\"uint16\",\"indexed\":false,\"internalType\":\"uint16\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TransitionProved\",\"inputs\":[{\"name\":\"blockId\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"tran\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structTaikoData.Transition\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blockHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"graffiti\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"prover\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"validityBond\",\"type\":\"uint96\",\"indexed\":false,\"internalType\":\"uint96\"},{\"name\":\"tier\",\"type\":\"uint16\",\"indexed\":false,\"internalType\":\"uint16\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"L1_ALREADY_CONTESTED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_ALREADY_PROVED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_BLOCK_MISMATCH\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_CANNOT_CONTEST\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_BLOCK_ID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_PAUSE_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_TIER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_INVALID_TRANSITION\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_MISSING_VERIFIER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L1_NOT_ASSIGNED_PROVER\",\"inputs\":[]}]", } // LibProvingABI is the input ABI used to generate the binding from. @@ -180,37 +180,6 @@ func (_LibProving *LibProvingTransactorRaw) Transact(opts *bind.TransactOpts, me return _LibProving.Contract.contract.Transact(opts, method, params...) } -// RETURNLIVENESSBOND is a free data retrieval call binding the contract method 0x53712a96. -// -// Solidity: function RETURN_LIVENESS_BOND() view returns(bytes32) -func (_LibProving *LibProvingCaller) RETURNLIVENESSBOND(opts *bind.CallOpts) ([32]byte, error) { - var out []interface{} - err := _LibProving.contract.Call(opts, &out, "RETURN_LIVENESS_BOND") - - if err != nil { - return *new([32]byte), err - } - - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - - return out0, err - -} - -// RETURNLIVENESSBOND is a free data retrieval call binding the contract method 0x53712a96. -// -// Solidity: function RETURN_LIVENESS_BOND() view returns(bytes32) -func (_LibProving *LibProvingSession) RETURNLIVENESSBOND() ([32]byte, error) { - return _LibProving.Contract.RETURNLIVENESSBOND(&_LibProving.CallOpts) -} - -// RETURNLIVENESSBOND is a free data retrieval call binding the contract method 0x53712a96. -// -// Solidity: function RETURN_LIVENESS_BOND() view returns(bytes32) -func (_LibProving *LibProvingCallerSession) RETURNLIVENESSBOND() ([32]byte, error) { - return _LibProving.Contract.RETURNLIVENESSBOND(&_LibProving.CallOpts) -} - // LibProvingProvingPausedIterator is returned from FilterProvingPaused and is used to iterate over the raw logs and unpacked data for ProvingPaused events raised by the LibProving contract. type LibProvingProvingPausedIterator struct { Event *LibProvingProvingPaused // Event containing the contract specifics and raw log diff --git a/cmd/flags/common.go b/cmd/flags/common.go index 95a37a01e..1aeeda8ee 100644 --- a/cmd/flags/common.go +++ b/cmd/flags/common.go @@ -3,6 +3,7 @@ package flags import ( "time" + "github.com/cenkalti/backoff/v4" "github.com/urfave/cli/v2" ) @@ -119,7 +120,7 @@ var ( Name: "backoff.retryInterval", Usage: "Retry interval in seconds when there is an error", Category: commonCategory, - Value: 12 * time.Second, + Value: backoff.DefaultMaxInterval, } RPCTimeout = &cli.DurationFlag{ Name: "rpc.timeout", diff --git a/cmd/flags/prover.go b/cmd/flags/prover.go index 535c4da6f..b27fd0fdb 100644 --- a/cmd/flags/prover.go +++ b/cmd/flags/prover.go @@ -164,7 +164,7 @@ var ( // Confirmations specific flag BlockConfirmations = &cli.Uint64Flag{ Name: "prover.blockConfirmations", - Usage: "Confirmations to the latest l1 block before submitting a proof for a l2 block", + Usage: "Confirmations to the latest L1 block before submitting a proof for a L2 block", Value: 6, Category: proverCategory, } diff --git a/prover/config.go b/prover/config.go index 299cdc1af..a5cb9bd2c 100644 --- a/prover/config.go +++ b/prover/config.go @@ -100,21 +100,20 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { if err := c.Set(flags.ProveUnassignedBlocks.Name, "true"); err != nil { return nil, err } - if err := c.Set(flags.ContesterMode.Name, "true"); err != nil { return nil, err } - // l1 and l2 node version flags are required only if guardian prover + // L1 and L2 node version flags are required only if guardian prover if !c.IsSet(flags.L1NodeVersion.Name) { - return nil, errors.New("L1NodeVersion is required if guardian prover is set") + return nil, errors.New("--prover.l1NodeVersion flag is required if guardian prover is set") } - if !c.IsSet(flags.L2NodeVersion.Name) { - return nil, errors.New("L2NodeVersion is required if guardian prover is set") + return nil, errors.New("--prover.l2NodeVersion flag is required if guardian prover is set") } } + // If we are not running a guardian prover, a raiko host endpoint is required. if !c.IsSet(flags.GuardianProver.Name) && !c.IsSet(flags.RaikoHostEndpoint.Name) { return nil, fmt.Errorf("raiko host not provided") } diff --git a/prover/prover.go b/prover/prover.go index b37b597b8..72ff30c3c 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -444,8 +444,7 @@ func (p *Prover) withRetry(f func() error) { p.wg.Add(1) go func() { defer p.wg.Done() - err := backoff.Retry(f, p.backoff) - if err != nil { + if err := backoff.Retry(f, p.backoff); err != nil { log.Error("Operation failed", "error", err) } }() From aee153a2e5757f0c08ab2e94cb41a724adc996ba Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2024 13:10:26 +0800 Subject: [PATCH 2/5] feat(bindings): update Go contract bindings --- bindings/encoding/input.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bindings/encoding/input.go b/bindings/encoding/input.go index 92d48a0b3..032a82df7 100644 --- a/bindings/encoding/input.go +++ b/bindings/encoding/input.go @@ -16,10 +16,7 @@ import ( // ABI arguments marshaling components. var ( - assignmentPayloadPrefix = "PROVER_ASSIGNMENT" - assignmentPayloadPrefixSize = len([]byte(assignmentPayloadPrefix)) - paddedAssignmentPayloadPrefixBytes = common.LeftPadBytes([]byte(assignmentPayloadPrefix), assignmentPayloadPrefixSize) - blockMetadataComponents = []abi.ArgumentMarshaling{ + blockMetadataComponents = []abi.ArgumentMarshaling{ { Name: "l1Hash", Type: "bytes32", @@ -367,7 +364,7 @@ func EncodeProverAssignmentPayload( binary.BigEndian.PutUint64(chainIDBytes, chainID) return bytes.Join([][]byte{ - paddedAssignmentPayloadPrefixBytes[len(paddedAssignmentPayloadPrefixBytes)-assignmentPayloadPrefixSize:], + common.RightPadBytes([]byte("PROVER_ASSIGNMENT"), 32), chainIDBytes, taikoAddress.Bytes(), blockProposer.Bytes(), From 2d80ce48040e9399bdce7f556065ac7aba810ffb Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2024 13:22:22 +0800 Subject: [PATCH 3/5] feat(bindings): update Go contract bindings --- integration_test/l1_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test/l1_env.sh b/integration_test/l1_env.sh index 7ef412926..c4a5ea8e3 100755 --- a/integration_test/l1_env.sh +++ b/integration_test/l1_env.sh @@ -27,5 +27,5 @@ export GUARDIAN_PROVERS=${GUARDIAN_PROVERS_ADDRESSES:1} export MIN_GUARDIANS=${#GUARDIAN_PROVERS_ADDRESSES_LIST[@]} # Get the hash of L2 genesis. -export L2_GENESIS_HASH=$(cast block --rpc-url "$L2_EXECUTION_ENGINE_WS_ENDPOINT" 0x0 -f hash) +export L2_GENESIS_HASH=$(cast block --rpc-url "$L2_EXECUTION_ENGINE_WS_ENDPOINT" 0x00 -f hash) echo "L2_GENESIS_HASH: $L2_GENESIS_HASH" From 5d1ae2407a59ef71c252d0feabbbe28949204866 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2024 13:27:36 +0800 Subject: [PATCH 4/5] feat(bindings): update Go contract bindings --- integration_test/l1_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test/l1_env.sh b/integration_test/l1_env.sh index c4a5ea8e3..76b1fc923 100755 --- a/integration_test/l1_env.sh +++ b/integration_test/l1_env.sh @@ -27,5 +27,5 @@ export GUARDIAN_PROVERS=${GUARDIAN_PROVERS_ADDRESSES:1} export MIN_GUARDIANS=${#GUARDIAN_PROVERS_ADDRESSES_LIST[@]} # Get the hash of L2 genesis. -export L2_GENESIS_HASH=$(cast block --rpc-url "$L2_EXECUTION_ENGINE_WS_ENDPOINT" 0x00 -f hash) +export L2_GENESIS_HASH=$(cast block --rpc-url "$L2_EXECUTION_ENGINE_HTTP_ENDPOINT" 0x0 -f hash) echo "L2_GENESIS_HASH: $L2_GENESIS_HASH" From 1d574ac5833470072b22b7c6e06cd2655c717cd8 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 10 Apr 2024 13:37:00 +0800 Subject: [PATCH 5/5] feat: fix genesis hash --- integration_test/l1_env.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/integration_test/l1_env.sh b/integration_test/l1_env.sh index 76b1fc923..8861f19c5 100755 --- a/integration_test/l1_env.sh +++ b/integration_test/l1_env.sh @@ -27,5 +27,12 @@ export GUARDIAN_PROVERS=${GUARDIAN_PROVERS_ADDRESSES:1} export MIN_GUARDIANS=${#GUARDIAN_PROVERS_ADDRESSES_LIST[@]} # Get the hash of L2 genesis. -export L2_GENESIS_HASH=$(cast block --rpc-url "$L2_EXECUTION_ENGINE_HTTP_ENDPOINT" 0x0 -f hash) +export L2_GENESIS_HASH=$( + curl \ + --silent \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc":"2.0","id":0,"method":"eth_getBlockByNumber","params":["0x0", false]}' \ + $L2_EXECUTION_ENGINE_HTTP_ENDPOINT | jq .result.hash | sed 's/\"//g' +) echo "L2_GENESIS_HASH: $L2_GENESIS_HASH"