From 75f19a22ee1fd9a13678bc8b43ba2d87b7d233d0 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 14 Jan 2024 09:22:19 +0800 Subject: [PATCH] feat(proposer): changes based on protocol `AssignmentHook` updates (#502) --- .github/workflows/test.yml | 2 +- bindings/.githead | 2 +- bindings/encoding/input.go | 8 ++++++++ bindings/encoding/input_test.go | 2 ++ bindings/gen_assignment_hook.go | 20 +++++++++---------- .../prover_selector/eth_fee_eoa_selector.go | 6 ++++++ prover/prover.go | 1 + prover/server/api.go | 2 ++ prover/server/server.go | 4 ++++ prover/server/server_test.go | 4 ++++ testutils/helper.go | 2 ++ 11 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f93e27ddb..9b5e6fc48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,7 @@ jobs: with: repository: taikoxyz/taiko-mono path: ${{ env.TAIKO_MONO_DIR }} - ref: based_contestable_zkrollup + ref: alpha-6 - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 diff --git a/bindings/.githead b/bindings/.githead index cd19ba01c..4046eb238 100644 --- a/bindings/.githead +++ b/bindings/.githead @@ -1 +1 @@ -fe9d8bea12c6d4e789a65e7d141af90f03981578 +08cab909e4cab27526b29226a22ea34675c2cc7e diff --git a/bindings/encoding/input.go b/bindings/encoding/input.go index fd9140ee1..5f35cb03d 100644 --- a/bindings/encoding/input.go +++ b/bindings/encoding/input.go @@ -241,7 +241,10 @@ var ( ) proverAssignmentPayloadArgs = abi.Arguments{ {Name: "PROVER_ASSIGNMENT", Type: stringType}, + {Name: "chainID", Type: uint64Type}, {Name: "taikoAddress", Type: addressType}, + {Name: "assignmentHookAddress", Type: addressType}, + {Name: "metaHash", Type: bytes32Type}, {Name: "blobHash", Type: bytes32Type}, {Name: "assignment.feeToken", Type: addressType}, {Name: "assignment.expiry", Type: uint64Type}, @@ -315,7 +318,9 @@ func EncodeAssignmentHookInput(input *AssignmentHookInput) ([]byte, error) { // EncodeProverAssignmentPayload performs the solidity `abi.encode` for the given proverAssignment payload. func EncodeProverAssignmentPayload( + chainID uint64, taikoAddress common.Address, + assignmentHookAddress common.Address, txListHash common.Hash, feeToken common.Address, expiry uint64, @@ -325,7 +330,10 @@ func EncodeProverAssignmentPayload( ) ([]byte, error) { b, err := proverAssignmentPayloadArgs.Pack( "PROVER_ASSIGNMENT", + chainID, taikoAddress, + assignmentHookAddress, + common.Hash{}, txListHash, feeToken, expiry, diff --git a/bindings/encoding/input_test.go b/bindings/encoding/input_test.go index 0415d77c4..07cc76707 100644 --- a/bindings/encoding/input_test.go +++ b/bindings/encoding/input_test.go @@ -18,6 +18,8 @@ import ( func TestEncodeProverAssignmentPayload(t *testing.T) { encoded, err := EncodeProverAssignmentPayload( + randomHash().Big().Uint64(), + common.BytesToAddress(randomBytes(20)), common.BytesToAddress(randomBytes(20)), common.BytesToHash(randomBytes(32)), common.BytesToAddress(randomBytes(20)), diff --git a/bindings/gen_assignment_hook.go b/bindings/gen_assignment_hook.go index e7673abdb..5e2e2c5d7 100644 --- a/bindings/gen_assignment_hook.go +++ b/bindings/gen_assignment_hook.go @@ -48,7 +48,7 @@ type TaikoDataTierFee struct { // AssignmentHookMetaData contains all meta data concerning the AssignmentHook contract. var AssignmentHookMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"MAX_GAS_PAYING_PROVER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"addressManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"hashAssignment\",\"inputs\":[{\"name\":\"assignment\",\"type\":\"tuple\",\"internalType\":\"structAssignmentHook.ProverAssignment\",\"components\":[{\"name\":\"feeToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"expiry\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxProposedIn\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"metaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"tierFees\",\"type\":\"tuple[]\",\"internalType\":\"structTaikoData.TierFee[]\",\"components\":[{\"name\":\"tier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"fee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}]},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"taikoAddress\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"blobHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"init\",\"inputs\":[{\"name\":\"_addressManager\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"onBlockProposed\",\"inputs\":[{\"name\":\"blk\",\"type\":\"tuple\",\"internalType\":\"structTaikoData.Block\",\"components\":[{\"name\":\"metaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"assignedProver\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"livenessBond\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"blockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"proposedAt\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"proposedIn\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nextTransitionId\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"verifiedTransitionId\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"__reserved\",\"type\":\"bytes32[7]\",\"internalType\":\"bytes32[7]\"}]},{\"name\":\"meta\",\"type\":\"tuple\",\"internalType\":\"structTaikoData.BlockMetadata\",\"components\":[{\"name\":\"l1Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"difficulty\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blobHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extraData\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"depositsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"coinbase\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"id\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"l1Height\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"txListByteOffset\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"txListByteSize\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"minTier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"blobUsed\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"parentMetaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"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\":\"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\":\"addr\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"resolve\",\"inputs\":[{\"name\":\"name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"allowZeroAddress\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[{\"name\":\"addr\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"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\":\"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\":\"BlockAssigned\",\"inputs\":[{\"name\":\"assignedProver\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"meta\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structTaikoData.BlockMetadata\",\"components\":[{\"name\":\"l1Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"difficulty\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blobHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extraData\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"depositsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"coinbase\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"id\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"l1Height\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"txListByteOffset\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"txListByteSize\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"minTier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"blobUsed\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"parentMetaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"assignment\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structAssignmentHook.ProverAssignment\",\"components\":[{\"name\":\"feeToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"expiry\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxProposedIn\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"metaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"tierFees\",\"type\":\"tuple[]\",\"internalType\":\"structTaikoData.TierFee[]\",\"components\":[{\"name\":\"tier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"fee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}]},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"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\":\"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\":\"HOOK_ASSIGNMENT_EXPIRED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"HOOK_ASSIGNMENT_INSUFFICIENT_FEE\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"HOOK_ASSIGNMENT_INVALID_SIG\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"HOOK_TIER_NOT_FOUND\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_PAUSE_STATUS\",\"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\":\"string\",\"internalType\":\"string\"}]}]", + ABI: "[{\"type\":\"function\",\"name\":\"MAX_GAS_PAYING_PROVER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"addressManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"hashAssignment\",\"inputs\":[{\"name\":\"assignment\",\"type\":\"tuple\",\"internalType\":\"structAssignmentHook.ProverAssignment\",\"components\":[{\"name\":\"feeToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"expiry\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxProposedIn\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"metaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"tierFees\",\"type\":\"tuple[]\",\"internalType\":\"structTaikoData.TierFee[]\",\"components\":[{\"name\":\"tier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"fee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}]},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"taikoL1Address\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"blobHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"init\",\"inputs\":[{\"name\":\"_addressManager\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"onBlockProposed\",\"inputs\":[{\"name\":\"blk\",\"type\":\"tuple\",\"internalType\":\"structTaikoData.Block\",\"components\":[{\"name\":\"metaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"assignedProver\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"livenessBond\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"blockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"proposedAt\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"proposedIn\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nextTransitionId\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"verifiedTransitionId\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"__reserved\",\"type\":\"bytes32[7]\",\"internalType\":\"bytes32[7]\"}]},{\"name\":\"meta\",\"type\":\"tuple\",\"internalType\":\"structTaikoData.BlockMetadata\",\"components\":[{\"name\":\"l1Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"difficulty\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blobHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extraData\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"depositsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"coinbase\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"id\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"l1Height\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"txListByteOffset\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"txListByteSize\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"minTier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"blobUsed\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"parentMetaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"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\":\"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\":\"addr\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"resolve\",\"inputs\":[{\"name\":\"name\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"allowZeroAddress\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[{\"name\":\"addr\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"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\":\"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\":\"BlockAssigned\",\"inputs\":[{\"name\":\"assignedProver\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"meta\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structTaikoData.BlockMetadata\",\"components\":[{\"name\":\"l1Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"difficulty\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blobHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extraData\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"depositsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"coinbase\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"id\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"gasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"l1Height\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"txListByteOffset\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"txListByteSize\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"minTier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"blobUsed\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"parentMetaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"assignment\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structAssignmentHook.ProverAssignment\",\"components\":[{\"name\":\"feeToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"expiry\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxProposedIn\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"metaHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"tierFees\",\"type\":\"tuple[]\",\"internalType\":\"structTaikoData.TierFee[]\",\"components\":[{\"name\":\"tier\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"fee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}]},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"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\":\"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\":\"HOOK_ASSIGNMENT_EXPIRED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"HOOK_ASSIGNMENT_INSUFFICIENT_FEE\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"HOOK_ASSIGNMENT_INVALID_SIG\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"HOOK_TIER_NOT_FOUND\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_PAUSE_STATUS\",\"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\":\"string\",\"internalType\":\"string\"}]}]", } // AssignmentHookABI is the input ABI used to generate the binding from. @@ -261,10 +261,10 @@ func (_AssignmentHook *AssignmentHookCallerSession) AddressManager() (common.Add // HashAssignment is a free data retrieval call binding the contract method 0x9f64a349. // -// Solidity: function hashAssignment((address,uint64,uint64,uint64,bytes32,(uint16,uint128)[],bytes) assignment, address taikoAddress, bytes32 blobHash) pure returns(bytes32) -func (_AssignmentHook *AssignmentHookCaller) HashAssignment(opts *bind.CallOpts, assignment AssignmentHookProverAssignment, taikoAddress common.Address, blobHash [32]byte) ([32]byte, error) { +// Solidity: function hashAssignment((address,uint64,uint64,uint64,bytes32,(uint16,uint128)[],bytes) assignment, address taikoL1Address, bytes32 blobHash) view returns(bytes32) +func (_AssignmentHook *AssignmentHookCaller) HashAssignment(opts *bind.CallOpts, assignment AssignmentHookProverAssignment, taikoL1Address common.Address, blobHash [32]byte) ([32]byte, error) { var out []interface{} - err := _AssignmentHook.contract.Call(opts, &out, "hashAssignment", assignment, taikoAddress, blobHash) + err := _AssignmentHook.contract.Call(opts, &out, "hashAssignment", assignment, taikoL1Address, blobHash) if err != nil { return *new([32]byte), err @@ -278,16 +278,16 @@ func (_AssignmentHook *AssignmentHookCaller) HashAssignment(opts *bind.CallOpts, // HashAssignment is a free data retrieval call binding the contract method 0x9f64a349. // -// Solidity: function hashAssignment((address,uint64,uint64,uint64,bytes32,(uint16,uint128)[],bytes) assignment, address taikoAddress, bytes32 blobHash) pure returns(bytes32) -func (_AssignmentHook *AssignmentHookSession) HashAssignment(assignment AssignmentHookProverAssignment, taikoAddress common.Address, blobHash [32]byte) ([32]byte, error) { - return _AssignmentHook.Contract.HashAssignment(&_AssignmentHook.CallOpts, assignment, taikoAddress, blobHash) +// Solidity: function hashAssignment((address,uint64,uint64,uint64,bytes32,(uint16,uint128)[],bytes) assignment, address taikoL1Address, bytes32 blobHash) view returns(bytes32) +func (_AssignmentHook *AssignmentHookSession) HashAssignment(assignment AssignmentHookProverAssignment, taikoL1Address common.Address, blobHash [32]byte) ([32]byte, error) { + return _AssignmentHook.Contract.HashAssignment(&_AssignmentHook.CallOpts, assignment, taikoL1Address, blobHash) } // HashAssignment is a free data retrieval call binding the contract method 0x9f64a349. // -// Solidity: function hashAssignment((address,uint64,uint64,uint64,bytes32,(uint16,uint128)[],bytes) assignment, address taikoAddress, bytes32 blobHash) pure returns(bytes32) -func (_AssignmentHook *AssignmentHookCallerSession) HashAssignment(assignment AssignmentHookProverAssignment, taikoAddress common.Address, blobHash [32]byte) ([32]byte, error) { - return _AssignmentHook.Contract.HashAssignment(&_AssignmentHook.CallOpts, assignment, taikoAddress, blobHash) +// Solidity: function hashAssignment((address,uint64,uint64,uint64,bytes32,(uint16,uint128)[],bytes) assignment, address taikoL1Address, bytes32 blobHash) view returns(bytes32) +func (_AssignmentHook *AssignmentHookCallerSession) HashAssignment(assignment AssignmentHookProverAssignment, taikoL1Address common.Address, blobHash [32]byte) ([32]byte, error) { + return _AssignmentHook.Contract.HashAssignment(&_AssignmentHook.CallOpts, assignment, taikoL1Address, blobHash) } // Owner is a free data retrieval call binding the contract method 0x8da5cb5b. diff --git a/proposer/prover_selector/eth_fee_eoa_selector.go b/proposer/prover_selector/eth_fee_eoa_selector.go index 80df4e5f0..28c14bdee 100644 --- a/proposer/prover_selector/eth_fee_eoa_selector.go +++ b/proposer/prover_selector/eth_fee_eoa_selector.go @@ -124,10 +124,12 @@ func (s *ETHFeeEOASelector) AssignProver( for _, endpoint := range s.shuffleProverEndpoints() { encodedAssignment, proverAddress, err := assignProver( ctx, + s.protocolConfigs.ChainId, endpoint, expiry, tierFees, s.taikoL1Address, + s.assignmentHookAddress, txListHash, s.requestTimeout, guardianProverAddress, @@ -174,10 +176,12 @@ func (s *ETHFeeEOASelector) shuffleProverEndpoints() []*url.URL { // assignProver tries to assign a proof generation task to the given prover by HTTP API. func assignProver( ctx context.Context, + chainID uint64, endpoint *url.URL, expiry uint64, tierFees []encoding.TierFee, taikoL1Address common.Address, + assignmentHookAddress common.Address, txListHash common.Hash, timeout time.Duration, guardianProverAddress common.Address, @@ -225,7 +229,9 @@ func assignProver( // Ensure prover in response is the same as the one recovered // from the signature payload, err := encoding.EncodeProverAssignmentPayload( + chainID, taikoL1Address, + assignmentHookAddress, txListHash, common.Address{}, expiry, diff --git a/prover/prover.go b/prover/prover.go index 75058d0e2..586c92a35 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -287,6 +287,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { AssignmentHookAddress: p.cfg.AssignmentHookAddress, ProposeConcurrencyGuard: p.proposeConcurrencyGuard, Rpc: p.rpc, + ProtocolConfigs: &protocolConfigs, LivenessBond: protocolConfigs.LivenessBond, IsGuardian: p.IsGuardianProver(), DB: db, diff --git a/prover/server/api.go b/prover/server/api.go index c29728bb8..7daa04c48 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -180,7 +180,9 @@ func (srv *ProverServer) CreateAssignment(c echo.Context) error { } encoded, err := encoding.EncodeProverAssignmentPayload( + srv.protocolConfigs.ChainId, srv.taikoL1Address, + srv.assignmentHookAddress, req.TxListHash, req.FeeToken, req.Expiry, diff --git a/prover/server/server.go b/prover/server/server.go index b65e04ca6..5a543fbe1 100644 --- a/prover/server/server.go +++ b/prover/server/server.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" echo "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "github.com/taikoxyz/taiko-client/bindings" "github.com/taikoxyz/taiko-client/pkg/rpc" ) @@ -44,6 +45,7 @@ type ProverServer struct { taikoL1Address common.Address assignmentHookAddress common.Address rpc *rpc.Client + protocolConfigs *bindings.TaikoDataConfig livenessBond *big.Int isGuardian bool db ethdb.KeyValueStore @@ -63,6 +65,7 @@ type NewProverServerOpts struct { TaikoL1Address common.Address AssignmentHookAddress common.Address Rpc *rpc.Client + ProtocolConfigs *bindings.TaikoDataConfig LivenessBond *big.Int IsGuardian bool DB ethdb.KeyValueStore @@ -85,6 +88,7 @@ func New(opts *NewProverServerOpts) (*ProverServer, error) { taikoL1Address: opts.TaikoL1Address, assignmentHookAddress: opts.AssignmentHookAddress, rpc: opts.Rpc, + protocolConfigs: opts.ProtocolConfigs, livenessBond: opts.LivenessBond, isGuardian: opts.IsGuardian, db: opts.DB, diff --git a/prover/server/server_test.go b/prover/server/server_test.go index fa506ff2d..0d8a534ca 100644 --- a/prover/server/server_test.go +++ b/prover/server/server_test.go @@ -45,6 +45,9 @@ func (s *ProverServerTestSuite) SetupTest() { }) s.Nil(err) + configs, err := rpcClient.TaikoL1.GetConfig(nil) + s.Nil(err) + p, err := New(&NewProverServerOpts{ ProverPrivateKey: l1ProverPrivKey, MinOptimisticTierFee: common.Big1, @@ -56,6 +59,7 @@ func (s *ProverServerTestSuite) SetupTest() { TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), Rpc: rpcClient, + ProtocolConfigs: &configs, LivenessBond: common.Big0, IsGuardian: false, DB: memorydb.New(), diff --git a/testutils/helper.go b/testutils/helper.go index edb29f7a6..6f2cde7f0 100644 --- a/testutils/helper.go +++ b/testutils/helper.go @@ -187,8 +187,10 @@ func NewTestProverServer( MinSgxAndPseZkevmTierFee: common.Big1, MaxExpiry: 24 * time.Hour, TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), + AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), ProposeConcurrencyGuard: make(chan struct{}, 1024), Rpc: s.RpcClient, + ProtocolConfigs: &protocolConfig, LivenessBond: protocolConfig.LivenessBond, IsGuardian: true, })