We want to avoid panicking when Zebra can't find a parent in its state during contextual validation of a candidate block.
Fixes #8881 (although without fully diagnosing how it was possible).
Solution
Returns a NotReadyToBeCommitted error instead of panicking when the relevant chain is empty
Follow-up Work
I'm not completely sure why this was happening in the first place, it may be plausible that because non_finalized_block_write_sent_hashes() isn't pruned until after the call to can_fork_chain_at(), the missing parent blocks on a side chain were dropped when the block height was finalized. We may want to take another look at it.
block_is_valid_for_recent_chain() definitely needs an update, there's a condition relevant_chain.is_empty() that can never be reached and another test-only condition that is outdated since Zebra can calculate difficulty thresholds with fewer than POW_ADJUSTMENT_BLOCK_SPAN blocks.
Motivation
We want to avoid panicking when Zebra can't find a parent in its state during contextual validation of a candidate block.
Fixes #8881 (although without fully diagnosing how it was possible).
Solution
Returns a
NotReadyToBeCommitted
error instead of panicking when the relevant chain is emptyFollow-up Work
I'm not completely sure why this was happening in the first place, it may be plausible that because
non_finalized_block_write_sent_hashes()
isn't pruned until after the call tocan_fork_chain_at()
, the missing parent blocks on a side chain were dropped when the block height was finalized. We may want to take another look at it.block_is_valid_for_recent_chain()
definitely needs an update, there's a conditionrelevant_chain.is_empty()
that can never be reached and another test-only condition that is outdated since Zebra can calculate difficulty thresholds with fewer thanPOW_ADJUSTMENT_BLOCK_SPAN
blocks.PR Author's Checklist
PR Reviewer's Checklist