Skip to content

Commit

Permalink
chore(taiko-client): more logs for BlockBatchIterator (#18774)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jan 15, 2025
1 parent 1b02bc0 commit 3945f60
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/taiko-client/driver/chain_syncer/blob/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (s *Syncer) onBlockProposed(
}
// Ignore those already inserted blocks.
if s.lastInsertedBlockID != nil && meta.GetBlockID().Cmp(s.lastInsertedBlockID) <= 0 {
log.Debug("Skip already inserted block", "blockID", meta.GetBlockID(), "lastInsertedBlockID", s.lastInsertedBlockID)
return nil
}

Expand All @@ -224,6 +225,7 @@ func (s *Syncer) onBlockProposed(
if s.progressTracker.Triggered() {
// Already synced through beacon sync, just skip this event.
if meta.GetBlockID().Cmp(s.progressTracker.LastSyncedBlockID()) <= 0 {
log.Debug("Skip already beacon synced block", "blockID", meta.GetBlockID())
return nil
}

Expand Down
11 changes: 11 additions & 0 deletions packages/taiko-client/pkg/chain_iterator/block_batch_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ func (i *BlockBatchIterator) Iter() error {
}
if err := i.iter(); err != nil {
if errors.Is(err, io.EOF) {
log.Debug(
"Block batch iterator finished",
"start", i.startHeight,
"end", i.endHeight,
"current", i.current.Number,
)
break
}
if errors.Is(err, errContinue) {
log.Debug("Block batch iterator continues", "current", i.current.Number)
continue
}
log.Error("Block batch iterator callback error", "error", err)
Expand Down Expand Up @@ -212,6 +219,8 @@ func (i *BlockBatchIterator) iter() (err error) {
return err
}

log.Debug("Iterating blocks", "start", i.current.Number, "end", endHeader.Number)

if err := i.onBlocks(i.ctx, i.current, endHeader, i.updateCurrent, i.end); err != nil {
return err
}
Expand Down Expand Up @@ -287,6 +296,8 @@ func (i *BlockBatchIterator) rewindOnReorgDetected() error {
return err
}

log.Debug("Rewind on reorg detected", "oldCurrent", i.current.Number, "newCurrent", current.Number)

i.current = current
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func assembleBlockProposedIteratorCallback(

for iterOntake.Next() {
event := iterOntake.Event
log.Debug("Processing BlockProposedV2 event", "block", event.BlockId, "l1BlockHeight", event.Raw.BlockNumber)

if err := callback(ctx, metadata.NewTaikoDataBlockMetadataOntake(event), eventIter.end); err != nil {
log.Warn("Error while processing BlockProposedV2 events, keep retrying", "error", err)
Expand Down

0 comments on commit 3945f60

Please sign in to comment.