Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(taiko-client): add #18442 back #18685

Merged
merged 5 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading