-
Notifications
You must be signed in to change notification settings - Fork 200
[Access] Indexer remove redundant header reads #8226
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,17 +158,22 @@ 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++ { | ||
| 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) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error would not happen, because AN is only syncing execution data for sealed blocks, so an indexed height must be finalized already.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this is currently true. this system will be replaced soon by one that does sync unsealed data, but this logic is not used. |
||
| } | ||
|
|
||
| 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) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm actually not sure why this is needed. Do we remember the original issue that requires us to add this patch?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it was related to the execution data tracker/pruner, but I don't remember why we needed to explicitly check that the header existed locally. |
||
| } | ||
| i.lastProcessedHeight.Store(highestIndexedHeight) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call might cause 30% CPU spikes on startup for hours, if there are lots of height to iterate.
We are not using the header, I don't think it's necessary to query it.