Skip to content

Commit ba0e4c5

Browse files
committed
fuzz: add chanmon holder signer fuzz ops
Allow chanmon consistency inputs to block and later unblock holder-side signing operations. This lets focused force-close fuzzing reuse the signer-op machinery without carrying the larger mining and settlement model.
1 parent 467cd0b commit ba0e4c5

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

fuzz/src/chanmon_consistency.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,16 @@ impl SignerProvider for KeyProvider {
718718
}
719719
}
720720

721-
// Since this fuzzer is only concerned with live-channel operations, we don't need to worry about
722-
// any signer operations that come after a force close.
723-
const SUPPORTED_SIGNER_OPS: [SignerOp; 4] = [
721+
// These signer operations can be blocked by fuzz bytes. The first four cover
722+
// live-channel and splice signing, while the holder-side operations cover local
723+
// on-chain claim signing after LDK has moved a channel to chain handling.
724+
const SUPPORTED_SIGNER_OPS: [SignerOp; 6] = [
724725
SignerOp::SignCounterpartyCommitment,
725726
SignerOp::GetPerCommitmentPoint,
726727
SignerOp::ReleaseCommitmentSecret,
727728
SignerOp::SignSpliceSharedInput,
729+
SignerOp::SignHolderCommitment,
730+
SignerOp::SignHolderHtlcTransaction,
728731
];
729732

730733
impl KeyProvider {
@@ -1024,6 +1027,18 @@ impl<'a> HarnessNode<'a> {
10241027
self.node.timer_tick_occurred();
10251028
}
10261029

1030+
// Re-enables holder-side signer operations and asks the chain monitor to
1031+
// retry pending claim transactions. Holder signing becomes relevant after
1032+
// on-chain close handling starts.
1033+
fn enable_holder_signer_ops(&self) {
1034+
// Holder-side signing is requested when a node needs to build local
1035+
// on-chain claim transactions. Keep it separate from live-channel
1036+
// signing so fuzz inputs can choose when those requests unblock.
1037+
self.keys_manager.enable_op_for_all_signers(SignerOp::SignHolderCommitment);
1038+
self.keys_manager.enable_op_for_all_signers(SignerOp::SignHolderHtlcTransaction);
1039+
self.monitor.signer_unblocked(None);
1040+
}
1041+
10271042
fn current_feerate_sat_per_kw(&self) -> FeeRate {
10281043
self.fee_estimator.feerate_sat_per_kw()
10291044
}
@@ -2959,9 +2974,14 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
29592974
self.nodes[1].keys_manager.enable_op_for_all_signers(op);
29602975
self.nodes[2].keys_manager.enable_op_for_all_signers(op);
29612976
}
2977+
// Live-channel signer work retries through the manager, while
2978+
// on-chain holder claims retry through the chain monitor.
29622979
self.nodes[0].signer_unblocked(None);
29632980
self.nodes[1].signer_unblocked(None);
29642981
self.nodes[2].signer_unblocked(None);
2982+
self.nodes[0].monitor.signer_unblocked(None);
2983+
self.nodes[1].monitor.signer_unblocked(None);
2984+
self.nodes[2].monitor.signer_unblocked(None);
29652985

29662986
self.process_all_events();
29672987

@@ -3383,6 +3403,13 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(data: &[u8], out: Out) {
33833403
.enable_op_for_all_signers(SignerOp::SignSpliceSharedInput);
33843404
harness.nodes[2].signer_unblocked(None);
33853405
},
3406+
// Keep holder signer unblocks adjacent to the existing signer op
3407+
// bytes. The helper re-enables both holder-side operations for
3408+
// every signer owned by the selected node, matching the existing
3409+
// key-manager-wide blocking model.
3410+
0xe4 => harness.nodes[0].enable_holder_signer_ops(),
3411+
0xe5 => harness.nodes[1].enable_holder_signer_ops(),
3412+
0xe6 => harness.nodes[2].enable_holder_signer_ops(),
33863413

33873414
0xf0 => harness.ab_link.complete_monitor_updates_for_node(
33883415
0,

0 commit comments

Comments
 (0)