From ebf862c1784043c30f973584a7e432c851854f44 Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Wed, 3 Dec 2025 20:27:16 -0800 Subject: [PATCH 1/2] indexer remove redundant header reads --- .../state_synchronization/indexer/indexer.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/module/state_synchronization/indexer/indexer.go b/module/state_synchronization/indexer/indexer.go index db164a2c12d..ee3343efe67 100644 --- a/module/state_synchronization/indexer/indexer.go +++ b/module/state_synchronization/indexer/indexer.go @@ -161,14 +161,16 @@ func (i *Indexer) onBlockIndexed() error { // we need loop here because it's possible for a height to be missed here, // we should guarantee all heights are processed for height := lastProcessedHeight + 1; height <= highestIndexedHeight; height++ { - header, err := i.indexer.headers.ByHeight(height) - if err != nil { - // if the execution data is available, the block must be locally finalized - i.log.Error().Err(err).Msgf("could not get header for height %d:", height) - return fmt.Errorf("could not get header for height %d: %w", height, err) - } - - i.OnBlockProcessed(header.Height) + // Use BlockIDByHeight instead of ByHeight since we only need to verify the block exists + // and don't need the full header data. This avoids expensive header deserialization. + // _, err := i.indexer.headers.BlockIDByHeight(height) + // if err != nil { + // // if the execution data is available, the block must be locally finalized + // i.log.Error().Err(err).Msgf("could not get header for height %d:", height) + // return fmt.Errorf("could not get header for height %d: %w", height, err) + // } + + i.OnBlockProcessed(height) } i.lastProcessedHeight.Store(highestIndexedHeight) } From 32c9d03f75d6014d41717003f29555b08f54230e Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Thu, 4 Dec 2025 14:28:22 -0800 Subject: [PATCH 2/2] warn about large iteration --- module/state_synchronization/indexer/indexer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/state_synchronization/indexer/indexer.go b/module/state_synchronization/indexer/indexer.go index ee3343efe67..0d45fa5a470 100644 --- a/module/state_synchronization/indexer/indexer.go +++ b/module/state_synchronization/indexer/indexer.go @@ -158,6 +158,9 @@ func (i *Indexer) onBlockIndexed() error { highestIndexedHeight := i.jobConsumer.LastProcessedIndex() if lastProcessedHeight < highestIndexedHeight { + if lastProcessedHeight+1000 < highestIndexedHeight { + i.log.Warn().Msgf("notifying processed heights from %d to %d", lastProcessedHeight+1, highestIndexedHeight) + } // we need loop here because it's possible for a height to be missed here, // we should guarantee all heights are processed for height := lastProcessedHeight + 1; height <= highestIndexedHeight; height++ {