Skip to content

Commit 4f5de12

Browse files
committed
f - Limit is_outpoint_spent lookback to avoid fuzz hash collisions
1 parent c972bf2 commit 4f5de12

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ impl ChainState {
207207
}
208208

209209
fn is_outpoint_spent(&self, outpoint: &bitcoin::OutPoint) -> bool {
210-
self.blocks.iter().any(|(_, txs)| {
210+
// Only check the last 6 blocks (1 confirmation block + 5 post-confirmation) to avoid
211+
// false positives from hash collisions in older blocks. Under fuzz hashing, txids have
212+
// only 8 effective bits, so unrelated outpoints in old blocks frequently collide.
213+
let start = self.blocks.len().saturating_sub(6);
214+
self.blocks[start..].iter().any(|(_, txs)| {
211215
txs.iter().any(|tx| {
212216
tx.input.iter().any(|input| input.previous_output == *outpoint)
213217
})

0 commit comments

Comments
 (0)