Skip to content
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(state): Avoids panicking during contextual validation when a parent block is missing #8883

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Sep 20, 2024

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 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.

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

@arya2 arya2 added C-bug Category: This is a bug I-panic Zebra panics with an internal error message A-state Area: State / database changes P-High 🔥 labels Sep 20, 2024
@arya2 arya2 self-assigned this Sep 20, 2024
@arya2 arya2 requested a review from a team as a code owner September 20, 2024 06:09
@arya2 arya2 requested review from upbqdn, conradoplg and a team and removed request for a team September 20, 2024 06:09
@arya2 arya2 changed the title fix(state): Returns an error instead of panicking during contextual validation when a parent block is missing fix(state): Avoids panicking during contextual validation when a parent block is missing Sep 20, 2024
mergify bot added a commit that referenced this pull request Sep 23, 2024
@mergify mergify bot merged commit d6301a6 into main Sep 23, 2024
147 of 148 checks passed
@mergify mergify bot deleted the fix-context-check-panic branch September 23, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-state Area: State / database changes C-bug Category: This is a bug I-panic Zebra panics with an internal error message P-High 🔥
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash while mining on testnet
2 participants