From 4abfaa9e28a619c1edfa82548a00eae0790f784b Mon Sep 17 00:00:00 2001 From: David Date: Fri, 27 Dec 2024 14:32:21 +0800 Subject: [PATCH] feat(taiko-client): introduce `TaikoL2.GetBasefeeV2` (#18660) Co-authored-by: Gavin Yu --- packages/taiko-client/bindings/.githead | 2 +- .../taiko-client/bindings/gen_taiko_l2.go | 241 +++++++++++++++--- .../bindings/gen_tier_provider.go | 20 +- packages/taiko-client/pkg/rpc/methods.go | 122 +++++---- 4 files changed, 283 insertions(+), 102 deletions(-) diff --git a/packages/taiko-client/bindings/.githead b/packages/taiko-client/bindings/.githead index 9780dac6ea3..98f65e8ed31 100644 --- a/packages/taiko-client/bindings/.githead +++ b/packages/taiko-client/bindings/.githead @@ -1 +1 @@ -ab50d406172e879e7436c70a41bda674bfc6e441 +8d2cca11180bd615420e9bb3287f31a9ddf18df8 diff --git a/packages/taiko-client/bindings/gen_taiko_l2.go b/packages/taiko-client/bindings/gen_taiko_l2.go index 9b3a541d934..62c3cfb6885 100644 --- a/packages/taiko-client/bindings/gen_taiko_l2.go +++ b/packages/taiko-client/bindings/gen_taiko_l2.go @@ -31,7 +31,7 @@ var ( // TaikoL2ClientMetaData contains all meta data concerning the TaikoL2Client contract. var TaikoL2ClientMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"GOLDEN_TOUCH_ADDRESS\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"acceptOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"addressManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"adjustExcess\",\"inputs\":[{\"name\":\"_currGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_currGasTarget\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_newGasTarget\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"newGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"anchor\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_l1StateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_l1BlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"anchorV2\",\"inputs\":[{\"name\":\"_anchorBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_anchorStateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_baseFeeConfig\",\"type\":\"tuple\",\"internalType\":\"structLibSharedData.BaseFeeConfig\",\"components\":[{\"name\":\"adjustmentQuotient\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"sharingPctg\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"gasIssuancePerSecond\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"minGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxGasIssuancePerBlock\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"calculateBaseFee\",\"inputs\":[{\"name\":\"_baseFeeConfig\",\"type\":\"tuple\",\"internalType\":\"structLibSharedData.BaseFeeConfig\",\"components\":[{\"name\":\"adjustmentQuotient\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"sharingPctg\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"gasIssuancePerSecond\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"minGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxGasIssuancePerBlock\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"_blocktime\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[{\"name\":\"basefee_\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"parentGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getBasefee\",\"inputs\":[{\"name\":\"_anchorBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[{\"name\":\"basefee_\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"parentGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlockHash\",\"inputs\":[{\"name\":\"_blockId\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getParentTimestamp\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"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\":\"_rollupAddressManager\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1ChainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_initialGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"l1ChainId\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"lastSyncedBlock\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"lastUnpausedAt\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ontakeForkHeight\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parentGasExcess\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parentGasTarget\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parentTimestamp\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"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\":\"proxiableUUID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"publicInputHash\",\"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\":\"skipFeeCheck\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"pure\"},{\"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\":\"withdraw\",\"inputs\":[{\"name\":\"_token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"}],\"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\":\"Anchored\",\"inputs\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"parentGasExcess\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"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\":\"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\":\"EIP1559_INVALID_PARAMS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ETH_TRANSFER_FAILED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FUNC_NOT_IMPLEMENTED\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"INVALID_PAUSE_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_BASEFEE_MISMATCH\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_FORK_ERROR\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_L1_CHAIN_ID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_L2_CHAIN_ID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_PARAM\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_SENDER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_PUBLIC_INPUT_HASH_MISMATCH\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_TOO_LATE\",\"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\":\"GOLDEN_TOUCH_ADDRESS\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"acceptOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"addressManager\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"adjustExcess\",\"inputs\":[{\"name\":\"_currGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_currGasTarget\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_newGasTarget\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"newGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"anchor\",\"inputs\":[{\"name\":\"_l1BlockHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_l1StateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_l1BlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"anchorV2\",\"inputs\":[{\"name\":\"_anchorBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_anchorStateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_baseFeeConfig\",\"type\":\"tuple\",\"internalType\":\"structLibSharedData.BaseFeeConfig\",\"components\":[{\"name\":\"adjustmentQuotient\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"sharingPctg\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"gasIssuancePerSecond\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"minGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxGasIssuancePerBlock\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"calculateBaseFee\",\"inputs\":[{\"name\":\"_baseFeeConfig\",\"type\":\"tuple\",\"internalType\":\"structLibSharedData.BaseFeeConfig\",\"components\":[{\"name\":\"adjustmentQuotient\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"sharingPctg\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"gasIssuancePerSecond\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"minGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxGasIssuancePerBlock\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"_blocktime\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[{\"name\":\"basefee_\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"parentGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getBasefee\",\"inputs\":[{\"name\":\"_anchorBlockId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[{\"name\":\"basefee_\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"parentGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getBasefeeV2\",\"inputs\":[{\"name\":\"_parentGasUsed\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_baseFeeConfig\",\"type\":\"tuple\",\"internalType\":\"structLibSharedData.BaseFeeConfig\",\"components\":[{\"name\":\"adjustmentQuotient\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"sharingPctg\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"gasIssuancePerSecond\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"minGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxGasIssuancePerBlock\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}],\"outputs\":[{\"name\":\"basefee_\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"newGasTarget_\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"newGasExcess_\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlockHash\",\"inputs\":[{\"name\":\"_blockId\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"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\":\"_rollupAddressManager\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l1ChainId\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"_initialGasExcess\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"l1ChainId\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"lastSyncedBlock\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"lastUnpausedAt\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ontakeForkHeight\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parentGasExcess\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parentGasTarget\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parentTimestamp\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"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\":\"proxiableUUID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"publicInputHash\",\"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\":\"skipFeeCheck\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"pure\"},{\"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\":\"withdraw\",\"inputs\":[{\"name\":\"_token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"}],\"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\":\"Anchored\",\"inputs\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"parentGasExcess\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"BeaconUpgraded\",\"inputs\":[{\"name\":\"beacon\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"EIP1559Update\",\"inputs\":[{\"name\":\"oldGasTarget\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"newGasTarget\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"oldGasExcess\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"newGasExcess\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"basefee\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"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\":\"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_PAUSE_STATUS\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_BASEFEE_MISMATCH\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_DEPRECATED_METHOD\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_FORK_ERROR\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_L1_CHAIN_ID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_L2_CHAIN_ID\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_PARAM\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_INVALID_SENDER\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_PUBLIC_INPUT_HASH_MISMATCH\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"L2_TOO_LATE\",\"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\":[]}]", } // TaikoL2ClientABI is the input ABI used to generate the binding from. @@ -320,7 +320,7 @@ func (_TaikoL2Client *TaikoL2ClientCallerSession) CalculateBaseFee(_baseFeeConfi // GetBasefee is a free data retrieval call binding the contract method 0xa7e022d1. // -// Solidity: function getBasefee(uint64 _anchorBlockId, uint32 _parentGasUsed) view returns(uint256 basefee_, uint64 parentGasExcess_) +// Solidity: function getBasefee(uint64 _anchorBlockId, uint32 _parentGasUsed) pure returns(uint256 basefee_, uint64 parentGasExcess_) func (_TaikoL2Client *TaikoL2ClientCaller) GetBasefee(opts *bind.CallOpts, _anchorBlockId uint64, _parentGasUsed uint32) (struct { Basefee *big.Int ParentGasExcess uint64 @@ -345,7 +345,7 @@ func (_TaikoL2Client *TaikoL2ClientCaller) GetBasefee(opts *bind.CallOpts, _anch // GetBasefee is a free data retrieval call binding the contract method 0xa7e022d1. // -// Solidity: function getBasefee(uint64 _anchorBlockId, uint32 _parentGasUsed) view returns(uint256 basefee_, uint64 parentGasExcess_) +// Solidity: function getBasefee(uint64 _anchorBlockId, uint32 _parentGasUsed) pure returns(uint256 basefee_, uint64 parentGasExcess_) func (_TaikoL2Client *TaikoL2ClientSession) GetBasefee(_anchorBlockId uint64, _parentGasUsed uint32) (struct { Basefee *big.Int ParentGasExcess uint64 @@ -355,7 +355,7 @@ func (_TaikoL2Client *TaikoL2ClientSession) GetBasefee(_anchorBlockId uint64, _p // GetBasefee is a free data retrieval call binding the contract method 0xa7e022d1. // -// Solidity: function getBasefee(uint64 _anchorBlockId, uint32 _parentGasUsed) view returns(uint256 basefee_, uint64 parentGasExcess_) +// Solidity: function getBasefee(uint64 _anchorBlockId, uint32 _parentGasUsed) pure returns(uint256 basefee_, uint64 parentGasExcess_) func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBasefee(_anchorBlockId uint64, _parentGasUsed uint32) (struct { Basefee *big.Int ParentGasExcess uint64 @@ -363,66 +363,85 @@ func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBasefee(_anchorBlockId uint return _TaikoL2Client.Contract.GetBasefee(&_TaikoL2Client.CallOpts, _anchorBlockId, _parentGasUsed) } -// GetBlockHash is a free data retrieval call binding the contract method 0xee82ac5e. +// GetBasefeeV2 is a free data retrieval call binding the contract method 0xc97157b6. // -// Solidity: function getBlockHash(uint256 _blockId) view returns(bytes32) -func (_TaikoL2Client *TaikoL2ClientCaller) GetBlockHash(opts *bind.CallOpts, _blockId *big.Int) ([32]byte, error) { +// Solidity: function getBasefeeV2(uint32 _parentGasUsed, (uint8,uint8,uint32,uint64,uint32) _baseFeeConfig) view returns(uint256 basefee_, uint64 newGasTarget_, uint64 newGasExcess_) +func (_TaikoL2Client *TaikoL2ClientCaller) GetBasefeeV2(opts *bind.CallOpts, _parentGasUsed uint32, _baseFeeConfig LibSharedDataBaseFeeConfig) (struct { + Basefee *big.Int + NewGasTarget uint64 + NewGasExcess uint64 +}, error) { var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "getBlockHash", _blockId) + err := _TaikoL2Client.contract.Call(opts, &out, "getBasefeeV2", _parentGasUsed, _baseFeeConfig) + outstruct := new(struct { + Basefee *big.Int + NewGasTarget uint64 + NewGasExcess uint64 + }) if err != nil { - return *new([32]byte), err + return *outstruct, err } - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Basefee = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.NewGasTarget = *abi.ConvertType(out[1], new(uint64)).(*uint64) + outstruct.NewGasExcess = *abi.ConvertType(out[2], new(uint64)).(*uint64) - return out0, err + return *outstruct, err } -// GetBlockHash is a free data retrieval call binding the contract method 0xee82ac5e. +// GetBasefeeV2 is a free data retrieval call binding the contract method 0xc97157b6. // -// Solidity: function getBlockHash(uint256 _blockId) view returns(bytes32) -func (_TaikoL2Client *TaikoL2ClientSession) GetBlockHash(_blockId *big.Int) ([32]byte, error) { - return _TaikoL2Client.Contract.GetBlockHash(&_TaikoL2Client.CallOpts, _blockId) +// Solidity: function getBasefeeV2(uint32 _parentGasUsed, (uint8,uint8,uint32,uint64,uint32) _baseFeeConfig) view returns(uint256 basefee_, uint64 newGasTarget_, uint64 newGasExcess_) +func (_TaikoL2Client *TaikoL2ClientSession) GetBasefeeV2(_parentGasUsed uint32, _baseFeeConfig LibSharedDataBaseFeeConfig) (struct { + Basefee *big.Int + NewGasTarget uint64 + NewGasExcess uint64 +}, error) { + return _TaikoL2Client.Contract.GetBasefeeV2(&_TaikoL2Client.CallOpts, _parentGasUsed, _baseFeeConfig) } -// GetBlockHash is a free data retrieval call binding the contract method 0xee82ac5e. +// GetBasefeeV2 is a free data retrieval call binding the contract method 0xc97157b6. // -// Solidity: function getBlockHash(uint256 _blockId) view returns(bytes32) -func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBlockHash(_blockId *big.Int) ([32]byte, error) { - return _TaikoL2Client.Contract.GetBlockHash(&_TaikoL2Client.CallOpts, _blockId) +// Solidity: function getBasefeeV2(uint32 _parentGasUsed, (uint8,uint8,uint32,uint64,uint32) _baseFeeConfig) view returns(uint256 basefee_, uint64 newGasTarget_, uint64 newGasExcess_) +func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBasefeeV2(_parentGasUsed uint32, _baseFeeConfig LibSharedDataBaseFeeConfig) (struct { + Basefee *big.Int + NewGasTarget uint64 + NewGasExcess uint64 +}, error) { + return _TaikoL2Client.Contract.GetBasefeeV2(&_TaikoL2Client.CallOpts, _parentGasUsed, _baseFeeConfig) } -// GetParentTimestamp is a free data retrieval call binding the contract method 0xa578781e. +// GetBlockHash is a free data retrieval call binding the contract method 0xee82ac5e. // -// Solidity: function getParentTimestamp() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientCaller) GetParentTimestamp(opts *bind.CallOpts) (uint64, error) { +// Solidity: function getBlockHash(uint256 _blockId) view returns(bytes32) +func (_TaikoL2Client *TaikoL2ClientCaller) GetBlockHash(opts *bind.CallOpts, _blockId *big.Int) ([32]byte, error) { var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "getParentTimestamp") + err := _TaikoL2Client.contract.Call(opts, &out, "getBlockHash", _blockId) if err != nil { - return *new(uint64), err + return *new([32]byte), err } - out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) return out0, err } -// GetParentTimestamp is a free data retrieval call binding the contract method 0xa578781e. +// GetBlockHash is a free data retrieval call binding the contract method 0xee82ac5e. // -// Solidity: function getParentTimestamp() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientSession) GetParentTimestamp() (uint64, error) { - return _TaikoL2Client.Contract.GetParentTimestamp(&_TaikoL2Client.CallOpts) +// Solidity: function getBlockHash(uint256 _blockId) view returns(bytes32) +func (_TaikoL2Client *TaikoL2ClientSession) GetBlockHash(_blockId *big.Int) ([32]byte, error) { + return _TaikoL2Client.Contract.GetBlockHash(&_TaikoL2Client.CallOpts, _blockId) } -// GetParentTimestamp is a free data retrieval call binding the contract method 0xa578781e. +// GetBlockHash is a free data retrieval call binding the contract method 0xee82ac5e. // -// Solidity: function getParentTimestamp() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientCallerSession) GetParentTimestamp() (uint64, error) { - return _TaikoL2Client.Contract.GetParentTimestamp(&_TaikoL2Client.CallOpts) +// Solidity: function getBlockHash(uint256 _blockId) view returns(bytes32) +func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBlockHash(_blockId *big.Int) ([32]byte, error) { + return _TaikoL2Client.Contract.GetBlockHash(&_TaikoL2Client.CallOpts, _blockId) } // Impl is a free data retrieval call binding the contract method 0x8abf6077. @@ -975,23 +994,23 @@ func (_TaikoL2Client *TaikoL2ClientTransactorSession) AcceptOwnership() (*types. // Anchor is a paid mutator transaction binding the contract method 0xda69d3db. // -// Solidity: function anchor(bytes32 , bytes32 _l1StateRoot, uint64 _l1BlockId, uint32 _parentGasUsed) returns() -func (_TaikoL2Client *TaikoL2ClientTransactor) Anchor(opts *bind.TransactOpts, arg0 [32]byte, _l1StateRoot [32]byte, _l1BlockId uint64, _parentGasUsed uint32) (*types.Transaction, error) { - return _TaikoL2Client.contract.Transact(opts, "anchor", arg0, _l1StateRoot, _l1BlockId, _parentGasUsed) +// Solidity: function anchor(bytes32 _l1BlockHash, bytes32 _l1StateRoot, uint64 _l1BlockId, uint32 _parentGasUsed) returns() +func (_TaikoL2Client *TaikoL2ClientTransactor) Anchor(opts *bind.TransactOpts, _l1BlockHash [32]byte, _l1StateRoot [32]byte, _l1BlockId uint64, _parentGasUsed uint32) (*types.Transaction, error) { + return _TaikoL2Client.contract.Transact(opts, "anchor", _l1BlockHash, _l1StateRoot, _l1BlockId, _parentGasUsed) } // Anchor is a paid mutator transaction binding the contract method 0xda69d3db. // -// Solidity: function anchor(bytes32 , bytes32 _l1StateRoot, uint64 _l1BlockId, uint32 _parentGasUsed) returns() -func (_TaikoL2Client *TaikoL2ClientSession) Anchor(arg0 [32]byte, _l1StateRoot [32]byte, _l1BlockId uint64, _parentGasUsed uint32) (*types.Transaction, error) { - return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, arg0, _l1StateRoot, _l1BlockId, _parentGasUsed) +// Solidity: function anchor(bytes32 _l1BlockHash, bytes32 _l1StateRoot, uint64 _l1BlockId, uint32 _parentGasUsed) returns() +func (_TaikoL2Client *TaikoL2ClientSession) Anchor(_l1BlockHash [32]byte, _l1StateRoot [32]byte, _l1BlockId uint64, _parentGasUsed uint32) (*types.Transaction, error) { + return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, _l1BlockHash, _l1StateRoot, _l1BlockId, _parentGasUsed) } // Anchor is a paid mutator transaction binding the contract method 0xda69d3db. // -// Solidity: function anchor(bytes32 , bytes32 _l1StateRoot, uint64 _l1BlockId, uint32 _parentGasUsed) returns() -func (_TaikoL2Client *TaikoL2ClientTransactorSession) Anchor(arg0 [32]byte, _l1StateRoot [32]byte, _l1BlockId uint64, _parentGasUsed uint32) (*types.Transaction, error) { - return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, arg0, _l1StateRoot, _l1BlockId, _parentGasUsed) +// Solidity: function anchor(bytes32 _l1BlockHash, bytes32 _l1StateRoot, uint64 _l1BlockId, uint32 _parentGasUsed) returns() +func (_TaikoL2Client *TaikoL2ClientTransactorSession) Anchor(_l1BlockHash [32]byte, _l1StateRoot [32]byte, _l1BlockId uint64, _parentGasUsed uint32) (*types.Transaction, error) { + return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, _l1BlockHash, _l1StateRoot, _l1BlockId, _parentGasUsed) } // AnchorV2 is a paid mutator transaction binding the contract method 0xfd85eb2d. @@ -1597,6 +1616,144 @@ func (_TaikoL2Client *TaikoL2ClientFilterer) ParseBeaconUpgraded(log types.Log) return event, nil } +// TaikoL2ClientEIP1559UpdateIterator is returned from FilterEIP1559Update and is used to iterate over the raw logs and unpacked data for EIP1559Update events raised by the TaikoL2Client contract. +type TaikoL2ClientEIP1559UpdateIterator struct { + Event *TaikoL2ClientEIP1559Update // 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 *TaikoL2ClientEIP1559UpdateIterator) 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(TaikoL2ClientEIP1559Update) + 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(TaikoL2ClientEIP1559Update) + 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 *TaikoL2ClientEIP1559UpdateIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TaikoL2ClientEIP1559UpdateIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TaikoL2ClientEIP1559Update represents a EIP1559Update event raised by the TaikoL2Client contract. +type TaikoL2ClientEIP1559Update struct { + OldGasTarget uint64 + NewGasTarget uint64 + OldGasExcess uint64 + NewGasExcess uint64 + Basefee *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterEIP1559Update is a free log retrieval operation binding the contract event 0x781ae5c2215806150d5c71a4ed5336e5dc3ad32aef04fc0f626a6ee0c2f8d1c8. +// +// Solidity: event EIP1559Update(uint64 oldGasTarget, uint64 newGasTarget, uint64 oldGasExcess, uint64 newGasExcess, uint256 basefee) +func (_TaikoL2Client *TaikoL2ClientFilterer) FilterEIP1559Update(opts *bind.FilterOpts) (*TaikoL2ClientEIP1559UpdateIterator, error) { + + logs, sub, err := _TaikoL2Client.contract.FilterLogs(opts, "EIP1559Update") + if err != nil { + return nil, err + } + return &TaikoL2ClientEIP1559UpdateIterator{contract: _TaikoL2Client.contract, event: "EIP1559Update", logs: logs, sub: sub}, nil +} + +// WatchEIP1559Update is a free log subscription operation binding the contract event 0x781ae5c2215806150d5c71a4ed5336e5dc3ad32aef04fc0f626a6ee0c2f8d1c8. +// +// Solidity: event EIP1559Update(uint64 oldGasTarget, uint64 newGasTarget, uint64 oldGasExcess, uint64 newGasExcess, uint256 basefee) +func (_TaikoL2Client *TaikoL2ClientFilterer) WatchEIP1559Update(opts *bind.WatchOpts, sink chan<- *TaikoL2ClientEIP1559Update) (event.Subscription, error) { + + logs, sub, err := _TaikoL2Client.contract.WatchLogs(opts, "EIP1559Update") + 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(TaikoL2ClientEIP1559Update) + if err := _TaikoL2Client.contract.UnpackLog(event, "EIP1559Update", 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 +} + +// ParseEIP1559Update is a log parse operation binding the contract event 0x781ae5c2215806150d5c71a4ed5336e5dc3ad32aef04fc0f626a6ee0c2f8d1c8. +// +// Solidity: event EIP1559Update(uint64 oldGasTarget, uint64 newGasTarget, uint64 oldGasExcess, uint64 newGasExcess, uint256 basefee) +func (_TaikoL2Client *TaikoL2ClientFilterer) ParseEIP1559Update(log types.Log) (*TaikoL2ClientEIP1559Update, error) { + event := new(TaikoL2ClientEIP1559Update) + if err := _TaikoL2Client.contract.UnpackLog(event, "EIP1559Update", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // TaikoL2ClientInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the TaikoL2Client contract. type TaikoL2ClientInitializedIterator struct { Event *TaikoL2ClientInitialized // Event containing the contract specifics and raw log diff --git a/packages/taiko-client/bindings/gen_tier_provider.go b/packages/taiko-client/bindings/gen_tier_provider.go index bbff66971f6..e0449320610 100644 --- a/packages/taiko-client/bindings/gen_tier_provider.go +++ b/packages/taiko-client/bindings/gen_tier_provider.go @@ -41,7 +41,7 @@ type ITierProviderTier struct { // TierProviderMetaData contains all meta data concerning the TierProvider contract. var TierProviderMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_daoFallbackProposer\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"BOND_UNIT\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint96\",\"internalType\":\"uint96\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"DAO_FALLBACK_PROPOSER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getMinTier\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getProvider\",\"inputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getTier\",\"inputs\":[{\"name\":\"_tierId\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structITierProvider.Tier\",\"components\":[{\"name\":\"verifierName\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"validityBond\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"contestBond\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"cooldownWindow\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"provingWindow\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"maxBlocksToVerifyPerProof\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getTierIds\",\"inputs\":[],\"outputs\":[{\"name\":\"tiers_\",\"type\":\"uint16[]\",\"internalType\":\"uint16[]\"}],\"stateMutability\":\"pure\"},{\"type\":\"error\",\"name\":\"TIER_NOT_FOUND\",\"inputs\":[]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_daoFallbackProposer\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"BOND_UNIT\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint96\",\"internalType\":\"uint96\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"DAO_FALLBACK_PROPOSER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getMinTier\",\"inputs\":[{\"name\":\"_proposer\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_rand\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getProvider\",\"inputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getTier\",\"inputs\":[{\"name\":\"_tierId\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structITierProvider.Tier\",\"components\":[{\"name\":\"verifierName\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"validityBond\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"contestBond\",\"type\":\"uint96\",\"internalType\":\"uint96\"},{\"name\":\"cooldownWindow\",\"type\":\"uint24\",\"internalType\":\"uint24\"},{\"name\":\"provingWindow\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"maxBlocksToVerifyPerProof\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getTierIds\",\"inputs\":[],\"outputs\":[{\"name\":\"tiers_\",\"type\":\"uint16[]\",\"internalType\":\"uint16[]\"}],\"stateMutability\":\"pure\"},{\"type\":\"error\",\"name\":\"TIER_NOT_FOUND\",\"inputs\":[]}]", } // TierProviderABI is the input ABI used to generate the binding from. @@ -254,10 +254,10 @@ func (_TierProvider *TierProviderCallerSession) DAOFALLBACKPROPOSER() (common.Ad // GetMinTier is a free data retrieval call binding the contract method 0x52c5c56b. // -// Solidity: function getMinTier(address , uint256 ) pure returns(uint16) -func (_TierProvider *TierProviderCaller) GetMinTier(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (uint16, error) { +// Solidity: function getMinTier(address _proposer, uint256 _rand) view returns(uint16) +func (_TierProvider *TierProviderCaller) GetMinTier(opts *bind.CallOpts, _proposer common.Address, _rand *big.Int) (uint16, error) { var out []interface{} - err := _TierProvider.contract.Call(opts, &out, "getMinTier", arg0, arg1) + err := _TierProvider.contract.Call(opts, &out, "getMinTier", _proposer, _rand) if err != nil { return *new(uint16), err @@ -271,16 +271,16 @@ func (_TierProvider *TierProviderCaller) GetMinTier(opts *bind.CallOpts, arg0 co // GetMinTier is a free data retrieval call binding the contract method 0x52c5c56b. // -// Solidity: function getMinTier(address , uint256 ) pure returns(uint16) -func (_TierProvider *TierProviderSession) GetMinTier(arg0 common.Address, arg1 *big.Int) (uint16, error) { - return _TierProvider.Contract.GetMinTier(&_TierProvider.CallOpts, arg0, arg1) +// Solidity: function getMinTier(address _proposer, uint256 _rand) view returns(uint16) +func (_TierProvider *TierProviderSession) GetMinTier(_proposer common.Address, _rand *big.Int) (uint16, error) { + return _TierProvider.Contract.GetMinTier(&_TierProvider.CallOpts, _proposer, _rand) } // GetMinTier is a free data retrieval call binding the contract method 0x52c5c56b. // -// Solidity: function getMinTier(address , uint256 ) pure returns(uint16) -func (_TierProvider *TierProviderCallerSession) GetMinTier(arg0 common.Address, arg1 *big.Int) (uint16, error) { - return _TierProvider.Contract.GetMinTier(&_TierProvider.CallOpts, arg0, arg1) +// Solidity: function getMinTier(address _proposer, uint256 _rand) view returns(uint16) +func (_TierProvider *TierProviderCallerSession) GetMinTier(_proposer common.Address, _rand *big.Int) (uint16, error) { + return _TierProvider.Contract.GetMinTier(&_TierProvider.CallOpts, _proposer, _rand) } // GetProvider is a free data retrieval call binding the contract method 0x5c42d079. diff --git a/packages/taiko-client/pkg/rpc/methods.go b/packages/taiko-client/pkg/rpc/methods.go index caec456b8f2..469e2eadad1 100644 --- a/packages/taiko-client/pkg/rpc/methods.go +++ b/packages/taiko-client/pkg/rpc/methods.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/big" + "strings" "time" "github.com/cenkalti/backoff/v4" @@ -281,59 +282,16 @@ func (c *Client) CalculateBaseFee( currentTimestamp uint64, ) (*big.Int, error) { var ( - baseFeeInfo struct { - Basefee *big.Int - ParentGasExcess uint64 - } - err error + baseFee *big.Int + err error ) if isOntake { - var ( - newGasTarget = uint64(baseFeeConfig.GasIssuancePerSecond) * uint64(baseFeeConfig.AdjustmentQuotient) - parentGasExcess uint64 - ) - parentGasTarget, err := c.TaikoL2.ParentGasTarget( - &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, - ) - if err != nil { - return nil, fmt.Errorf("failed to fetch parent gas target: %w", err) - } - - if newGasTarget != parentGasTarget && parentGasTarget != 0 { - oldParentGasExcess, err := c.TaikoL2.ParentGasExcess( - &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, - ) - if err != nil { - return nil, fmt.Errorf("failed to fetch old parent gas excess: %w", err) - } - if parentGasExcess, err = c.TaikoL2.AdjustExcess( - &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, - oldParentGasExcess, - parentGasTarget, - newGasTarget, - ); err != nil { - return nil, fmt.Errorf("failed to adjust parent gas excess: %w", err) - } - } else { - if parentGasExcess, err = c.TaikoL2.ParentGasExcess(&bind.CallOpts{ - BlockNumber: l2Head.Number, Context: ctx, - }); err != nil { - return nil, fmt.Errorf("failed to fetch parent gas excess: %w", err) - } - } - baseFeeInfo, err = c.TaikoL2.CalculateBaseFee( - &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, - *baseFeeConfig, - currentTimestamp-l2Head.Time, - parentGasExcess, - uint32(l2Head.GasUsed), - ) - if err != nil { + if baseFee, err = c.calculateBaseFeeOntake(ctx, l2Head, currentTimestamp, baseFeeConfig); err != nil { return nil, err } } else { - baseFeeInfo, err = c.TaikoL2.GetBasefee( + baseFeeInfo, err := c.TaikoL2.GetBasefee( &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, anchorBlockID.Uint64(), uint32(l2Head.GasUsed), @@ -341,6 +299,7 @@ func (c *Client) CalculateBaseFee( if err != nil { return nil, err } + baseFee = baseFeeInfo.Basefee } if err != nil { @@ -349,13 +308,13 @@ func (c *Client) CalculateBaseFee( log.Info( "Base fee information", - "fee", utils.WeiToGWei(baseFeeInfo.Basefee), + "fee", utils.WeiToGWei(baseFee), "l2Head", l2Head.Number, "anchorBlockID", anchorBlockID, "isOntake", isOntake, ) - return baseFeeInfo.Basefee, nil + return baseFee, nil } // GetPoolContent fetches the transactions list from L2 execution engine's transactions pool with given @@ -914,3 +873,68 @@ func (c *Client) WaitL1NewPendingTransaction( return nil } + +// CalculateBaseFeeOnTake calculates the base fee after ontake fork from the L2 protocol. +func (c *Client) calculateBaseFeeOntake( + ctx context.Context, + l2Head *types.Header, + currentTimestamp uint64, + baseFeeConfig *bindings.LibSharedDataBaseFeeConfig, +) (*big.Int, error) { + var ( + newGasTarget = uint64(baseFeeConfig.GasIssuancePerSecond) * uint64(baseFeeConfig.AdjustmentQuotient) + parentGasExcess uint64 + ) + parentGasTarget, err := c.TaikoL2.ParentGasTarget(&bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}) + if err != nil { + return nil, fmt.Errorf("failed to fetch parent gas target: %w", err) + } + + if newGasTarget != parentGasTarget && parentGasTarget != 0 { + oldParentGasExcess, err := c.TaikoL2.ParentGasExcess(&bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}) + if err != nil { + return nil, fmt.Errorf("failed to fetch old parent gas excess: %w", err) + } + if parentGasExcess, err = c.TaikoL2.AdjustExcess( + &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, + oldParentGasExcess, + parentGasTarget, + newGasTarget, + ); err != nil { + // If the `calculateBaseFee()` method is deprecated, we will use the new method `getBasefeeV2()` + // to calculate the base fee. + if strings.Contains(encoding.TryParsingCustomError(err).Error(), "L2_DEPRECATED_METHOD") { + baseFeeInfo, err := c.TaikoL2.GetBasefeeV2( + &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, + 0, + *baseFeeConfig, + ) + if err != nil { + return nil, fmt.Errorf("failed to calculate base fee by GetBasefeeV2: %w", err) + } + return baseFeeInfo.Basefee, nil + } + + return nil, fmt.Errorf("failed to adjust parent gas excess: %w", err) + } + } else { + if parentGasExcess, err = c.TaikoL2.ParentGasExcess(&bind.CallOpts{ + BlockNumber: l2Head.Number, Context: ctx, + }); err != nil { + return nil, fmt.Errorf("failed to fetch parent gas excess: %w", err) + } + } + + baseFeeInfo, err := c.TaikoL2.CalculateBaseFee( + &bind.CallOpts{BlockNumber: l2Head.Number, Context: ctx}, + *baseFeeConfig, + currentTimestamp-l2Head.Time, + parentGasExcess, + uint32(l2Head.GasUsed), + ) + if err != nil { + return nil, err + } + + return baseFeeInfo.Basefee, nil +}