Skip to content

Commit

Permalink
fix(taiko-client): add #18442 back (#18685)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Jan 2, 2025
1 parent 361c26a commit abc0554
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
25 changes: 25 additions & 0 deletions packages/taiko-client/bindings/gen_taiko_l1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 18 additions & 1 deletion packages/taiko-client/pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit abc0554

Please sign in to comment.