Skip to content

Commit 9de0830

Browse files
joostjagerclaude
andcommitted
chanmon_consistency: resync stale monitors to chain tip during settlement
After a node reload with an older monitor, the fuzzer's node_height tracking variable stays at the pre-reload height. During settlement, sync_with_chain_state starts from node_height, so it never re-delivers the blocks that the stale monitor missed. If a commitment tx was confirmed in one of those missed blocks, the monitor never learns about the funding spend, causing get_claimable_balances() to incorrectly report a ClaimableOnChannelClose balance. Fix this by resetting each node_height to the minimum of its current value and all its monitors' best_block heights at the start of settlement, ensuring sync_with_chain_state re-delivers missed blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 834f2e5 commit 9de0830

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

fuzz/src/chanmon_consistency.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,6 +2875,23 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
28752875
nodes[1].signer_unblocked(None);
28762876
nodes[2].signer_unblocked(None);
28772877

2878+
// After a node reload with an older monitor, node_height may be
2879+
// ahead of the monitor's best_block. Reset to the minimum so
2880+
// sync_with_chain_state re-delivers missed blocks during settlement.
2881+
for (node, monitor, node_height) in [
2882+
(&nodes[0], &monitor_a, &mut node_height_a),
2883+
(&nodes[1], &monitor_b, &mut node_height_b),
2884+
(&nodes[2], &monitor_c, &mut node_height_c),
2885+
] {
2886+
let mut min = std::cmp::min(*node_height, node.current_best_block().height);
2887+
for chan_id in monitor.chain_monitor.list_monitors() {
2888+
if let Ok(mon) = monitor.chain_monitor.get_monitor(chan_id) {
2889+
min = std::cmp::min(min, mon.current_best_block().height);
2890+
}
2891+
}
2892+
*node_height = min;
2893+
}
2894+
28782895
macro_rules! process_all_events {
28792896
() => { {
28802897
let mut last_pass_no_updates = false;

0 commit comments

Comments
 (0)