diff --git a/packages/taiko-client/bindings/gen_taiko_l1.go b/packages/taiko-client/bindings/gen_taiko_l1.go index 1301db5dbff..6c18d3621ea 100644 --- a/packages/taiko-client/bindings/gen_taiko_l1.go +++ b/packages/taiko-client/bindings/gen_taiko_l1.go @@ -143,6 +143,16 @@ type TaikoDataSlotB struct { LastUnpausedAt uint64 } +type TaikoDataSlotBV1 struct { + NumBlocks uint64 + LastVerifiedBlockId uint64 + ProvingPaused bool + ReservedB1 uint8 + ReservedB2 uint16 + ReservedB3 uint32 + LastUnpausedAt uint64 +} + // TaikoDataTransition is an auto generated low-level Go binding around an user-defined struct. type TaikoDataTransition struct { ParentHash [32]byte @@ -599,6 +609,21 @@ func (_TaikoL1Client *TaikoL1ClientCaller) GetStateVariables(opts *bind.CallOpts } +func (_TaikoL1Client *TaikoL1ClientCaller) GetStateVariablesV1(opts *bind.CallOpts) (TaikoDataSlotA, TaikoDataSlotBV1, error) { + var out []interface{} + err := _TaikoL1Client.contract.Call(opts, &out, "getStateVariables") + + if err != nil { + return *new(TaikoDataSlotA), *new(TaikoDataSlotBV1), err + } + + out0 := *abi.ConvertType(out[0], new(TaikoDataSlotA)).(*TaikoDataSlotA) + out1 := *abi.ConvertType(out[1], new(TaikoDataSlotB)).(*TaikoDataSlotBV1) + + return out0, out1, err + +} + // GetStateVariables is a free data retrieval call binding the contract method 0xdde89cf5. // // Solidity: function getStateVariables() view returns((uint64,uint64,uint64,uint64), (uint64,uint64,bool,uint56,uint64)) diff --git a/packages/taiko-client/pkg/rpc/methods.go b/packages/taiko-client/pkg/rpc/methods.go index 692c018a7f2..cc27518fef6 100644 --- a/packages/taiko-client/pkg/rpc/methods.go +++ b/packages/taiko-client/pkg/rpc/methods.go @@ -552,14 +552,14 @@ func (c *Client) CheckL1Reorg(ctx context.Context, blockID *big.Int) (*ReorgChec // If we rollback to the genesis block, then there is no L1Origin information recorded in the L2 execution // engine for that block, so we will query the protocol to use `GenesisHeight` value to reset the L1 cursor. if blockID.Cmp(common.Big0) == 0 { - slotA, _, err := c.TaikoL1.GetStateVariables(&bind.CallOpts{Context: ctxWithTimeout}) + state, err := GetProtocolStateVariables(c.TaikoL1, &bind.CallOpts{Context: ctxWithTimeout}) if err != nil { return result, err } if result.L1CurrentToReset, err = c.L1.HeaderByNumber( ctxWithTimeout, - new(big.Int).SetUint64(slotA.GenesisHeight), + new(big.Int).SetUint64(state.A.GenesisHeight), ); err != nil { return nil, err } diff --git a/packages/taiko-client/pkg/rpc/utils.go b/packages/taiko-client/pkg/rpc/utils.go index c425b82158f..c08b7f136eb 100644 --- a/packages/taiko-client/pkg/rpc/utils.go +++ b/packages/taiko-client/pkg/rpc/utils.go @@ -34,6 +34,7 @@ var ( syscall.SIGQUIT, } ErrInvalidLength = errors.New("invalid length") + ErrSlotBMarshal = errors.New("abi: cannot marshal in to go type: length insufficient 160 require 192") ) // GetProtocolConfigs gets the protocol configs from TaikoL1 contract. @@ -67,9 +68,25 @@ func GetProtocolStateVariables( defer cancel() // Notice: sloB.LastProposedIn and slotB.LastUnpausedAt are always 0 // before upgrading contract, but we can ignore it since we won't use it. + + var slotBV1 bindings.TaikoDataSlotBV1 slotA, slotB, err := taikoL1Client.GetStateVariables(opts) if err != nil { - return nil, err + if errors.Is(err, ErrSlotBMarshal) { + slotA, slotBV1, err = taikoL1Client.GetStateVariablesV1(opts) + if err != nil { + return nil, err + } + slotB = bindings.TaikoDataSlotB{ + NumBlocks: slotBV1.NumBlocks, + LastVerifiedBlockId: slotBV1.LastVerifiedBlockId, + ProvingPaused: slotBV1.ProvingPaused, + LastProposedIn: nil, + LastUnpausedAt: slotBV1.LastUnpausedAt, + } + } else { + return nil, err + } } return &struct { A bindings.TaikoDataSlotA