Skip to content

Commit 032fda1

Browse files
committed
Fix crash on missing parent blocks:
Historically we have some weird floating blocks back from Golang times because AstroBWTv3 implemnentation was slow and in some cases too slow to fit the 1s block window constantly. With latest upstream merges from Kaspa the boomerang bounces back hard. It will fail with: KeyNotFound(GhostdagCompact/0/fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe) It fails because block neither exist in Ghostdag nor Ghostdag Compact. Since the block doesn't exist, we will assume blue work to be 0 and return it as fallback.
1 parent 7525708 commit 032fda1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

consensus/src/processes/ghostdag/protocol.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ impl<T: GhostdagStoreReader, S: RelationsStoreReader, U: ReachabilityService, V:
9999
pub fn find_selected_parent(&self, parents: impl IntoIterator<Item = Hash>) -> Hash {
100100
parents
101101
.into_iter()
102-
.map(|parent| SortableBlock { hash: parent, blue_work: self.ghostdag_store.get_blue_work(parent).unwrap() })
102+
.map(|parent| SortableBlock {
103+
hash: parent,
104+
blue_work: self.ghostdag_store.get_blue_work(parent).unwrap_or(spectre_math::Uint192([0, 0, 0])),
105+
})
103106
.max()
104107
.unwrap()
105108
.hash

0 commit comments

Comments
 (0)