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): check inner iterator errors in BlockProposedIterator #18757

Merged
merged 5 commits into from
Jan 13, 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
4 changes: 4 additions & 0 deletions packages/taiko-client/driver/txlist_fetcher/calldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ func (d *CalldataFetcher) Fetch(
return iter.Event.TxList, nil
}

if iter.Error() != nil {
return nil, fmt.Errorf("failed to fetch calldata for block %d: %w", meta.GetBlockID(), iter.Error())
}

return nil, fmt.Errorf("calldata for block %d not found", meta.GetBlockID())
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ func assembleBlockProposedIteratorCallback(
) error {
endHeight := end.Number.Uint64()

iter, err := taikoL1.FilterBlockProposed(
&bind.FilterOpts{Start: start.Number.Uint64(), End: &endHeight, Context: ctx},
filterQuery,
nil,
)
if err != nil {
return err
}
defer iter.Close()

iterOntake, err := taikoL1.FilterBlockProposedV2(
&bind.FilterOpts{Start: start.Number.Uint64(), End: &endHeight, Context: ctx},
filterQuery,
Expand All @@ -130,26 +120,6 @@ func assembleBlockProposedIteratorCallback(
}
defer iterOntake.Close()

for iter.Next() {
event := iter.Event

if err := callback(ctx, metadata.NewTaikoDataBlockMetadataLegacy(event), eventIter.end); err != nil {
return err
}

if eventIter.isEnd {
endFunc()
return nil
}

current, err := client.HeaderByHash(ctx, event.Raw.BlockHash)
if err != nil {
return err
}

updateCurrentFunc(current)
}

for iterOntake.Next() {
event := iterOntake.Event

Expand All @@ -170,6 +140,6 @@ func assembleBlockProposedIteratorCallback(
updateCurrentFunc(current)
}

return nil
return iterOntake.Error()
}
}
9 changes: 9 additions & 0 deletions packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {
if iter.Next() {
l2GenesisHash = iter.Event.BlockHash
}
if iter.Error() != nil {
return iter.Error()
}
} else {
// Fetch the genesis `BlockVerified` event.
iter, err := c.TaikoL1.FilterBlockVerified(filterOpts, []*big.Int{common.Big0}, nil)
Expand All @@ -84,6 +87,9 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {
if iter.Next() {
l2GenesisHash = iter.Event.BlockHash
}
if iter.Error() != nil {
return iter.Error()
}
}

log.Debug("Genesis hash", "node", nodeGenesis.Hash(), "TaikoL1", common.BytesToHash(l2GenesisHash[:]))
Expand Down Expand Up @@ -836,6 +842,9 @@ func (c *Client) GetTaikoDataSlotBByNumber(ctx context.Context, number uint64) (
for iter.Next() {
return &iter.Event.SlotB, nil
}
if iter.Error() != nil {
return nil, fmt.Errorf("failed to get state variables by block number %d: %w", number, iter.Error())
}

return nil, fmt.Errorf("failed to get state variables by block number %d", number)
}
Expand Down
Loading