From 7e8f43d01700f3246bc282cbeb1ee59c361a1505 Mon Sep 17 00:00:00 2001 From: Nishant Bansal Date: Tue, 20 Oct 2026 23:38:55 +0530 Subject: [PATCH] smite-scenarios: use received_channel_ready_point for channel_ready Checking for a received channel_ready is shorter than checking for the first commitment with no known next per-commitment point, and stays correct once the commitment advances. Signed-off-by: Nishant Bansal --- smite-scenarios/src/executor.rs | 16 +++++++--------- smite-scenarios/src/executor/tests.rs | 7 +++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/smite-scenarios/src/executor.rs b/smite-scenarios/src/executor.rs index fe58d6ae..faf56713 100644 --- a/smite-scenarios/src/executor.rs +++ b/smite-scenarios/src/executor.rs @@ -1367,20 +1367,18 @@ fn recv_bolt( /// Returns `true` if the target owes us a `channel_ready` message. /// -/// A `channel_ready` is expected when a tracked channel's counterparty -/// commitment is still at commitment number 0, the counterparty's next -/// per-commitment point is unknown, the advertised funding outpoint pays the -/// negotiated funding output, the funding transaction was mined only after we -/// sent `funding_created`, we have not sent a signature the peer is required to -/// reject, and it has at least `minimum_depth` confirmations (as specified in -/// the received `accept_channel`). +/// A `channel_ready` is expected when a tracked channel has not yet received +/// one, the advertised funding outpoint pays the negotiated funding output, the +/// funding transaction was mined only after we sent `funding_created`, we have +/// not sent a signature the peer is required to reject, and it has at least +/// `minimum_depth` confirmations (as specified in the received +/// `accept_channel`). fn is_channel_ready_expected( channel_states: &HashMap, bitcoin_cli: &mut impl BitcoinRpc, ) -> bool { channel_states.values().any(|state| { - state.counterparty_commitment_state().commitment_number == 0 - && state.next_counterparty_per_commitment_point().is_none() + state.received_channel_ready_point.is_none() && state.is_funding_outpoint_valid && !state.was_funding_mined_prematurely && !state.sent_invalid_signature diff --git a/smite-scenarios/src/executor/tests.rs b/smite-scenarios/src/executor/tests.rs index b2236f0f..52f57a28 100644 --- a/smite-scenarios/src/executor/tests.rs +++ b/smite-scenarios/src/executor/tests.rs @@ -1344,6 +1344,7 @@ fn execute_recv_channel_ready_invalid_funding_outpoint_is_noop() { assert!(!state.was_funding_mined_prematurely); assert!(!state.sent_invalid_signature); assert!(state.next_counterparty_per_commitment_point().is_none()); + assert!(state.received_channel_ready_point.is_none()); assert_eq!(fx.queued_len(), 1); } @@ -1366,6 +1367,7 @@ fn execute_recv_channel_ready_below_minimum_depth_is_noop() { assert!(!state.was_funding_mined_prematurely); assert!(!state.sent_invalid_signature); assert!(state.next_counterparty_per_commitment_point().is_none()); + assert!(state.received_channel_ready_point.is_none()); assert_eq!(fx.queued_len(), 1); } @@ -1387,6 +1389,7 @@ fn execute_recv_channel_ready_at_minimum_depth_records_point() { *state.next_counterparty_per_commitment_point(), Some(target_pcp) ); + assert_eq!(state.received_channel_ready_point, Some(target_pcp)); assert_eq!(fx.queued_len(), 0); } @@ -1416,6 +1419,7 @@ fn execute_recv_channel_ready_funding_mined_prematurely_is_noop() { assert!(state.was_funding_mined_prematurely); assert!(!state.sent_invalid_signature); assert!(state.next_counterparty_per_commitment_point().is_none()); + assert!(state.received_channel_ready_point.is_none()); assert_eq!(fx.queued_len(), 1); } @@ -1448,6 +1452,7 @@ fn execute_recv_channel_ready_invalid_signature_is_noop() { assert!(!state.was_funding_mined_prematurely); assert!(state.sent_invalid_signature); assert!(state.next_counterparty_per_commitment_point().is_none()); + assert!(state.received_channel_ready_point.is_none()); assert_eq!(fx.queued_len(), 2); } @@ -1474,6 +1479,7 @@ fn execute_recv_channel_ready_resend_with_new_alias() { *state.next_counterparty_per_commitment_point(), Some(target_pcp) ); + assert_eq!(state.received_channel_ready_point, Some(target_pcp)); assert_eq!(fx.queued_len(), 0); assert_eq!(fx.channel_states().len(), 2); } @@ -1565,6 +1571,7 @@ fn execute_recv_channel_ready_already_recorded_is_noop() { *state.next_counterparty_per_commitment_point(), Some(target_pcp) ); + assert_eq!(state.received_channel_ready_point, Some(target_pcp)); assert!(state.funding_signed_received); assert_eq!(fx.queued_len(), 0); }