-
Notifications
You must be signed in to change notification settings - Fork 120
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
feat(state): Implements reconsider_block method #9260
base: main
Are you sure you want to change the base?
feat(state): Implements reconsider_block method #9260
Conversation
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.
Thank you! This looks good, I left a suggestion for some cleanup, but there are no blockers to merging this as-is if preferred.
…m validate_and_commit if a candidate block's hash is in the map of invalidated blocks. Stores invalidated_blocks by height and clears when finalizing. Checks against non finalized tip hash to create a new chain if parnt_chain doesn't exist. Renames ReconsiderError variant NonPreviouslyInvalidatedBlock to MissingInvalidatedBlock.
This pull request has been removed from the queue for the following reason: Pull request #9260 has been dequeued, merge conditions unmatch:
You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
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 is looking great, thank you for adding the IndexMap
.
There's one small issue around adding chains to the non-finalized state with roots below the finalized tip, but otherwise this PR looks ready to merge.
…). Removes unused ReconsiderError variant. Opts to refuse block consideration if parent_chain does not exist. Adds db handle to reconsider_block function. Edits max blocks constant documentation
if let Some(best_chain_root_height) = finalized_state.finalized_tip_height() { | ||
self.invalidated_blocks | ||
.retain(|height, _blocks| *height >= best_chain_root_height); | ||
} |
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.
Optional: It would be better to check the finalized tip height before calling self.parent_chain()
so it could insert a new chain instead.
parent_chain()
will return None
if the block's parent is missing in the non-finalized state, but if the block's parent is the finalized tip, normally Zebra inserts a new chain. It's not crucial for the reconsiderblock
method, but it would be nice.
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.
I think I understand what you are saying now. If the parent is already finalized it would better to create a new chain of non finalized blocks and insert that. If not then we can make the call to parent_chain and proceed
…ized blocks only before checking parent_chain.
Motivation
The changes create and test a reconsider_block method to later be integrated into the zebra RPC. This method reconsiders previously invalidated_blocks into a chain that exist in the chain_set. Closes #8842.
Specifications & References
NonFinalizedState
via RPC methods #8634reconsider_block()
method to theNonFinalizedState
for validating/committing a previously invalidated block and its invalidated descendents #8842Solution
reconsider_block
method toNonFinalizedState
that allows previously invalidated blocks to be reconsidered and re-inserted into the chain.Tests
Follow-up Work
PR Author's Checklist
PR Reviewer's Checklist