-
Notifications
You must be signed in to change notification settings - Fork 74
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 panic with unpinning pruned blocks #2386
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.
Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.
twiggy diff reportDifference in .wasm size before and after this pull request.
|
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.
👍
Fixes a panic introduced in #2373
Imagine the following situation:
Block A has two children: block B and block C. The latest finalized block is currently block A. All three blocks are pinned.
Now, imagine that block B gets finalized. Block A, B, and C all stay pinned. The number of pinned blocks remaining is decreased by 1.
When the user then unpins block C, we check
height(block_C) <= height(current_finalized_block)
, which returnstrue
, and we add 1 to the number of pinned blocks remaining.When the user then unpins block A, the same happens, and we add 1 again to the number of pinned blocks remaining.
This leads to an overflow when that number of pinned blocks is
usize::max_value()
.This PR fixes this problem by tracking in
pinned_blocks
whether the block counts towards the limit.