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

feat(taiko-client): compatible changes for lastProposedIn #18442

Merged
merged 6 commits into from
Nov 5, 2024
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 @@ -594,14 +594,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 @@ -2,6 +2,7 @@ package rpc

import (
"context"
"errors"
"math/big"
"os"
"os/signal"
Expand Down Expand Up @@ -31,6 +32,7 @@ var (
syscall.SIGTERM,
syscall.SIGQUIT,
}
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 @@ -63,9 +65,24 @@ func GetProtocolStateVariables(
opts.Context, cancel = CtxWithTimeoutOrDefault(opts.Context, defaultTimeout)
defer cancel()

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