diff --git a/bindings/.githead b/bindings/.githead index 64917ca0f..dceed7fc9 100644 --- a/bindings/.githead +++ b/bindings/.githead @@ -1 +1 @@ -be0fe1cfa4f8f97f8abdec2a9d350c2c5224ac68 +a74f44f1d710185c9b29d88e60e73794893ba99d diff --git a/bindings/gen_taiko_l2.go b/bindings/gen_taiko_l2.go index f95cbdb49..c1b40a319 100644 --- a/bindings/gen_taiko_l2.go +++ b/bindings/gen_taiko_l2.go @@ -29,17 +29,9 @@ var ( _ = abi.ConvertType ) -// TaikoL2EIP1559Config is an auto generated low-level Go binding around an user-defined struct. -type TaikoL2EIP1559Config struct { - Xscale *big.Int - Yscale *big.Int - GasIssuedPerSecond uint32 - GasExcessMax uint64 -} - // TaikoL2ClientMetaData contains all meta data concerning the TaikoL2Client contract. var TaikoL2ClientMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"L2_1559_OUT_OF_STOCK\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"expected\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"actual\",\"type\":\"uint64\"}],\"name\":\"L2_1559_UNEXPECTED_CHANGE\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_BASEFEE_MISMATCH\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_1559_PARAMS\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_CHAIN_ID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_GOLDEN_TOUCH_K\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_SENDER\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_PUBLIC_INPUT_HASH_MISMATCH\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_TOO_LATE\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Overflow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RESOLVER_DENIED\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RESOLVER_INVALID_ADDR\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"}],\"name\":\"RESOLVER_ZERO_ADDR\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addressManager\",\"type\":\"address\"}],\"name\":\"AddressManagerChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"number\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"basefee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"gaslimit\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"timestamp\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"parentHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"prevrandao\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"chainid\",\"type\":\"uint64\"}],\"name\":\"Anchored\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"srcHeight\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"signalRoot\",\"type\":\"bytes32\"}],\"name\":\"CrossChainSynced\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GOLDEN_TOUCH_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOLDEN_TOUCH_PRIVATEKEY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addressManager\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"l1Hash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"l1SignalRoot\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"l1Height\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"parentGasUsed\",\"type\":\"uint32\"}],\"name\":\"anchor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"basefee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"gasIssuedPerSecond\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"gasExcessMax\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"gasTarget\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"ratio2x1x\",\"type\":\"uint64\"}],\"name\":\"calcEIP1559Config\",\"outputs\":[{\"components\":[{\"internalType\":\"uint128\",\"name\":\"xscale\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"yscale\",\"type\":\"uint128\"},{\"internalType\":\"uint32\",\"name\":\"gasIssuedPerSecond\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"gasExcessMax\",\"type\":\"uint64\"}],\"internalType\":\"structTaikoL2.EIP1559Config\",\"name\":\"config\",\"type\":\"tuple\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasExcess\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"timeSinceParent\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"parentGasUsed\",\"type\":\"uint32\"}],\"name\":\"getBasefee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"_basefee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"}],\"name\":\"getCrossChainBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"}],\"name\":\"getCrossChainSignalRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEIP1559Config\",\"outputs\":[{\"components\":[{\"internalType\":\"uint128\",\"name\":\"xscale\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"yscale\",\"type\":\"uint128\"},{\"internalType\":\"uint32\",\"name\":\"gasIssuedPerSecond\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"gasExcessMax\",\"type\":\"uint64\"}],\"internalType\":\"structTaikoL2.EIP1559Config\",\"name\":\"config\",\"type\":\"tuple\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addressManager\",\"type\":\"address\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestSyncedL1Height\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"parentTimestamp\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"publicInputHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"allowZeroAddress\",\"type\":\"bool\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"addr\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"allowZeroAddress\",\"type\":\"bool\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"addr\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAddressManager\",\"type\":\"address\"}],\"name\":\"setAddressManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"digest\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"k\",\"type\":\"uint8\"}],\"name\":\"signAnchor\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"r\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"s\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"name\":\"EIP1559_INVALID_PARAMS\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_BASEFEE_MISMATCH\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_GAS_EXCESS_TOO_LARGE\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_CHAIN_ID\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_GOLDEN_TOUCH_K\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_INVALID_SENDER\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_PUBLIC_INPUT_HASH_MISMATCH\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"L2_TOO_LATE\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"Overflow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RESOLVER_DENIED\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"RESOLVER_INVALID_ADDR\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"}],\"name\":\"RESOLVER_ZERO_ADDR\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"addressManager\",\"type\":\"address\"}],\"name\":\"AddressManagerChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"parentHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"gasExcess\",\"type\":\"uint128\"}],\"name\":\"Anchored\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"srcHeight\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"signalRoot\",\"type\":\"bytes32\"}],\"name\":\"CrossChainSynced\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GOLDEN_TOUCH_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOLDEN_TOUCH_PRIVATEKEY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addressManager\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"l1Hash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"l1SignalRoot\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"syncedL1Height\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"parentGasUsed\",\"type\":\"uint32\"}],\"name\":\"anchor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasExcess\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"get1559Params\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"gasTarget\",\"type\":\"uint64\"},{\"internalType\":\"uint256\",\"name\":\"adjustmentQuotient\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"syncedL1Height\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"parentGasUsed\",\"type\":\"uint32\"}],\"name\":\"getBasefee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"basefee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"}],\"name\":\"getBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"}],\"name\":\"getCrossChainBlockHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"blockId\",\"type\":\"uint64\"}],\"name\":\"getCrossChainSignalRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addressManager\",\"type\":\"address\"},{\"internalType\":\"uint128\",\"name\":\"_gasExcess\",\"type\":\"uint128\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"latestSyncedL1Height\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"publicInputHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"allowZeroAddress\",\"type\":\"bool\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"addr\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"allowZeroAddress\",\"type\":\"bool\"}],\"name\":\"resolve\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"addr\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAddressManager\",\"type\":\"address\"}],\"name\":\"setAddressManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"digest\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"k\",\"type\":\"uint8\"}],\"name\":\"signAnchor\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"r\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"s\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // TaikoL2ClientABI is the input ABI used to generate the binding from. @@ -281,74 +273,88 @@ func (_TaikoL2Client *TaikoL2ClientCallerSession) AddressManager() (common.Addre return _TaikoL2Client.Contract.AddressManager(&_TaikoL2Client.CallOpts) } -// CalcEIP1559Config is a free data retrieval call binding the contract method 0x06becb55. +// GasExcess is a free data retrieval call binding the contract method 0xf535bd56. // -// Solidity: function calcEIP1559Config(uint64 basefee, uint32 gasIssuedPerSecond, uint64 gasExcessMax, uint64 gasTarget, uint64 ratio2x1x) pure returns((uint128,uint128,uint32,uint64) config) -func (_TaikoL2Client *TaikoL2ClientCaller) CalcEIP1559Config(opts *bind.CallOpts, basefee uint64, gasIssuedPerSecond uint32, gasExcessMax uint64, gasTarget uint64, ratio2x1x uint64) (TaikoL2EIP1559Config, error) { +// Solidity: function gasExcess() view returns(uint128) +func (_TaikoL2Client *TaikoL2ClientCaller) GasExcess(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "calcEIP1559Config", basefee, gasIssuedPerSecond, gasExcessMax, gasTarget, ratio2x1x) + err := _TaikoL2Client.contract.Call(opts, &out, "gasExcess") if err != nil { - return *new(TaikoL2EIP1559Config), err + return *new(*big.Int), err } - out0 := *abi.ConvertType(out[0], new(TaikoL2EIP1559Config)).(*TaikoL2EIP1559Config) + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) return out0, err } -// CalcEIP1559Config is a free data retrieval call binding the contract method 0x06becb55. +// GasExcess is a free data retrieval call binding the contract method 0xf535bd56. // -// Solidity: function calcEIP1559Config(uint64 basefee, uint32 gasIssuedPerSecond, uint64 gasExcessMax, uint64 gasTarget, uint64 ratio2x1x) pure returns((uint128,uint128,uint32,uint64) config) -func (_TaikoL2Client *TaikoL2ClientSession) CalcEIP1559Config(basefee uint64, gasIssuedPerSecond uint32, gasExcessMax uint64, gasTarget uint64, ratio2x1x uint64) (TaikoL2EIP1559Config, error) { - return _TaikoL2Client.Contract.CalcEIP1559Config(&_TaikoL2Client.CallOpts, basefee, gasIssuedPerSecond, gasExcessMax, gasTarget, ratio2x1x) +// Solidity: function gasExcess() view returns(uint128) +func (_TaikoL2Client *TaikoL2ClientSession) GasExcess() (*big.Int, error) { + return _TaikoL2Client.Contract.GasExcess(&_TaikoL2Client.CallOpts) } -// CalcEIP1559Config is a free data retrieval call binding the contract method 0x06becb55. +// GasExcess is a free data retrieval call binding the contract method 0xf535bd56. // -// Solidity: function calcEIP1559Config(uint64 basefee, uint32 gasIssuedPerSecond, uint64 gasExcessMax, uint64 gasTarget, uint64 ratio2x1x) pure returns((uint128,uint128,uint32,uint64) config) -func (_TaikoL2Client *TaikoL2ClientCallerSession) CalcEIP1559Config(basefee uint64, gasIssuedPerSecond uint32, gasExcessMax uint64, gasTarget uint64, ratio2x1x uint64) (TaikoL2EIP1559Config, error) { - return _TaikoL2Client.Contract.CalcEIP1559Config(&_TaikoL2Client.CallOpts, basefee, gasIssuedPerSecond, gasExcessMax, gasTarget, ratio2x1x) +// Solidity: function gasExcess() view returns(uint128) +func (_TaikoL2Client *TaikoL2ClientCallerSession) GasExcess() (*big.Int, error) { + return _TaikoL2Client.Contract.GasExcess(&_TaikoL2Client.CallOpts) } -// GasExcess is a free data retrieval call binding the contract method 0xf535bd56. +// Get1559Params is a free data retrieval call binding the contract method 0x594e47ca. // -// Solidity: function gasExcess() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientCaller) GasExcess(opts *bind.CallOpts) (uint64, error) { +// Solidity: function get1559Params() pure returns(uint64 gasTarget, uint256 adjustmentQuotient) +func (_TaikoL2Client *TaikoL2ClientCaller) Get1559Params(opts *bind.CallOpts) (struct { + GasTarget uint64 + AdjustmentQuotient *big.Int +}, error) { var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "gasExcess") + err := _TaikoL2Client.contract.Call(opts, &out, "get1559Params") + outstruct := new(struct { + GasTarget uint64 + AdjustmentQuotient *big.Int + }) if err != nil { - return *new(uint64), err + return *outstruct, err } - out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + outstruct.GasTarget = *abi.ConvertType(out[0], new(uint64)).(*uint64) + outstruct.AdjustmentQuotient = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - return out0, err + return *outstruct, err } -// GasExcess is a free data retrieval call binding the contract method 0xf535bd56. +// Get1559Params is a free data retrieval call binding the contract method 0x594e47ca. // -// Solidity: function gasExcess() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientSession) GasExcess() (uint64, error) { - return _TaikoL2Client.Contract.GasExcess(&_TaikoL2Client.CallOpts) +// Solidity: function get1559Params() pure returns(uint64 gasTarget, uint256 adjustmentQuotient) +func (_TaikoL2Client *TaikoL2ClientSession) Get1559Params() (struct { + GasTarget uint64 + AdjustmentQuotient *big.Int +}, error) { + return _TaikoL2Client.Contract.Get1559Params(&_TaikoL2Client.CallOpts) } -// GasExcess is a free data retrieval call binding the contract method 0xf535bd56. +// Get1559Params is a free data retrieval call binding the contract method 0x594e47ca. // -// Solidity: function gasExcess() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientCallerSession) GasExcess() (uint64, error) { - return _TaikoL2Client.Contract.GasExcess(&_TaikoL2Client.CallOpts) +// Solidity: function get1559Params() pure returns(uint64 gasTarget, uint256 adjustmentQuotient) +func (_TaikoL2Client *TaikoL2ClientCallerSession) Get1559Params() (struct { + GasTarget uint64 + AdjustmentQuotient *big.Int +}, error) { + return _TaikoL2Client.Contract.Get1559Params(&_TaikoL2Client.CallOpts) } // GetBasefee is a free data retrieval call binding the contract method 0xa7e022d1. // -// Solidity: function getBasefee(uint64 timeSinceParent, uint32 parentGasUsed) view returns(uint256 _basefee) -func (_TaikoL2Client *TaikoL2ClientCaller) GetBasefee(opts *bind.CallOpts, timeSinceParent uint64, parentGasUsed uint32) (*big.Int, error) { +// Solidity: function getBasefee(uint64 syncedL1Height, uint32 parentGasUsed) view returns(uint256 basefee) +func (_TaikoL2Client *TaikoL2ClientCaller) GetBasefee(opts *bind.CallOpts, syncedL1Height uint64, parentGasUsed uint32) (*big.Int, error) { var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "getBasefee", timeSinceParent, parentGasUsed) + err := _TaikoL2Client.contract.Call(opts, &out, "getBasefee", syncedL1Height, parentGasUsed) if err != nil { return *new(*big.Int), err @@ -362,16 +368,16 @@ func (_TaikoL2Client *TaikoL2ClientCaller) GetBasefee(opts *bind.CallOpts, timeS // GetBasefee is a free data retrieval call binding the contract method 0xa7e022d1. // -// Solidity: function getBasefee(uint64 timeSinceParent, uint32 parentGasUsed) view returns(uint256 _basefee) -func (_TaikoL2Client *TaikoL2ClientSession) GetBasefee(timeSinceParent uint64, parentGasUsed uint32) (*big.Int, error) { - return _TaikoL2Client.Contract.GetBasefee(&_TaikoL2Client.CallOpts, timeSinceParent, parentGasUsed) +// Solidity: function getBasefee(uint64 syncedL1Height, uint32 parentGasUsed) view returns(uint256 basefee) +func (_TaikoL2Client *TaikoL2ClientSession) GetBasefee(syncedL1Height uint64, parentGasUsed uint32) (*big.Int, error) { + return _TaikoL2Client.Contract.GetBasefee(&_TaikoL2Client.CallOpts, syncedL1Height, parentGasUsed) } // GetBasefee is a free data retrieval call binding the contract method 0xa7e022d1. // -// Solidity: function getBasefee(uint64 timeSinceParent, uint32 parentGasUsed) view returns(uint256 _basefee) -func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBasefee(timeSinceParent uint64, parentGasUsed uint32) (*big.Int, error) { - return _TaikoL2Client.Contract.GetBasefee(&_TaikoL2Client.CallOpts, timeSinceParent, parentGasUsed) +// Solidity: function getBasefee(uint64 syncedL1Height, uint32 parentGasUsed) view returns(uint256 basefee) +func (_TaikoL2Client *TaikoL2ClientCallerSession) GetBasefee(syncedL1Height uint64, parentGasUsed uint32) (*big.Int, error) { + return _TaikoL2Client.Contract.GetBasefee(&_TaikoL2Client.CallOpts, syncedL1Height, parentGasUsed) } // GetBlockHash is a free data retrieval call binding the contract method 0x23ac7136. @@ -467,37 +473,6 @@ func (_TaikoL2Client *TaikoL2ClientCallerSession) GetCrossChainSignalRoot(blockI return _TaikoL2Client.Contract.GetCrossChainSignalRoot(&_TaikoL2Client.CallOpts, blockId) } -// GetEIP1559Config is a free data retrieval call binding the contract method 0x4e755573. -// -// Solidity: function getEIP1559Config() pure returns((uint128,uint128,uint32,uint64) config) -func (_TaikoL2Client *TaikoL2ClientCaller) GetEIP1559Config(opts *bind.CallOpts) (TaikoL2EIP1559Config, error) { - var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "getEIP1559Config") - - if err != nil { - return *new(TaikoL2EIP1559Config), err - } - - out0 := *abi.ConvertType(out[0], new(TaikoL2EIP1559Config)).(*TaikoL2EIP1559Config) - - return out0, err - -} - -// GetEIP1559Config is a free data retrieval call binding the contract method 0x4e755573. -// -// Solidity: function getEIP1559Config() pure returns((uint128,uint128,uint32,uint64) config) -func (_TaikoL2Client *TaikoL2ClientSession) GetEIP1559Config() (TaikoL2EIP1559Config, error) { - return _TaikoL2Client.Contract.GetEIP1559Config(&_TaikoL2Client.CallOpts) -} - -// GetEIP1559Config is a free data retrieval call binding the contract method 0x4e755573. -// -// Solidity: function getEIP1559Config() pure returns((uint128,uint128,uint32,uint64) config) -func (_TaikoL2Client *TaikoL2ClientCallerSession) GetEIP1559Config() (TaikoL2EIP1559Config, error) { - return _TaikoL2Client.Contract.GetEIP1559Config(&_TaikoL2Client.CallOpts) -} - // LatestSyncedL1Height is a free data retrieval call binding the contract method 0xc7b96908. // // Solidity: function latestSyncedL1Height() view returns(uint64) @@ -560,37 +535,6 @@ func (_TaikoL2Client *TaikoL2ClientCallerSession) Owner() (common.Address, error return _TaikoL2Client.Contract.Owner(&_TaikoL2Client.CallOpts) } -// ParentTimestamp is a free data retrieval call binding the contract method 0x539b8ade. -// -// Solidity: function parentTimestamp() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientCaller) ParentTimestamp(opts *bind.CallOpts) (uint64, error) { - var out []interface{} - err := _TaikoL2Client.contract.Call(opts, &out, "parentTimestamp") - - if err != nil { - return *new(uint64), err - } - - out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) - - return out0, err - -} - -// ParentTimestamp is a free data retrieval call binding the contract method 0x539b8ade. -// -// Solidity: function parentTimestamp() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientSession) ParentTimestamp() (uint64, error) { - return _TaikoL2Client.Contract.ParentTimestamp(&_TaikoL2Client.CallOpts) -} - -// ParentTimestamp is a free data retrieval call binding the contract method 0x539b8ade. -// -// Solidity: function parentTimestamp() view returns(uint64) -func (_TaikoL2Client *TaikoL2ClientCallerSession) ParentTimestamp() (uint64, error) { - return _TaikoL2Client.Contract.ParentTimestamp(&_TaikoL2Client.CallOpts) -} - // PublicInputHash is a free data retrieval call binding the contract method 0xdac5df78. // // Solidity: function publicInputHash() view returns(bytes32) @@ -736,44 +680,44 @@ func (_TaikoL2Client *TaikoL2ClientCallerSession) SignAnchor(digest [32]byte, k // Anchor is a paid mutator transaction binding the contract method 0xda69d3db. // -// Solidity: function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 l1Height, uint32 parentGasUsed) returns() -func (_TaikoL2Client *TaikoL2ClientTransactor) Anchor(opts *bind.TransactOpts, l1Hash [32]byte, l1SignalRoot [32]byte, l1Height uint64, parentGasUsed uint32) (*types.Transaction, error) { - return _TaikoL2Client.contract.Transact(opts, "anchor", l1Hash, l1SignalRoot, l1Height, parentGasUsed) +// Solidity: function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 syncedL1Height, uint32 parentGasUsed) returns() +func (_TaikoL2Client *TaikoL2ClientTransactor) Anchor(opts *bind.TransactOpts, l1Hash [32]byte, l1SignalRoot [32]byte, syncedL1Height uint64, parentGasUsed uint32) (*types.Transaction, error) { + return _TaikoL2Client.contract.Transact(opts, "anchor", l1Hash, l1SignalRoot, syncedL1Height, parentGasUsed) } // Anchor is a paid mutator transaction binding the contract method 0xda69d3db. // -// Solidity: function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 l1Height, uint32 parentGasUsed) returns() -func (_TaikoL2Client *TaikoL2ClientSession) Anchor(l1Hash [32]byte, l1SignalRoot [32]byte, l1Height uint64, parentGasUsed uint32) (*types.Transaction, error) { - return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, l1Hash, l1SignalRoot, l1Height, parentGasUsed) +// Solidity: function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 syncedL1Height, uint32 parentGasUsed) returns() +func (_TaikoL2Client *TaikoL2ClientSession) Anchor(l1Hash [32]byte, l1SignalRoot [32]byte, syncedL1Height uint64, parentGasUsed uint32) (*types.Transaction, error) { + return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, l1Hash, l1SignalRoot, syncedL1Height, parentGasUsed) } // Anchor is a paid mutator transaction binding the contract method 0xda69d3db. // -// Solidity: function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 l1Height, uint32 parentGasUsed) returns() -func (_TaikoL2Client *TaikoL2ClientTransactorSession) Anchor(l1Hash [32]byte, l1SignalRoot [32]byte, l1Height uint64, parentGasUsed uint32) (*types.Transaction, error) { - return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, l1Hash, l1SignalRoot, l1Height, parentGasUsed) +// Solidity: function anchor(bytes32 l1Hash, bytes32 l1SignalRoot, uint64 syncedL1Height, uint32 parentGasUsed) returns() +func (_TaikoL2Client *TaikoL2ClientTransactorSession) Anchor(l1Hash [32]byte, l1SignalRoot [32]byte, syncedL1Height uint64, parentGasUsed uint32) (*types.Transaction, error) { + return _TaikoL2Client.Contract.Anchor(&_TaikoL2Client.TransactOpts, l1Hash, l1SignalRoot, syncedL1Height, parentGasUsed) } -// Init is a paid mutator transaction binding the contract method 0x19ab453c. +// Init is a paid mutator transaction binding the contract method 0xcce03bf3. // -// Solidity: function init(address _addressManager) returns() -func (_TaikoL2Client *TaikoL2ClientTransactor) Init(opts *bind.TransactOpts, _addressManager common.Address) (*types.Transaction, error) { - return _TaikoL2Client.contract.Transact(opts, "init", _addressManager) +// Solidity: function init(address _addressManager, uint128 _gasExcess) returns() +func (_TaikoL2Client *TaikoL2ClientTransactor) Init(opts *bind.TransactOpts, _addressManager common.Address, _gasExcess *big.Int) (*types.Transaction, error) { + return _TaikoL2Client.contract.Transact(opts, "init", _addressManager, _gasExcess) } -// Init is a paid mutator transaction binding the contract method 0x19ab453c. +// Init is a paid mutator transaction binding the contract method 0xcce03bf3. // -// Solidity: function init(address _addressManager) returns() -func (_TaikoL2Client *TaikoL2ClientSession) Init(_addressManager common.Address) (*types.Transaction, error) { - return _TaikoL2Client.Contract.Init(&_TaikoL2Client.TransactOpts, _addressManager) +// Solidity: function init(address _addressManager, uint128 _gasExcess) returns() +func (_TaikoL2Client *TaikoL2ClientSession) Init(_addressManager common.Address, _gasExcess *big.Int) (*types.Transaction, error) { + return _TaikoL2Client.Contract.Init(&_TaikoL2Client.TransactOpts, _addressManager, _gasExcess) } -// Init is a paid mutator transaction binding the contract method 0x19ab453c. +// Init is a paid mutator transaction binding the contract method 0xcce03bf3. // -// Solidity: function init(address _addressManager) returns() -func (_TaikoL2Client *TaikoL2ClientTransactorSession) Init(_addressManager common.Address) (*types.Transaction, error) { - return _TaikoL2Client.Contract.Init(&_TaikoL2Client.TransactOpts, _addressManager) +// Solidity: function init(address _addressManager, uint128 _gasExcess) returns() +func (_TaikoL2Client *TaikoL2ClientTransactorSession) Init(_addressManager common.Address, _gasExcess *big.Int) (*types.Transaction, error) { + return _TaikoL2Client.Contract.Init(&_TaikoL2Client.TransactOpts, _addressManager, _gasExcess) } // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. @@ -1052,20 +996,14 @@ func (it *TaikoL2ClientAnchoredIterator) Close() error { // TaikoL2ClientAnchored represents a Anchored event raised by the TaikoL2Client contract. type TaikoL2ClientAnchored struct { - Number uint64 - Basefee uint64 - Gaslimit uint32 - Timestamp uint64 ParentHash [32]byte - Prevrandao *big.Int - Coinbase common.Address - Chainid uint64 + GasExcess *big.Int Raw types.Log // Blockchain specific contextual infos } -// FilterAnchored is a free log retrieval operation binding the contract event 0xf0fde5abf5476e9fb590d1e786d07c1ceee1d3c80cce3fafe0478e203cf5184e. +// FilterAnchored is a free log retrieval operation binding the contract event 0xb01a20e23471fa4d881340e2b742c2f84cb2f7a714b34ba370b815478ae4aae0. // -// Solidity: event Anchored(uint64 number, uint64 basefee, uint32 gaslimit, uint64 timestamp, bytes32 parentHash, uint256 prevrandao, address coinbase, uint64 chainid) +// Solidity: event Anchored(bytes32 parentHash, uint128 gasExcess) func (_TaikoL2Client *TaikoL2ClientFilterer) FilterAnchored(opts *bind.FilterOpts) (*TaikoL2ClientAnchoredIterator, error) { logs, sub, err := _TaikoL2Client.contract.FilterLogs(opts, "Anchored") @@ -1075,9 +1013,9 @@ func (_TaikoL2Client *TaikoL2ClientFilterer) FilterAnchored(opts *bind.FilterOpt return &TaikoL2ClientAnchoredIterator{contract: _TaikoL2Client.contract, event: "Anchored", logs: logs, sub: sub}, nil } -// WatchAnchored is a free log subscription operation binding the contract event 0xf0fde5abf5476e9fb590d1e786d07c1ceee1d3c80cce3fafe0478e203cf5184e. +// WatchAnchored is a free log subscription operation binding the contract event 0xb01a20e23471fa4d881340e2b742c2f84cb2f7a714b34ba370b815478ae4aae0. // -// Solidity: event Anchored(uint64 number, uint64 basefee, uint32 gaslimit, uint64 timestamp, bytes32 parentHash, uint256 prevrandao, address coinbase, uint64 chainid) +// Solidity: event Anchored(bytes32 parentHash, uint128 gasExcess) func (_TaikoL2Client *TaikoL2ClientFilterer) WatchAnchored(opts *bind.WatchOpts, sink chan<- *TaikoL2ClientAnchored) (event.Subscription, error) { logs, sub, err := _TaikoL2Client.contract.WatchLogs(opts, "Anchored") @@ -1112,9 +1050,9 @@ func (_TaikoL2Client *TaikoL2ClientFilterer) WatchAnchored(opts *bind.WatchOpts, }), nil } -// ParseAnchored is a log parse operation binding the contract event 0xf0fde5abf5476e9fb590d1e786d07c1ceee1d3c80cce3fafe0478e203cf5184e. +// ParseAnchored is a log parse operation binding the contract event 0xb01a20e23471fa4d881340e2b742c2f84cb2f7a714b34ba370b815478ae4aae0. // -// Solidity: event Anchored(uint64 number, uint64 basefee, uint32 gaslimit, uint64 timestamp, bytes32 parentHash, uint256 prevrandao, address coinbase, uint64 chainid) +// Solidity: event Anchored(bytes32 parentHash, uint128 gasExcess) func (_TaikoL2Client *TaikoL2ClientFilterer) ParseAnchored(log types.Log) (*TaikoL2ClientAnchored, error) { event := new(TaikoL2ClientAnchored) if err := _TaikoL2Client.contract.UnpackLog(event, "Anchored", log); err != nil { diff --git a/driver/chain_syncer/calldata/syncer.go b/driver/chain_syncer/calldata/syncer.go index c6040cd56..bbb703289 100644 --- a/driver/chain_syncer/calldata/syncer.go +++ b/driver/chain_syncer/calldata/syncer.go @@ -330,25 +330,21 @@ func (s *Syncer) insertNewHead( } } - parentTimestamp, err := s.rpc.TaikoL2.ParentTimestamp(&bind.CallOpts{BlockNumber: parent.Number, Context: ctx}) - if err != nil { - return nil, err - } - // Get L2 baseFee baseFee, err := s.rpc.TaikoL2.GetBasefee( &bind.CallOpts{BlockNumber: parent.Number, Context: ctx}, - event.Meta.Timestamp-parentTimestamp, + event.Meta.L1Height, uint32(parent.GasUsed), ) if err != nil { return nil, fmt.Errorf("failed to get L2 baseFee: %w", encoding.TryParsingCustomError(err)) } - log.Debug( - "GetBasefee", + log.Info( + "L2 baseFee", + "blockID", event.BlockId, "baseFee", baseFee, - "timeSinceParent", uint32(event.Meta.Timestamp-parentTimestamp), + "syncedL1Height", event.Meta.L1Height, "parentGasUsed", parent.GasUsed, ) diff --git a/prover/capacity_manager/capacity_manager.go b/prover/capacity_manager/capacity_manager.go index 532a94a4b..92b58db16 100644 --- a/prover/capacity_manager/capacity_manager.go +++ b/prover/capacity_manager/capacity_manager.go @@ -31,7 +31,8 @@ func (m *CapacityManager) ReadCapacity() uint64 { m.mutex.RLock() defer m.mutex.RUnlock() - log.Info("Reading capacity", + log.Info( + "Reading capacity", "maxCapacity", m.maxCapacity, "currentCapacity", m.maxCapacity-uint64(len(m.capacity)), "currentUsage", len(m.capacity), @@ -47,7 +48,8 @@ func (m *CapacityManager) ReleaseOneCapacity(blockID uint64) (uint64, bool) { defer m.mutex.Unlock() if _, ok := m.capacity[blockID]; !ok { - log.Info("Can not release capacity", + log.Info( + "Can not release capacity", "blockID", blockID, "maxCapacity", m.maxCapacity, "currentCapacity", m.maxCapacity-uint64(len(m.capacity)), @@ -58,7 +60,8 @@ func (m *CapacityManager) ReleaseOneCapacity(blockID uint64) (uint64, bool) { delete(m.capacity, blockID) - log.Info("Released capacity", + log.Info( + "Released capacity", "blockID", blockID, "maxCapacity", m.maxCapacity, "currentCapacityAfterRelease", m.maxCapacity-uint64(len(m.capacity)), @@ -74,7 +77,8 @@ func (m *CapacityManager) TakeOneCapacity(blockID uint64) (uint64, bool) { defer m.mutex.Unlock() if len(m.capacity) == int(m.maxCapacity) { - log.Info("Could not take one capacity", + log.Info( + "Could not take one capacity", "blockID", blockID, "maxCapacity", m.maxCapacity, "currentCapacity", m.maxCapacity-uint64(len(m.capacity)), @@ -85,7 +89,8 @@ func (m *CapacityManager) TakeOneCapacity(blockID uint64) (uint64, bool) { m.capacity[blockID] = true - log.Info("Took one capacity", + log.Info( + "Took one capacity", "blockID", blockID, "maxCapacity", m.maxCapacity, "currentCapacityAfterTaking", m.maxCapacity-uint64(len(m.capacity)), @@ -104,7 +109,8 @@ func (m *CapacityManager) TakeOneTempCapacity() (uint64, bool) { m.clearExpiredTempCapacities() if len(m.capacity)+len(m.tempCapacity) >= int(m.maxCapacity) { - log.Info("Could not take one temp capacity", + log.Info( + "Could not take one temp capacity", "maxCapacity", m.maxCapacity, "currentCapacityAfterTaking", m.maxCapacity-uint64(len(m.capacity)), "currentUsageAfterTaking", len(m.capacity), @@ -123,7 +129,8 @@ func (m *CapacityManager) clearExpiredTempCapacities() { for i, c := range m.tempCapacity { if time.Now().UTC().Sub(c) > m.tempCapacityExpiresAt { m.tempCapacity = append(m.tempCapacity[:i], m.tempCapacity[i+1:]...) - log.Info("Cleared one temp capacity", + log.Info( + "Cleared one temp capacity", "maxCapacity", m.maxCapacity, "currentCapacityAfterClearing", m.maxCapacity-uint64(len(m.capacity)), "currentUsageAfterClearing", len(m.capacity), diff --git a/prover/prover.go b/prover/prover.go index d3805c8c5..b9eb1a5dd 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -32,8 +32,6 @@ var ( errNoCapacity = errors.New("no prover capacity available") ) -type cancelFunc func() - // Prover keep trying to prove new proposed blocks valid/invalid. type Prover struct { // Configurations @@ -78,14 +76,6 @@ type Prover struct { submitProofConcurrencyGuard chan struct{} submitProofTxMutex *sync.Mutex - currentBlocksBeingProven map[uint64]cancelFunc - currentBlocksBeingProvenMutex *sync.Mutex - currentBlocksWaitingForProofWindow map[uint64]uint64 // l2BlockId : l1Height - currentBlocksWaitingForProofWindowMutex *sync.Mutex - - // interval settings - checkProofWindowExpiredInterval time.Duration - // capacity-related configs capacityManager *capacity.CapacityManager @@ -107,10 +97,6 @@ func (p *Prover) InitFromCli(ctx context.Context, c *cli.Context) error { func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { p.cfg = cfg p.ctx = ctx - p.currentBlocksBeingProven = make(map[uint64]cancelFunc) - p.currentBlocksBeingProvenMutex = new(sync.Mutex) - p.currentBlocksWaitingForProofWindow = make(map[uint64]uint64, 0) - p.currentBlocksWaitingForProofWindowMutex = new(sync.Mutex) p.capacityManager = capacity.New(cfg.Capacity, cfg.TempCapacityExpiresAt) // Clients @@ -153,8 +139,6 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { p.proposeConcurrencyGuard = make(chan struct{}, cfg.MaxConcurrentProvingJobs) p.submitProofConcurrencyGuard = make(chan struct{}, cfg.MaxConcurrentProvingJobs) - p.checkProofWindowExpiredInterval = p.cfg.CheckProofWindowExpiredInterval - guardianProverAddress, err := p.rpc.TaikoL1.Resolve( &bind.CallOpts{Context: ctx}, p.rpc.L1ChainID, @@ -257,7 +241,7 @@ func (p *Prover) eventLoop() { } } - // If there is too many (TaikoData.Config.maxNumBlocks) pending blocks in TaikoL1 contract, there will be no new + // If there is too many (TaikoData.Config.blockMaxProposals) pending blocks in TaikoL1 contract, there will be no new // BlockProposed temporarily, so except the BlockProposed subscription, we need another trigger to start // fetching the proposed blocks. forceProvingTicker := time.NewTicker(15 * time.Second) @@ -296,7 +280,7 @@ func (p *Prover) eventLoop() { func (p *Prover) Close(ctx context.Context) { p.closeSubscription() if err := p.srv.Shutdown(ctx); err != nil { - log.Error("Error shutting down http server", "error", err) + log.Error("Failed to shut down prover server", "error", err) } p.wg.Wait() } @@ -451,12 +435,6 @@ func (p *Prover) onBlockProposed( return nil } - // Check if the current prover has seen this block ID before, there was probably - // a L1 reorg, we need to cancel that reorged block's proof generation task at first. - if p.currentBlocksBeingProven[event.Meta.Id] != nil { - p.cancelProof(ctx, event.Meta.Id) - } - log.Info( "Proposed block information", "blockID", event.BlockId, @@ -520,16 +498,6 @@ func (p *Prover) onBlockProposed( } } - ctx, cancelCtx := context.WithCancel(ctx) - p.currentBlocksBeingProvenMutex.Lock() - p.currentBlocksBeingProven[event.BlockId.Uint64()] = cancelFunc(func() { - defer cancelCtx() - if err := p.validProofSubmitter.CancelProof(ctx, event.BlockId); err != nil { - log.Error("failed to cancel proof", "error", err, "blockID", event.BlockId) - } - }) - p.currentBlocksBeingProvenMutex.Unlock() - return p.validProofSubmitter.RequestProof(ctx, event) } @@ -547,9 +515,6 @@ func (p *Prover) onBlockProposed( func() error { return handleBlockProposedEvent() }, backoff.WithMaxRetries(backoff.NewConstantBackOff(p.cfg.BackOffRetryInterval), p.cfg.BackOffMaxRetrys), ); err != nil { - p.currentBlocksBeingProvenMutex.Lock() - delete(p.currentBlocksBeingProven, event.BlockId.Uint64()) - p.currentBlocksBeingProvenMutex.Unlock() log.Error("Handle new BlockProposed event error", "error", err) } }() @@ -562,10 +527,6 @@ func (p *Prover) submitProofOp(ctx context.Context, proofWithHeader *proofProduc p.submitProofConcurrencyGuard <- struct{}{} go func() { - p.currentBlocksBeingProvenMutex.Lock() - delete(p.currentBlocksBeingProven, proofWithHeader.Meta.Id) - p.currentBlocksBeingProvenMutex.Unlock() - defer func() { <-p.submitProofConcurrencyGuard if !p.cfg.GuardianProver { @@ -607,37 +568,6 @@ func (p *Prover) onBlockVerified(ctx context.Context, event *bindings.TaikoL1Cli "prover", event.Prover, ) - // cancel any proofs being generated for this block - p.cancelProof(ctx, event.BlockId.Uint64()) - - return nil -} - -// onBlockProven cancels proof generation if the proof is being generated by this prover, -// and the proof is not the guardian proof address. -func (p *Prover) onBlockProven(ctx context.Context, event *bindings.TaikoL1ClientTransitionProved) error { - metrics.ProverReceivedProvenBlockGauge.Update(event.BlockId.Int64()) - - // cancel any proofs being generated for this block - isValidProof, err := p.isValidProof( - ctx, - event.BlockId.Uint64(), - event.ParentHash, - event.BlockHash, - ) - if err != nil { - return err - } - - if isValidProof { - p.cancelProof(ctx, event.BlockId.Uint64()) - } else { - // generate guardian proof if guardian prover, proof is invalid - if p.cfg.GuardianProver { - return p.requestProofForBlockId(event.BlockId, new(big.Int).SetUint64(event.Raw.BlockNumber)) - } - } - return nil } @@ -744,109 +674,26 @@ func (p *Prover) isValidProof( return false, nil } -// cancelProof cancels local proof generation -func (p *Prover) cancelProof(ctx context.Context, blockID uint64) { - p.currentBlocksBeingProvenMutex.Lock() - defer p.currentBlocksBeingProvenMutex.Unlock() - - if cancel, ok := p.currentBlocksBeingProven[blockID]; ok { - log.Info("cancelling proof", "blockID", blockID) - - cancel() - delete(p.currentBlocksBeingProven, blockID) - if !p.cfg.GuardianProver { - capacity, released := p.capacityManager.ReleaseOneCapacity(blockID) - if !released { - log.Error("unable to release capacity while cancelling proof", - "capacity", capacity, - "blockID", blockID, - ) - } - } - } -} - -// proveOp performs a proving operation, find current unproven blocks, then -// request generating proofs for them. -func (p *Prover) requestProofForBlockId(blockId *big.Int, l1Height *big.Int) error { - onBlockProposed := func( - ctx context.Context, - event *bindings.TaikoL1ClientBlockProposed, - end eventIterator.EndBlockProposedEventIterFunc, - ) error { - // only filter for exact blockID we want - if event.BlockId.Cmp(blockId) != 0 { - return nil - } - - // Check whether the block has been verified. - isVerified, err := p.isBlockVerified(event.BlockId) - if err != nil { - return fmt.Errorf("failed to check if the current L2 block is verified: %w", err) - } - - if isVerified { - log.Info("📋 Block has been verified", "blockID", event.BlockId) - return nil - } - - // make sure to takea capacity before requesting proof - if !p.cfg.GuardianProver { - if _, ok := p.capacityManager.TakeOneCapacity(event.BlockId.Uint64()); !ok { - return errNoCapacity - } - } - - ctx, cancelCtx := context.WithCancel(ctx) - p.currentBlocksBeingProvenMutex.Lock() - p.currentBlocksBeingProven[event.BlockId.Uint64()] = cancelFunc(func() { - defer cancelCtx() - if err := p.validProofSubmitter.CancelProof(ctx, event.BlockId); err != nil { - log.Error("Failed to cancel proof", "error", err, "blockID", event.BlockId) - } - }) - p.currentBlocksBeingProvenMutex.Unlock() - - p.proposeConcurrencyGuard <- struct{}{} - - if err := p.validProofSubmitter.RequestProof(ctx, event); err != nil { - return err - } - - return nil - } - - handleBlockProposedEvent := func() error { - defer func() { <-p.proposeConcurrencyGuard }() - - iter, err := eventIterator.NewBlockProposedIterator(p.ctx, &eventIterator.BlockProposedIteratorConfig{ - Client: p.rpc.L1, - TaikoL1: p.rpc.TaikoL1, - StartHeight: l1Height, - EndHeight: new(big.Int).Add(l1Height, common.Big1), - OnBlockProposedEvent: onBlockProposed, - FilterQuery: []*big.Int{blockId}, - }) - if err != nil { - return err - } - - return iter.Iter() - } +// onBlockProven cancels proof generation if the proof is being generated by this prover, +// and the proof is not the guardian proof address. +func (p *Prover) onBlockProven(ctx context.Context, event *bindings.TaikoL1ClientTransitionProved) error { + metrics.ProverReceivedProvenBlockGauge.Update(event.BlockId.Int64()) - go func() { - if err := backoff.Retry( - func() error { - return handleBlockProposedEvent() - }, - backoff.WithMaxRetries(backoff.NewConstantBackOff(p.cfg.BackOffRetryInterval), p.cfg.BackOffMaxRetrys), - ); err != nil { - p.currentBlocksBeingProvenMutex.Lock() - defer p.currentBlocksBeingProvenMutex.Unlock() - delete(p.currentBlocksBeingProven, blockId.Uint64()) - log.Error("Request proof with a given block ID", "blockID", blockId, "error", err) - } - }() + // cancel any proofs being generated for this block + // isValidProof, err := p.isValidProof( + // ctx, + // event.BlockId.Uint64(), + // event.ParentHash, + // event.BlockHash, + // ) + // if err != nil { + // return err + // } + + // // generate guardian proof if guardian prover, proof is invalid + // if p.cfg.GuardianProver { + // return p.requestProofForBlockId(event.BlockId, new(big.Int).SetUint64(event.Raw.BlockNumber)) + // } return nil }