When a parent block is rejected, also reject its children #2479
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.
Motivation
After Zebra rejects a queued non-finalized block, it keeps on processing that block's children, as if their parent was valid.
This might cause panics or hangs, or break consensus rules in the non-finalized state.
I'm not sure if we should merge this fix, leave it for later, or turn it into a ticket.
Equivalent zcashd Behaviour
zcashd
implements a similar "drop all children of invalid blocks" behaviour:https://github.com/zcash/zcash/blob/c34162d6ddfaa8d6276aa0628cee838a51ad9df7/src/main.cpp#L3905
See also
BLOCK_FAILED_CHILD
:https://github.com/zcash/zcash/blob/785803382a27c85301bc75b34576c3704966fe87/src/chain.h#L176
And its uses:
https://github.com/zcash/zcash/blob/c34162d6ddfaa8d6276aa0628cee838a51ad9df7/src/main.cpp#L3919
https://github.com/zcash/zcash/blob/c34162d6ddfaa8d6276aa0628cee838a51ad9df7/src/main.cpp#L4144
Designs
Non-finalized state validation:
https://github.com/ZcashFoundation/zebra/blob/main/book/src/dev/rfcs/0005-state-updates.md#pubsuper-fn-queue_and_commit_non_finalized_blocksmut-self-new-arcblock---tokiosynconeshotreceiverblockhash
Solution
Review
Do you think we should merge this fix, leave it for later, or turn it into a ticket?
We might add tests for this error case as part of upcoming PRs.
We could hold this PR until it has tests.
Reviewer Checklist