fix(tree): remove_blocks fixes, return hash and number in persistence task #10678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This does many things:
remove_blocks_above
andsave_blocks
output both a block number and hash.remove_until
take an upper bound block number, a last_persisted_block_num and hash, and an optionalfinalized_hash
.remove_until
will now make sure that it only removes canonical in-memory blocks if they are in the same chain as the last persisted block. This was motivated by hive tests where the persistence task would run in between a reorg. In this case, we were removing canonical blocks that were not actually persisted yet.remove_until
is split into two methods,remove_canonical_until
andprune_finalized_sidechains
.is_canonical
is introduced as a helper forremove_until
remove_persisted_blocks
is modified to only remove blocks if they are actually part of the persisted chain.remove_blocks_above
was incorrect, removing exclusively for some pieces of data, and inclusively for others. This is fixed.VecDeque
in case there are multiple reorgs in a row.closes #10570