Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ count, prefill mask, fill/duplicate/corrupt flags, nonce) then encodes a
well-formed `cmpctblock`. `data[0] % 8 == 7` is the raw-wire arm
(`prepare_cmpct_fuzz_hsi` restamp; malformed decode is skip). Each case
grinds a unique header (prev = genesis) so Core treats it as a new compact.
The stamp folds a mix of the input into genesis + 600 through genesis + 2
hours: this job's `setmocktime` is genesis, and a later header is
`time-too-new` on Core. The follow accept pins the hub clock to that same
mocktime. A split panic includes Core's `submitblock` reason.
Spawn `setmocktime`s Core to regtest genesis time (`CanDirectFetch`).
P2P `bitcoind` also gets `-maxtipage=999999999` so Core v31's IBD latch
(`UpdateIBDStatus` on `LoadChainTip`, not `setmocktime`) leaves IBD at
Expand Down
5 changes: 5 additions & 0 deletions changelog.d/cmpct-mock-clock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixed

- **Compact fuzz shares Core's mock clock.** Header stamps stay within
two hours of regtest genesis, and the follow accept uses that same
clock. A split panic includes Core's `submitblock` reason.
2 changes: 2 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/block_csv_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== BLOCK-CSV-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/block_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== BLOCK-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/block_fork_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== BLOCK-FORK-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/block_reorg_n_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== BLOCK-REORG-N-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/block_spend_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== BLOCK-SPEND-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
11 changes: 9 additions & 2 deletions fuzz/fuzz_targets/cmpct_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,15 @@ fn send_one(b: &Base, data: &[u8]) -> SendOutcome {
if let Some(fate) = follow_reconstructed_cmpct(&b.hub, &b.core.rpc, &case) {
match fate {
CompareOne::Harness(msg) => harness_failure(msg),
CompareOne::Disagreed { ours, core, hex } => {
panic!("cmpct follow split ours={ours} core={core} hex={hex}");
CompareOne::Disagreed {
ours,
core,
reason,
hex,
} => {
panic!(
"cmpct follow split ours={ours} core={core} reason={reason} hex={hex}"
);
}
CompareOne::Agreed { accept: true } => {
if b.hub.rewind_to_height(0).is_err() {
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/cmpct_reorg_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== CMPCT-REORG-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/mempool_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== MEMPOOL-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("tx_hex={hex}");
Expand Down
8 changes: 6 additions & 2 deletions fuzz/fuzz_targets/p2p_sequence_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ fuzz_target!(|data: &[u8]| {
match compare_one(&b.hub, &mut tip, &b.core.rpc, body) {
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::NotABlock | CompareOne::Skipped => {}
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
panic!("p2p-sequence block: ours={ours} core={core} hex={hex}");
}
CompareOne::Harness(msg) if msg == "oracle dead" => {}
Expand All @@ -440,7 +442,9 @@ fuzz_target!(|data: &[u8]| {
P2pSeqKind::Tx => match compare_tx_bytes(&b.hub, &b.core.rpc, &step.payload) {
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::NotABlock | CompareOne::Skipped => {}
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
panic!("p2p-sequence tx: ours={ours} core={core} hex={hex}");
}
CompareOne::Harness(msg) if msg == "oracle dead" => {}
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/script_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== SCRIPT-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("block_hex={hex}");
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_targets/script_verify_differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ fuzz_target!(|data: &[u8]| {
ORACLE_DOWN_STREAK.store(0, Ordering::Relaxed);
}
CompareOne::Agreed { .. } => note_comparison(),
CompareOne::Disagreed { ours, core, hex } => {
CompareOne::Disagreed {
ours, core, hex, ..
} => {
eprintln!("=== SCRIPT-VERIFY-DIFFERENTIAL FUZZ CONSENSUS DIVERGENCE ===");
eprintln!("ours_accept={ours} core_accept={core}");
eprintln!("tx_hex={hex}");
Expand Down
31 changes: 28 additions & 3 deletions fuzz/src/block_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,17 @@ pub struct DiffPad {
pub enum CompareOne {
NotABlock,
Skipped,
Agreed { accept: bool },
Disagreed { ours: bool, core: bool, hex: String },
Agreed {
accept: bool,
},
Disagreed {
ours: bool,
core: bool,
hex: String,
/// Core `submitblock` reason when this split came from a reply.
/// Empty when the split has no oracle string.
reason: String,
},
Harness(&'static str),
}

Expand Down Expand Up @@ -966,6 +975,7 @@ pub fn compare_tx_bytes(hub: &ChainHub, oracle: &dyn BlockOracle, raw: &[u8]) ->
ours: ours == DiffVerdict::Accept,
core: core == DiffVerdict::Accept,
hex,
reason: String::new(),
}
}
}
Expand Down Expand Up @@ -1016,6 +1026,7 @@ pub fn compare_mempool_one(
ours: ours == DiffVerdict::Accept,
core: core == DiffVerdict::Accept,
hex,
reason: String::new(),
}
}
}
Expand Down Expand Up @@ -1066,6 +1077,7 @@ pub fn compare_script_verify_one(
ours: ours == DiffVerdict::Accept,
core: core == DiffVerdict::Accept,
hex: hex2,
reason: String::new(),
}
}
}
Expand Down Expand Up @@ -1752,6 +1764,7 @@ fn finish_reorg_compare(
ours: true,
core: false,
hex,
reason: String::new(),
}
}
(DiffVerdict::Reject, DiffVerdict::Reject) => {
Expand All @@ -1767,6 +1780,7 @@ fn finish_reorg_compare(
ours: false,
core: true,
hex,
reason: String::new(),
}
}
(DiffVerdict::Reject, DiffVerdict::Skip) => {
Expand Down Expand Up @@ -1833,11 +1847,13 @@ pub fn honest_replay_verdict(ours: DiffVerdict, core: DiffVerdict) -> CompareOne
ours: false,
core: true,
hex: String::new(),
reason: String::new(),
},
(DiffVerdict::Accept, DiffVerdict::Reject) => CompareOne::Disagreed {
ours: true,
core: false,
hex: String::new(),
reason: String::new(),
},
(DiffVerdict::Reject, DiffVerdict::Reject) => CompareOne::Agreed { accept: false },
(DiffVerdict::Skip, _) | (_, DiffVerdict::Skip) => CompareOne::Skipped,
Expand Down Expand Up @@ -1877,6 +1893,7 @@ fn replay_honest_twin(
ours: true,
core: true,
hex,
reason: String::new(),
};
}
match honest_replay_verdict(ours, core) {
Expand All @@ -1887,7 +1904,12 @@ fn replay_honest_twin(
let _ = hub.rewind_to_height(keep);
}
let _ = oracle.core_rewind_to_height(keep);
CompareOne::Disagreed { ours, core, hex }
CompareOne::Disagreed {
ours,
core,
hex,
reason: String::new(),
}
}
other => {
if ours == DiffVerdict::Accept {
Expand Down Expand Up @@ -1991,13 +2013,15 @@ fn combine(
ours: true,
core: false,
hex: hex.to_string(),
reason: String::new(),
}
}
(DiffVerdict::Reject, DiffVerdict::Reject) => CompareOne::Agreed { accept: false },
(DiffVerdict::Reject, DiffVerdict::Accept) => CompareOne::Disagreed {
ours: false,
core: true,
hex: hex.to_string(),
reason: String::new(),
},
(DiffVerdict::Reject, DiffVerdict::Skip) => CompareOne::Skipped,
(DiffVerdict::Skip, DiffVerdict::Accept) => {
Expand Down Expand Up @@ -2199,6 +2223,7 @@ mod tests {
ours: false,
core: true,
hex: String::new(),
reason: String::new(),
}
);
}
Expand Down
Loading
Loading