From e846f6289fea0b046ddcfcdfaf46f3727efbdf11 Mon Sep 17 00:00:00 2001 From: Gavin Yu Date: Mon, 16 Dec 2024 23:27:48 +0800 Subject: [PATCH] feat(protocol): propose a batch blocks conditionally (#18570) Co-authored-by: YoGhurt111 --- .../contracts/layer1/provers/ProverSet.sol | 15 ++++--- packages/taiko-client/bindings/.githead | 2 +- .../taiko-client/bindings/gen_prover_set.go | 44 +++++++++---------- packages/taiko-client/cmd/flags/proposer.go | 8 ++++ packages/taiko-client/proposer/config.go | 2 + packages/taiko-client/proposer/proposer.go | 2 + .../taiko-client/proposer/proposer_test.go | 1 + .../proposer/transaction_builder/blob.go | 9 +++- .../proposer/transaction_builder/calldata.go | 10 ++++- .../transaction_builder/common_test.go | 2 + 10 files changed, 62 insertions(+), 33 deletions(-) diff --git a/packages/protocol/contracts/layer1/provers/ProverSet.sol b/packages/protocol/contracts/layer1/provers/ProverSet.sol index d557aba553c..36eb638eb00 100644 --- a/packages/protocol/contracts/layer1/provers/ProverSet.sol +++ b/packages/protocol/contracts/layer1/provers/ProverSet.sol @@ -15,8 +15,8 @@ interface IHasRecipient { } /// @title ProverSet -/// @notice A contract that holds TKO token and acts as a Taiko prover. This contract will simply -/// relay `proveBlock` calls to TaikoL1 so msg.sender doesn't need to hold any TKO. +/// @notice A contract that holds TAIKO token and acts as a Taiko prover. This contract will simply +/// relay `proveBlock` calls to TaikoL1 so msg.sender doesn't need to hold any TAIKO. /// @custom:security-contact security@taiko.xyz contract ProverSet is EssentialContract, IERC1271 { bytes4 private constant _EIP1271_MAGICVALUE = 0x1626ba7e; @@ -94,10 +94,11 @@ contract ProverSet is EssentialContract, IERC1271 { LibAddress.sendEtherAndVerify(admin, _amount); } - /// @notice Proposes a block only when it is the first block proposal in the current L1 block. - function proposeBlockV2Conditionally( - bytes calldata _params, - bytes calldata _txList + /// @notice Proposes a batch blocks only when it is the first batch blocks proposal in the + /// current L1 block. + function proposeBlocksV2Conditionally( + bytes[] calldata _params, + bytes[] calldata _txList ) external onlyProver @@ -105,7 +106,7 @@ contract ProverSet is EssentialContract, IERC1271 { ITaikoL1 taiko = ITaikoL1(taikoL1()); // Ensure this block is the first block proposed in the current L1 block. require(taiko.lastProposedIn() != block.number, NOT_FIRST_PROPOSAL()); - taiko.proposeBlockV2(_params, _txList); + taiko.proposeBlocksV2(_params, _txList); } /// @notice Propose a Taiko block. diff --git a/packages/taiko-client/bindings/.githead b/packages/taiko-client/bindings/.githead index f875d71bc72..9780dac6ea3 100644 --- a/packages/taiko-client/bindings/.githead +++ b/packages/taiko-client/bindings/.githead @@ -1 +1 @@ -5b4b0cd271534aa72d865afa5fc55e0ee4b16b73 +ab50d406172e879e7436c70a41bda674bfc6e441 diff --git a/packages/taiko-client/bindings/gen_prover_set.go b/packages/taiko-client/bindings/gen_prover_set.go index 25e434457b6..9ce5ee76b8a 100644 --- a/packages/taiko-client/bindings/gen_prover_set.go +++ b/packages/taiko-client/bindings/gen_prover_set.go @@ -31,7 +31,7 @@ var ( // ProverSetMetaData contains all meta data concerning the ProverSet contract. var ProverSetMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"acceptOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"addressManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"admin\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"approveAllowance\",\"inputs\":[{\"name\":\"_address\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_allowance\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"delegate\",\"inputs\":[{\"name\":\"_delegatee\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"depositBond\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"enableProver\",\"inputs\":[{\"name\":\"_prover\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_isProver\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"impl\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"inNonReentrant\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"init\",\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_admin\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_rollupAddressManager\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"isProver\",\"inputs\":[{\"name\":\"prover\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"isProver\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isValidSignature\",\"inputs\":[{\"name\":\"_hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"magicValue_\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"lastUnpausedAt\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pendingOwner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proposeBlockV2\",\"inputs\":[{\"name\":\"_params\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"_txList\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proposeBlockV2Conditionally\",\"inputs\":[{\"name\":\"_params\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"_txList\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proposeBlocksV2\",\"inputs\":[{\"name\":\"_paramsArr\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"_txListArr\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proveBlock\",\"inputs\":[{\"name\":\"_blockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_input\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proveBlocks\",\"inputs\":[{\"name\":\"_blockId\",\"type\":\"uint64[]\",\"internalType\":\"uint64[]\"},{\"name\":\"_input\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"_batchProof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proxiableUUID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"resolve\",\"inputs\":[{\"name\":\"_chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_allowZeroAddress\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"resolve\",\"inputs\":[{\"name\":\"_name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_allowZeroAddress\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unpause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"upgradeTo\",\"inputs\":[{\"name\":\"newImplementation\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"upgradeToAndCall\",\"inputs\":[{\"name\":\"newImplementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"withdrawBond\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawEtherToAdmin\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawToAdmin\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"AdminChanged\",\"inputs\":[{\"name\":\"previousAdmin\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"newAdmin\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"BeaconUpgraded\",\"inputs\":[{\"name\":\"beacon\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferStarted\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Paused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ProverEnabled\",\"inputs\":[{\"name\":\"prover\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"enabled\",\"type\":\"bool\",\"indexed\":true,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unpaused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Upgraded\",\"inputs\":[{\"name\":\"implementation\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"ETH_TRANSFER_FAILED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FUNC_NOT_IMPLEMENTED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_BOND_TOKEN\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_PAUSE_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NOT_FIRST_PROPOSAL\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"PERMISSION_DENIED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"REENTRANT_CALL\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_DENIED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_INVALID_MANAGER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_UNEXPECTED_CHAINID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_ZERO_ADDR\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"ZERO_ADDRESS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ZERO_VALUE\",\"inputs\":[]}]", + ABI: "[{\"type\":\"function\",\"name\":\"acceptOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"addressManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"admin\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"approveAllowance\",\"inputs\":[{\"name\":\"_address\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_allowance\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"delegate\",\"inputs\":[{\"name\":\"_delegatee\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"depositBond\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"enableProver\",\"inputs\":[{\"name\":\"_prover\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_isProver\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"impl\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"inNonReentrant\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"init\",\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_admin\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_rollupAddressManager\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"isProver\",\"inputs\":[{\"name\":\"prover\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"isProver\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isValidSignature\",\"inputs\":[{\"name\":\"_hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"magicValue_\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"lastUnpausedAt\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pendingOwner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proposeBlockV2\",\"inputs\":[{\"name\":\"_params\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"_txList\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proposeBlocksV2\",\"inputs\":[{\"name\":\"_paramsArr\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"_txListArr\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proposeBlocksV2Conditionally\",\"inputs\":[{\"name\":\"_params\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"_txList\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proveBlock\",\"inputs\":[{\"name\":\"_blockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_input\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proveBlocks\",\"inputs\":[{\"name\":\"_blockId\",\"type\":\"uint64[]\",\"internalType\":\"uint64[]\"},{\"name\":\"_input\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"_batchProof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"proxiableUUID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"resolve\",\"inputs\":[{\"name\":\"_chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_allowZeroAddress\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"resolve\",\"inputs\":[{\"name\":\"_name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_allowZeroAddress\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unpause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"upgradeTo\",\"inputs\":[{\"name\":\"newImplementation\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"upgradeToAndCall\",\"inputs\":[{\"name\":\"newImplementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"withdrawBond\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawEtherToAdmin\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawToAdmin\",\"inputs\":[{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"AdminChanged\",\"inputs\":[{\"name\":\"previousAdmin\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"newAdmin\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"BeaconUpgraded\",\"inputs\":[{\"name\":\"beacon\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferStarted\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Paused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ProverEnabled\",\"inputs\":[{\"name\":\"prover\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"enabled\",\"type\":\"bool\",\"indexed\":true,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unpaused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Upgraded\",\"inputs\":[{\"name\":\"implementation\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"ETH_TRANSFER_FAILED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FUNC_NOT_IMPLEMENTED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_BOND_TOKEN\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_PAUSE_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NOT_FIRST_PROPOSAL\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"PERMISSION_DENIED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"REENTRANT_CALL\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_DENIED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_INVALID_MANAGER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_UNEXPECTED_CHAINID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"RESOLVER_ZERO_ADDR\",\"inputs\":[{\"name\":\"chainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"ZERO_ADDRESS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ZERO_VALUE\",\"inputs\":[]}]", } // ProverSetABI is the input ABI used to generate the binding from. @@ -751,27 +751,6 @@ func (_ProverSet *ProverSetTransactorSession) ProposeBlockV2(_params []byte, _tx return _ProverSet.Contract.ProposeBlockV2(&_ProverSet.TransactOpts, _params, _txList) } -// ProposeBlockV2Conditionally is a paid mutator transaction binding the contract method 0x64834f6e. -// -// Solidity: function proposeBlockV2Conditionally(bytes _params, bytes _txList) returns() -func (_ProverSet *ProverSetTransactor) ProposeBlockV2Conditionally(opts *bind.TransactOpts, _params []byte, _txList []byte) (*types.Transaction, error) { - return _ProverSet.contract.Transact(opts, "proposeBlockV2Conditionally", _params, _txList) -} - -// ProposeBlockV2Conditionally is a paid mutator transaction binding the contract method 0x64834f6e. -// -// Solidity: function proposeBlockV2Conditionally(bytes _params, bytes _txList) returns() -func (_ProverSet *ProverSetSession) ProposeBlockV2Conditionally(_params []byte, _txList []byte) (*types.Transaction, error) { - return _ProverSet.Contract.ProposeBlockV2Conditionally(&_ProverSet.TransactOpts, _params, _txList) -} - -// ProposeBlockV2Conditionally is a paid mutator transaction binding the contract method 0x64834f6e. -// -// Solidity: function proposeBlockV2Conditionally(bytes _params, bytes _txList) returns() -func (_ProverSet *ProverSetTransactorSession) ProposeBlockV2Conditionally(_params []byte, _txList []byte) (*types.Transaction, error) { - return _ProverSet.Contract.ProposeBlockV2Conditionally(&_ProverSet.TransactOpts, _params, _txList) -} - // ProposeBlocksV2 is a paid mutator transaction binding the contract method 0x0c8f4a10. // // Solidity: function proposeBlocksV2(bytes[] _paramsArr, bytes[] _txListArr) returns() @@ -793,6 +772,27 @@ func (_ProverSet *ProverSetTransactorSession) ProposeBlocksV2(_paramsArr [][]byt return _ProverSet.Contract.ProposeBlocksV2(&_ProverSet.TransactOpts, _paramsArr, _txListArr) } +// ProposeBlocksV2Conditionally is a paid mutator transaction binding the contract method 0xe4882785. +// +// Solidity: function proposeBlocksV2Conditionally(bytes[] _params, bytes[] _txList) returns() +func (_ProverSet *ProverSetTransactor) ProposeBlocksV2Conditionally(opts *bind.TransactOpts, _params [][]byte, _txList [][]byte) (*types.Transaction, error) { + return _ProverSet.contract.Transact(opts, "proposeBlocksV2Conditionally", _params, _txList) +} + +// ProposeBlocksV2Conditionally is a paid mutator transaction binding the contract method 0xe4882785. +// +// Solidity: function proposeBlocksV2Conditionally(bytes[] _params, bytes[] _txList) returns() +func (_ProverSet *ProverSetSession) ProposeBlocksV2Conditionally(_params [][]byte, _txList [][]byte) (*types.Transaction, error) { + return _ProverSet.Contract.ProposeBlocksV2Conditionally(&_ProverSet.TransactOpts, _params, _txList) +} + +// ProposeBlocksV2Conditionally is a paid mutator transaction binding the contract method 0xe4882785. +// +// Solidity: function proposeBlocksV2Conditionally(bytes[] _params, bytes[] _txList) returns() +func (_ProverSet *ProverSetTransactorSession) ProposeBlocksV2Conditionally(_params [][]byte, _txList [][]byte) (*types.Transaction, error) { + return _ProverSet.Contract.ProposeBlocksV2Conditionally(&_ProverSet.TransactOpts, _params, _txList) +} + // ProveBlock is a paid mutator transaction binding the contract method 0x10d008bd. // // Solidity: function proveBlock(uint64 _blockId, bytes _input) returns() diff --git a/packages/taiko-client/cmd/flags/proposer.go b/packages/taiko-client/cmd/flags/proposer.go index b266f1456db..ff8e85c0ce3 100644 --- a/packages/taiko-client/cmd/flags/proposer.go +++ b/packages/taiko-client/cmd/flags/proposer.go @@ -112,6 +112,13 @@ var ( Value: false, EnvVars: []string{"L1_BLOB_ALLOWED"}, } + RevertProtectionEnabled = &cli.BoolFlag{ + Name: "revertProtection", + Usage: "Enable revert protection with the support of endpoint and contract", + Value: false, + Category: proposerCategory, + EnvVars: []string{"REVERT_PROTECTION"}, + } ) // ProposerFlags All proposer flags. @@ -134,4 +141,5 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{ MaxProposedTxListsPerEpoch, ProposeBlockIncludeParentMetaHash, BlobAllowed, + RevertProtectionEnabled, }, TxmgrFlags) diff --git a/packages/taiko-client/proposer/config.go b/packages/taiko-client/proposer/config.go index 951130d8c06..24f631a3872 100644 --- a/packages/taiko-client/proposer/config.go +++ b/packages/taiko-client/proposer/config.go @@ -36,6 +36,7 @@ type Config struct { ProposeBlockTxGasLimit uint64 IncludeParentMetaHash bool BlobAllowed bool + RevertProtectionEnabled bool TxmgrConfigs *txmgr.CLIConfig PrivateTxmgrConfigs *txmgr.CLIConfig } @@ -105,6 +106,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name), IncludeParentMetaHash: c.Bool(flags.ProposeBlockIncludeParentMetaHash.Name), BlobAllowed: c.Bool(flags.BlobAllowed.Name), + RevertProtectionEnabled: c.Bool(flags.RevertProtectionEnabled.Name), TxmgrConfigs: pkgFlags.InitTxmgrConfigsFromCli( c.String(flags.L1WSEndpoint.Name), l1ProposerPrivKey, diff --git a/packages/taiko-client/proposer/proposer.go b/packages/taiko-client/proposer/proposer.go index bb6146a41bf..3ac58e51565 100644 --- a/packages/taiko-client/proposer/proposer.go +++ b/packages/taiko-client/proposer/proposer.go @@ -129,6 +129,7 @@ func (p *Proposer) InitFromConfig( cfg.ProposeBlockTxGasLimit, cfg.ExtraData, chainConfig, + cfg.RevertProtectionEnabled, ) } else { p.txBuilder = builder.NewCalldataTransactionBuilder( @@ -140,6 +141,7 @@ func (p *Proposer) InitFromConfig( cfg.ProposeBlockTxGasLimit, cfg.ExtraData, chainConfig, + cfg.RevertProtectionEnabled, ) } diff --git a/packages/taiko-client/proposer/proposer_test.go b/packages/taiko-client/proposer/proposer_test.go index 42e04020c45..afe34def3c3 100644 --- a/packages/taiko-client/proposer/proposer_test.go +++ b/packages/taiko-client/proposer/proposer_test.go @@ -258,6 +258,7 @@ func (s *ProposerTestSuite) TestProposeTxLists() { cfg.ProposeBlockTxGasLimit, cfg.ExtraData, config.NewChainConfig(s.p.protocolConfigs), + false, ) emptyTxListBytes, err := rlp.EncodeToBytes(types.Transactions{}) diff --git a/packages/taiko-client/proposer/transaction_builder/blob.go b/packages/taiko-client/proposer/transaction_builder/blob.go index 66ac14a1fd6..a2e7833c9a3 100644 --- a/packages/taiko-client/proposer/transaction_builder/blob.go +++ b/packages/taiko-client/proposer/transaction_builder/blob.go @@ -30,6 +30,7 @@ type BlobTransactionBuilder struct { gasLimit uint64 extraData string chainConfig *config.ChainConfig + revertProtectionEnabled bool } // NewBlobTransactionBuilder creates a new BlobTransactionBuilder instance based on giving configurations. @@ -42,6 +43,7 @@ func NewBlobTransactionBuilder( gasLimit uint64, extraData string, chainConfig *config.ChainConfig, + revertProtectionEnabled bool, ) *BlobTransactionBuilder { return &BlobTransactionBuilder{ rpc, @@ -52,6 +54,7 @@ func NewBlobTransactionBuilder( gasLimit, extraData, chainConfig, + revertProtectionEnabled, } } @@ -190,7 +193,11 @@ func (b *BlobTransactionBuilder) BuildOntake( } txListArray := make([][]byte, len(encodedParamsArray)) if b.proverSetAddress != rpc.ZeroAddress { - data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListArray) + if b.revertProtectionEnabled { + data, err = encoding.ProverSetABI.Pack("proposeBlocksV2Conditionally", encodedParamsArray, txListArray) + } else { + data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListArray) + } if err != nil { return nil, err } diff --git a/packages/taiko-client/proposer/transaction_builder/calldata.go b/packages/taiko-client/proposer/transaction_builder/calldata.go index 1eb7322967c..3c522120d7c 100644 --- a/packages/taiko-client/proposer/transaction_builder/calldata.go +++ b/packages/taiko-client/proposer/transaction_builder/calldata.go @@ -27,6 +27,7 @@ type CalldataTransactionBuilder struct { gasLimit uint64 extraData string chainConfig *config.ChainConfig + revertProtectionEnabled bool } // NewCalldataTransactionBuilder creates a new CalldataTransactionBuilder instance based on giving configurations. @@ -39,6 +40,7 @@ func NewCalldataTransactionBuilder( gasLimit uint64, extraData string, chainConfig *config.ChainConfig, + revertProtectionEnabled bool, ) *CalldataTransactionBuilder { return &CalldataTransactionBuilder{ rpc, @@ -49,6 +51,7 @@ func NewCalldataTransactionBuilder( gasLimit, extraData, chainConfig, + revertProtectionEnabled, } } @@ -157,8 +160,11 @@ func (b *CalldataTransactionBuilder) BuildOntake( if b.proverSetAddress != rpc.ZeroAddress { to = &b.proverSetAddress - - data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListBytesArray) + if b.revertProtectionEnabled { + data, err = encoding.ProverSetABI.Pack("proposeBlocksV2Conditionally", encodedParamsArray, txListBytesArray) + } else { + data, err = encoding.ProverSetABI.Pack("proposeBlocksV2", encodedParamsArray, txListBytesArray) + } if err != nil { return nil, err } diff --git a/packages/taiko-client/proposer/transaction_builder/common_test.go b/packages/taiko-client/proposer/transaction_builder/common_test.go index ec0bf0584a2..1c1c0e6a724 100644 --- a/packages/taiko-client/proposer/transaction_builder/common_test.go +++ b/packages/taiko-client/proposer/transaction_builder/common_test.go @@ -41,6 +41,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() { 0, "test", chainConfig, + false, ) s.blobTxBuiler = NewBlobTransactionBuilder( s.RPCClient, @@ -51,6 +52,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() { 10_000_000, "test", chainConfig, + false, ) }