-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: do not truncate blocks to persist #9986
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.
lgtm
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.
lgtm
/// Returns a batch of consecutive canonical blocks to persist in the range | ||
/// `(last_persisted_number .. canonical_head - threshold]` . The expected | ||
/// order is oldest -> newest. |
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.
sg!
if block.block.number <= last_persisted_number { | ||
break; | ||
} |
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 believe this should actually be enforced by the tree invariants, but better be safe here
if block.block.number <= target_number { | ||
blocks_to_persist.push(block.clone()); | ||
} |
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 will work because we have a guarantee that canonical head always has its parent blocks
/// oldest -> newest. | ||
/// Returns a batch of consecutive canonical blocks to persist in the range | ||
/// `(last_persisted_number .. canonical_head - threshold]` . The expected | ||
/// order is oldest -> newest. | ||
fn get_canonical_blocks_to_persist(&self) -> Vec<ExecutedBlock> { |
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.
could this return an empty vec?
if so we likely should add a sanity check before we send that vec to the persistence task
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.
sure, added here 45fbe9e
Closes #9978