Skip to content

Commit 7e2b509

Browse files
joostjagerclaude
andcommitted
Consolidate persistence style opcodes into toggles
Replace the 6 separate opcodes (0x00-0x02 for InProgress, 0x04-0x06 for Completed) with 3 toggle opcodes (0x00-0x02) that flip the persistence style for each node. When toggling back to Completed, the existing guard that prevents switching while monitors are pending is preserved. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2ae9afb commit 7e2b509

1 file changed

Lines changed: 19 additions & 46 deletions

File tree

fuzz/src/chanmon_consistency.rs

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,52 +2082,25 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
20822082
// In general, we keep related message groups close together in binary form, allowing
20832083
// bit-twiddling mutations to have similar effects. This is probably overkill, but no
20842084
// harm in doing so.
2085-
0x00 => {
2086-
*monitor_a.persister.update_ret.lock().unwrap() =
2087-
ChannelMonitorUpdateStatus::InProgress;
2088-
},
2089-
0x01 => {
2090-
*monitor_b.persister.update_ret.lock().unwrap() =
2091-
ChannelMonitorUpdateStatus::InProgress;
2092-
},
2093-
0x02 => {
2094-
*monitor_c.persister.update_ret.lock().unwrap() =
2095-
ChannelMonitorUpdateStatus::InProgress;
2096-
},
2097-
0x04 => {
2098-
let has_pending = monitor_a
2099-
.latest_monitors
2100-
.lock()
2101-
.unwrap()
2102-
.values()
2103-
.any(|s| !s.pending_monitors.is_empty());
2104-
if !has_pending {
2105-
*monitor_a.persister.update_ret.lock().unwrap() =
2106-
ChannelMonitorUpdateStatus::Completed;
2107-
}
2108-
},
2109-
0x05 => {
2110-
let has_pending = monitor_b
2111-
.latest_monitors
2112-
.lock()
2113-
.unwrap()
2114-
.values()
2115-
.any(|s| !s.pending_monitors.is_empty());
2116-
if !has_pending {
2117-
*monitor_b.persister.update_ret.lock().unwrap() =
2118-
ChannelMonitorUpdateStatus::Completed;
2119-
}
2120-
},
2121-
0x06 => {
2122-
let has_pending = monitor_c
2123-
.latest_monitors
2124-
.lock()
2125-
.unwrap()
2126-
.values()
2127-
.any(|s| !s.pending_monitors.is_empty());
2128-
if !has_pending {
2129-
*monitor_c.persister.update_ret.lock().unwrap() =
2130-
ChannelMonitorUpdateStatus::Completed;
2085+
0x00 | 0x01 | 0x02 => {
2086+
let monitor = match v {
2087+
0x00 => &monitor_a,
2088+
0x01 => &monitor_b,
2089+
_ => &monitor_c,
2090+
};
2091+
let mut ret = monitor.persister.update_ret.lock().unwrap();
2092+
if *ret == ChannelMonitorUpdateStatus::Completed {
2093+
*ret = ChannelMonitorUpdateStatus::InProgress;
2094+
} else {
2095+
let has_pending = monitor
2096+
.latest_monitors
2097+
.lock()
2098+
.unwrap()
2099+
.values()
2100+
.any(|s| !s.pending_monitors.is_empty());
2101+
if !has_pending {
2102+
*ret = ChannelMonitorUpdateStatus::Completed;
2103+
}
21312104
}
21322105
},
21332106

0 commit comments

Comments
 (0)