Skip to content

Conversation

@zhangchiqing
Copy link
Member

@zhangchiqing zhangchiqing commented Dec 4, 2025

This PR removes a unnecessary header reads that might cause CPU spikes during startup.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

// 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)
Copy link
Member Author

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.

@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
module/state_synchronization/indexer/indexer.go 33.33% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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)
Copy link
Member Author

@zhangchiqing zhangchiqing Dec 4, 2025

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AN is only syncing execution data for sealed blocks

this is currently true. this system will be replaced soon by one that does sync unsealed data, but this logic is not used.

// return fmt.Errorf("could not get header for height %d: %w", height, err)
// }

i.OnBlockProcessed(height)
Copy link
Member Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

@peterargue peterargue Dec 4, 2025

Choose a reason for hiding this comment

The 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.

@zhangchiqing zhangchiqing marked this pull request as ready for review December 4, 2025 20:03
@zhangchiqing zhangchiqing requested a review from a team as a code owner December 4, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants