Skip to content
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

Set chain status when adding intermediate blocks #9908

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

psteckler
Copy link
Member

@psteckler psteckler commented Dec 10, 2021

When adding blocks to the archive db, they are marked as pending to start. For blocks k or more above the highest canonical block, we can mark additional blocks as canonical.

If there are missing blocks added, they may be below the highest canonical block, and we weren't updating their chain status. In this PR, we add that update.

Algorithm:

  • find the closest canonical blocks above and below the new block, and the subchain between them
  • mark all blocks in the subchain as canonical, and all other blocks at the same heights as orphaned

Tested by extracting some blocks from the db, deleting the blocks from the db, then re-adding them, verifying that the re-added blocks have the same chain statuses as before. Also tried the same experiment with precomputed blocks, instead of extracted extensional blocks. Also ran the missing blocks auditor, which does consistency checks on chain statuses.

@psteckler psteckler requested a review from a team as a code owner December 10, 2021 19:50
@psteckler psteckler added the ci-build-me Add this label to trigger a circle+buildkite build for this branch label Dec 10, 2021
@psteckler psteckler marked this pull request as draft December 10, 2021 19:59
@psteckler psteckler marked this pull request as ready for review December 10, 2021 20:21
@psteckler
Copy link
Member Author

Corner case: If the added block is at the same height as the highest canonical block, and it's an orphan added from a precomputed block, it will remain pending. But eventually, it will be marked as an orphan, as blocks above it are added.

@psteckler psteckler merged commit 7beba33 into rosetta-1.2.1-safe Dec 10, 2021
@psteckler psteckler deleted the fix/chain-status-intermediate-blocks branch December 10, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-build-me Add this label to trigger a circle+buildkite build for this branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants