diff --git a/packages/taiko-client/driver/txlist_fetcher/calldata.go b/packages/taiko-client/driver/txlist_fetcher/calldata.go index 7beee95e99b..9f8de41548e 100644 --- a/packages/taiko-client/driver/txlist_fetcher/calldata.go +++ b/packages/taiko-client/driver/txlist_fetcher/calldata.go @@ -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()) } diff --git a/packages/taiko-client/pkg/chain_iterator/event_iterator/block_proposed_iterator.go b/packages/taiko-client/pkg/chain_iterator/event_iterator/block_proposed_iterator.go index 67fc0fea23d..be350e5aeeb 100644 --- a/packages/taiko-client/pkg/chain_iterator/event_iterator/block_proposed_iterator.go +++ b/packages/taiko-client/pkg/chain_iterator/event_iterator/block_proposed_iterator.go @@ -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, @@ -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 @@ -170,6 +140,6 @@ func assembleBlockProposedIteratorCallback( updateCurrentFunc(current) } - return nil + return iterOntake.Error() } } diff --git a/packages/taiko-client/pkg/rpc/methods.go b/packages/taiko-client/pkg/rpc/methods.go index 824eaceaae6..6ce4278dd81 100644 --- a/packages/taiko-client/pkg/rpc/methods.go +++ b/packages/taiko-client/pkg/rpc/methods.go @@ -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) @@ -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[:])) @@ -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) }