Skip to content

Commit 54f8895

Browse files
authored
Merge pull request #2063 from valentinewallace/2023-03-remove-paymentpathfailed-retry
Remove `PaymentPathFailed::retry`
2 parents c18f705 + f89b7d6 commit 54f8895

File tree

8 files changed

+75
-127
lines changed

8 files changed

+75
-127
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,6 @@ mod tests {
13691369
failure: PathFailure::OnPath { network_update: None },
13701370
path: path.clone(),
13711371
short_channel_id: Some(scored_scid),
1372-
retry: None,
13731372
});
13741373
let event = receiver
13751374
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))
@@ -1389,7 +1388,6 @@ mod tests {
13891388
failure: PathFailure::OnPath { network_update: None },
13901389
path: path.clone(),
13911390
short_channel_id: None,
1392-
retry: None,
13931391
});
13941392
let event = receiver
13951393
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))

lightning/src/ln/channel.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7118,7 +7118,6 @@ mod tests {
71187118
first_hop_htlc_msat: 548,
71197119
payment_id: PaymentId([42; 32]),
71207120
payment_secret: None,
7121-
payment_params: None,
71227121
}
71237122
});
71247123

lightning/src/ln/channelmanager.rs

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ pub(crate) enum HTLCSource {
275275
first_hop_htlc_msat: u64,
276276
payment_id: PaymentId,
277277
payment_secret: Option<PaymentSecret>,
278-
/// Note that this is now "deprecated" - we write it for forwards (and read it for
279-
/// backwards) compatibility reasons, but prefer to use the data in the
280-
/// [`super::outbound_payment`] module, which stores per-payment data once instead of in
281-
/// each HTLC.
282-
payment_params: Option<PaymentParameters>,
283278
},
284279
}
285280
#[allow(clippy::derive_hash_xor_eq)] // Our Hash is faithful to the data, we just don't have SecretKey::hash
@@ -290,14 +285,13 @@ impl core::hash::Hash for HTLCSource {
290285
0u8.hash(hasher);
291286
prev_hop_data.hash(hasher);
292287
},
293-
HTLCSource::OutboundRoute { path, session_priv, payment_id, payment_secret, first_hop_htlc_msat, payment_params } => {
288+
HTLCSource::OutboundRoute { path, session_priv, payment_id, payment_secret, first_hop_htlc_msat } => {
294289
1u8.hash(hasher);
295290
path.hash(hasher);
296291
session_priv[..].hash(hasher);
297292
payment_id.hash(hasher);
298293
payment_secret.hash(hasher);
299294
first_hop_htlc_msat.hash(hasher);
300-
payment_params.hash(hasher);
301295
},
302296
}
303297
}
@@ -312,7 +306,6 @@ impl HTLCSource {
312306
first_hop_htlc_msat: 0,
313307
payment_id: PaymentId([2; 32]),
314308
payment_secret: None,
315-
payment_params: None,
316309
}
317310
}
318311
}
@@ -2467,12 +2460,12 @@ where
24672460
}
24682461

24692462
#[cfg(test)]
2470-
pub(crate) fn test_send_payment_along_path(&self, path: &Vec<RouteHop>, payment_params: &Option<PaymentParameters>, payment_hash: &PaymentHash, payment_secret: &Option<PaymentSecret>, total_value: u64, cur_height: u32, payment_id: PaymentId, keysend_preimage: &Option<PaymentPreimage>, session_priv_bytes: [u8; 32]) -> Result<(), APIError> {
2463+
pub(crate) fn test_send_payment_along_path(&self, path: &Vec<RouteHop>, payment_hash: &PaymentHash, payment_secret: &Option<PaymentSecret>, total_value: u64, cur_height: u32, payment_id: PaymentId, keysend_preimage: &Option<PaymentPreimage>, session_priv_bytes: [u8; 32]) -> Result<(), APIError> {
24712464
let _lck = self.total_consistency_lock.read().unwrap();
2472-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
2465+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv_bytes)
24732466
}
24742467

2475-
fn send_payment_along_path(&self, path: &Vec<RouteHop>, payment_params: &Option<PaymentParameters>, payment_hash: &PaymentHash, payment_secret: &Option<PaymentSecret>, total_value: u64, cur_height: u32, payment_id: PaymentId, keysend_preimage: &Option<PaymentPreimage>, session_priv_bytes: [u8; 32]) -> Result<(), APIError> {
2468+
fn send_payment_along_path(&self, path: &Vec<RouteHop>, payment_hash: &PaymentHash, payment_secret: &Option<PaymentSecret>, total_value: u64, cur_height: u32, payment_id: PaymentId, keysend_preimage: &Option<PaymentPreimage>, session_priv_bytes: [u8; 32]) -> Result<(), APIError> {
24762469
// The top-level caller should hold the total_consistency_lock read lock.
24772470
debug_assert!(self.total_consistency_lock.try_write().is_err());
24782471

@@ -2511,7 +2504,6 @@ where
25112504
first_hop_htlc_msat: htlc_msat,
25122505
payment_id,
25132506
payment_secret: payment_secret.clone(),
2514-
payment_params: payment_params.clone(),
25152507
}, onion_packet, &self.logger);
25162508
match break_chan_entry!(self, send_res, chan) {
25172509
Some(monitor_update) => {
@@ -2617,8 +2609,8 @@ where
26172609
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
26182610
self.pending_outbound_payments
26192611
.send_payment_with_route(route, payment_hash, payment_secret, payment_id, &self.entropy_source, &self.node_signer, best_block_height,
2620-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2621-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
2612+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2613+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
26222614
}
26232615

26242616
/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
@@ -2631,17 +2623,17 @@ where
26312623
&self.router, self.list_usable_channels(), || self.compute_inflight_htlcs(),
26322624
&self.entropy_source, &self.node_signer, best_block_height, &self.logger,
26332625
&self.pending_events,
2634-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2635-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
2626+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2627+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
26362628
}
26372629

26382630
#[cfg(test)]
26392631
fn test_send_payment_internal(&self, route: &Route, payment_hash: PaymentHash, payment_secret: &Option<PaymentSecret>, keysend_preimage: Option<PaymentPreimage>, payment_id: PaymentId, recv_value_msat: Option<u64>, onion_session_privs: Vec<[u8; 32]>) -> Result<(), PaymentSendFailure> {
26402632
let best_block_height = self.best_block.read().unwrap().height();
26412633
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
26422634
self.pending_outbound_payments.test_send_payment_internal(route, payment_hash, payment_secret, keysend_preimage, payment_id, recv_value_msat, onion_session_privs, &self.node_signer, best_block_height,
2643-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2644-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
2635+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2636+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
26452637
}
26462638

26472639
#[cfg(test)]
@@ -2693,8 +2685,8 @@ where
26932685
self.pending_outbound_payments.send_spontaneous_payment_with_route(
26942686
route, payment_preimage, payment_id, &self.entropy_source, &self.node_signer,
26952687
best_block_height,
2696-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2697-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
2688+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2689+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
26982690
}
26992691

27002692
/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
@@ -2711,8 +2703,8 @@ where
27112703
retry_strategy, route_params, &self.router, self.list_usable_channels(),
27122704
|| self.compute_inflight_htlcs(), &self.entropy_source, &self.node_signer, best_block_height,
27132705
&self.logger, &self.pending_events,
2714-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2715-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
2706+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2707+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
27162708
}
27172709

27182710
/// Send a payment that is probing the given route for liquidity. We calculate the
@@ -2722,8 +2714,8 @@ where
27222714
let best_block_height = self.best_block.read().unwrap().height();
27232715
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
27242716
self.pending_outbound_payments.send_probe(hops, self.probing_cookie_secret, &self.entropy_source, &self.node_signer, best_block_height,
2725-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2726-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
2717+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
2718+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv))
27272719
}
27282720

27292721
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
@@ -3447,8 +3439,8 @@ where
34473439
self.pending_outbound_payments.check_retry_payments(&self.router, || self.list_usable_channels(),
34483440
|| self.compute_inflight_htlcs(), &self.entropy_source, &self.node_signer, best_block_height,
34493441
&self.pending_events, &self.logger,
3450-
|path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
3451-
self.send_payment_along_path(path, payment_params, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv));
3442+
|path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv|
3443+
self.send_payment_along_path(path, payment_hash, payment_secret, total_value, cur_height, payment_id, keysend_preimage, session_priv));
34523444

34533445
for (htlc_source, payment_hash, failure_reason, destination) in failed_forwards.drain(..) {
34543446
self.fail_htlc_backwards_internal(&htlc_source, &payment_hash, &failure_reason, destination);
@@ -3834,9 +3826,9 @@ where
38343826
// from block_connected which may run during initialization prior to the chain_monitor
38353827
// being fully configured. See the docs for `ChannelManagerReadArgs` for more.
38363828
match source {
3837-
HTLCSource::OutboundRoute { ref path, ref session_priv, ref payment_id, ref payment_params, .. } => {
3829+
HTLCSource::OutboundRoute { ref path, ref session_priv, ref payment_id, .. } => {
38383830
if self.pending_outbound_payments.fail_htlc(source, payment_hash, onion_error, path,
3839-
session_priv, payment_id, payment_params, self.probing_cookie_secret, &self.secp_ctx,
3831+
session_priv, payment_id, self.probing_cookie_secret, &self.secp_ctx,
38403832
&self.pending_events, &self.logger)
38413833
{ self.push_pending_forwards_ev(); }
38423834
},
@@ -6858,7 +6850,6 @@ impl Readable for HTLCSource {
68586850
path,
68596851
payment_id: payment_id.unwrap(),
68606852
payment_secret,
6861-
payment_params,
68626853
})
68636854
}
68646855
1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
@@ -6870,7 +6861,7 @@ impl Readable for HTLCSource {
68706861
impl Writeable for HTLCSource {
68716862
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), crate::io::Error> {
68726863
match self {
6873-
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id, payment_secret, payment_params } => {
6864+
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id, payment_secret } => {
68746865
0u8.write(writer)?;
68756866
let payment_id_opt = Some(payment_id);
68766867
write_tlv_fields!(writer, {
@@ -6879,7 +6870,7 @@ impl Writeable for HTLCSource {
68796870
(2, first_hop_htlc_msat, required),
68806871
(3, payment_secret, option),
68816872
(4, *path, vec_type),
6882-
(5, payment_params, option),
6873+
(5, None::<PaymentParameters>, option), // payment_params in LDK versions prior to 0.0.115
68836874
});
68846875
}
68856876
HTLCSource::PreviousHopData(ref field) => {
@@ -7959,7 +7950,7 @@ mod tests {
79597950
// indicates there are more HTLCs coming.
79607951
let cur_height = CHAN_CONFIRM_DEPTH + 1; // route_payment calls send_payment, which adds 1 to the current height. So we do the same here to match.
79617952
let session_privs = nodes[0].node.test_add_new_pending_payment(our_payment_hash, Some(payment_secret), payment_id, &mpp_route).unwrap();
7962-
nodes[0].node.test_send_payment_along_path(&mpp_route.paths[0], &route.payment_params, &our_payment_hash, &Some(payment_secret), 200_000, cur_height, payment_id, &None, session_privs[0]).unwrap();
7953+
nodes[0].node.test_send_payment_along_path(&mpp_route.paths[0], &our_payment_hash, &Some(payment_secret), 200_000, cur_height, payment_id, &None, session_privs[0]).unwrap();
79637954
check_added_monitors!(nodes[0], 1);
79647955
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
79657956
assert_eq!(events.len(), 1);
@@ -7989,7 +7980,7 @@ mod tests {
79897980
expect_payment_failed!(nodes[0], our_payment_hash, true);
79907981

79917982
// Send the second half of the original MPP payment.
7992-
nodes[0].node.test_send_payment_along_path(&mpp_route.paths[1], &route.payment_params, &our_payment_hash, &Some(payment_secret), 200_000, cur_height, payment_id, &None, session_privs[1]).unwrap();
7983+
nodes[0].node.test_send_payment_along_path(&mpp_route.paths[1], &our_payment_hash, &Some(payment_secret), 200_000, cur_height, payment_id, &None, session_privs[1]).unwrap();
79937984
check_added_monitors!(nodes[0], 1);
79947985
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
79957986
assert_eq!(events.len(), 1);

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,20 +1868,13 @@ pub fn expect_payment_failed_conditions_event<'a, 'b, 'c, 'd, 'e>(
18681868
) {
18691869
if conditions.expected_mpp_parts_remain { assert_eq!(payment_failed_events.len(), 1); } else { assert_eq!(payment_failed_events.len(), 2); }
18701870
let expected_payment_id = match &payment_failed_events[0] {
1871-
Event::PaymentPathFailed { payment_hash, payment_failed_permanently, path, retry, payment_id, failure, short_channel_id,
1871+
Event::PaymentPathFailed { payment_hash, payment_failed_permanently, payment_id, failure,
18721872
#[cfg(test)]
18731873
error_code,
18741874
#[cfg(test)]
18751875
error_data, .. } => {
18761876
assert_eq!(*payment_hash, expected_payment_hash, "unexpected payment_hash");
18771877
assert_eq!(*payment_failed_permanently, expected_payment_failed_permanently, "unexpected payment_failed_permanently value");
1878-
assert!(retry.is_some(), "expected retry.is_some()");
1879-
assert_eq!(retry.as_ref().unwrap().final_value_msat, path.last().unwrap().fee_msat, "Retry amount should match last hop in path");
1880-
assert_eq!(retry.as_ref().unwrap().payment_params.payee_pubkey, path.last().unwrap().pubkey, "Retry payee node_id should match last hop in path");
1881-
if let Some(scid) = short_channel_id {
1882-
assert!(retry.as_ref().unwrap().payment_params.previously_failed_channels.contains(&scid));
1883-
}
1884-
18851878
#[cfg(test)]
18861879
{
18871880
assert!(error_code.is_some(), "expected error_code.is_some() = true");

lightning/src/ln/functional_tests.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,7 +4083,7 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) {
40834083
let cur_height = CHAN_CONFIRM_DEPTH + 1; // route_payment calls send_payment, which adds 1 to the current height. So we do the same here to match.
40844084
let payment_id = PaymentId([42; 32]);
40854085
let session_privs = nodes[0].node.test_add_new_pending_payment(our_payment_hash, Some(payment_secret), payment_id, &route).unwrap();
4086-
nodes[0].node.test_send_payment_along_path(&route.paths[0], &route.payment_params, &our_payment_hash, &Some(payment_secret), 200_000, cur_height, payment_id, &None, session_privs[0]).unwrap();
4086+
nodes[0].node.test_send_payment_along_path(&route.paths[0], &our_payment_hash, &Some(payment_secret), 200_000, cur_height, payment_id, &None, session_privs[0]).unwrap();
40874087
check_added_monitors!(nodes[0], 1);
40884088
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
40894089
assert_eq!(events.len(), 1);
@@ -9130,7 +9130,6 @@ fn test_inconsistent_mpp_params() {
91309130
if path_a[0].pubkey == nodes[1].node.get_our_node_id() {
91319131
core::cmp::Ordering::Less } else { core::cmp::Ordering::Greater }
91329132
});
9133-
let payment_params_opt = Some(payment_params);
91349133

91359134
let (our_payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(&nodes[3]);
91369135

@@ -9144,7 +9143,7 @@ fn test_inconsistent_mpp_params() {
91449143
dup_route.paths.push(route.paths[1].clone());
91459144
nodes[0].node.test_add_new_pending_payment(our_payment_hash, Some(our_payment_secret), payment_id, &dup_route).unwrap()
91469145
};
9147-
nodes[0].node.test_send_payment_along_path(&route.paths[0], &payment_params_opt, &our_payment_hash, &Some(our_payment_secret), 15_000_000, cur_height, payment_id, &None, session_privs[0]).unwrap();
9146+
nodes[0].node.test_send_payment_along_path(&route.paths[0], &our_payment_hash, &Some(our_payment_secret), 15_000_000, cur_height, payment_id, &None, session_privs[0]).unwrap();
91489147
check_added_monitors!(nodes[0], 1);
91499148

91509149
{
@@ -9154,7 +9153,7 @@ fn test_inconsistent_mpp_params() {
91549153
}
91559154
assert!(nodes[3].node.get_and_clear_pending_events().is_empty());
91569155

9157-
nodes[0].node.test_send_payment_along_path(&route.paths[1], &payment_params_opt, &our_payment_hash, &Some(our_payment_secret), 14_000_000, cur_height, payment_id, &None, session_privs[1]).unwrap();
9156+
nodes[0].node.test_send_payment_along_path(&route.paths[1], &our_payment_hash, &Some(our_payment_secret), 14_000_000, cur_height, payment_id, &None, session_privs[1]).unwrap();
91589157
check_added_monitors!(nodes[0], 1);
91599158

91609159
{
@@ -9200,7 +9199,7 @@ fn test_inconsistent_mpp_params() {
92009199

92019200
expect_payment_failed_conditions(&nodes[0], our_payment_hash, true, PaymentFailedConditions::new().mpp_parts_remain());
92029201

9203-
nodes[0].node.test_send_payment_along_path(&route.paths[1], &payment_params_opt, &our_payment_hash, &Some(our_payment_secret), 15_000_000, cur_height, payment_id, &None, session_privs[2]).unwrap();
9202+
nodes[0].node.test_send_payment_along_path(&route.paths[1], &our_payment_hash, &Some(our_payment_secret), 15_000_000, cur_height, payment_id, &None, session_privs[2]).unwrap();
92049203
check_added_monitors!(nodes[0], 1);
92059204

92069205
let mut events = nodes[0].node.get_and_clear_pending_msg_events();

0 commit comments

Comments
 (0)