fix crash during apply_proof with DAG level 0 blocks referencing origin#43
Merged
Merged
Conversation
fix a crash that occurs at `let calculated_gd = self.ghostdag_manager.ghostdag(&parents)` when processing the first block in `proof[0]` (dag level 0). When parents contain [ORIGIN] so `ghostdag()` calls `find_selected_parent` which tries to read the ORIGIN's blue work from the ghostdag store via `get_blue_work(parent).unwrap()`, but `origin_ghostdag_data` was never inserted so it crashes with KeyNotFound. This also reverts 032fda1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a crash that occurs at
let calculated_gd = self.ghostdag_manager.ghostdag(&parents)when processing the first block inproof[0](DAG level 0).2025-06-18 21:39:18.547+02:00 [ERROR] thread 'tokio-runtime-worker' panicked at consensus\src\processes\ghostdag\protocol.rs:103:110: calledResult::unwrap()on anErrvalue: KeyNotFound(GhostdagCompact/0/fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe)The crash happens during
apply_proofwhen processing DAG level 0 blocks. The root cause is in the parent filtering logic using level ancestors:When this filtering removes all parents (because they're not in the level ancestors set) it code falls back to using
[ORIGIN]as parents via.push_if_empty(ORIGIN).For the first block in level 0 this results in
parentscontaining only[ORIGIN]. Whenghostdag()is called, it invokesfind_selected_parent()which tries to read ORIGIN's blue work from the ghostdag store viaget_blue_work(parent).unwrap(). But ORIGIN's ghostdag data was never inserted into the store, causingKeyNotFound(GhostdagCompact/0/fefe...)panic.https://gist.github.com/x100111010/2189956eacc3559bae9da889422a1b87
ORIGIN is a special virtual genesis block:
Spectre has significantly more dag level 0 blocks (stems from large hashrate spikes that the Difficulty Adjustment Algorithm (DAA) cannot respond to quickly enough) blocks at DAG level 0 (98,969 blocks vs Kaspa's typically empty level 0), making
proof[0]non-empty.