Skip to content

Commit 9ddf4dd

Browse files
committed
Fix tracking of collected value across pathfinding iterations
If we end up "paying" for an `htlc_minimum_msat` with fees, we increment `already_collected_value_msat` by more than the amount of the path that we collected (who's `value_contribution_msat` is higher than the total payment amount, despite having been reduced down to the payment amount). This throws off our total value collection target, though in the coming commit(s) it would also throw off our path selection calculations.
1 parent e8950ac commit 9ddf4dd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ where L::Target: Logger {
14641464
// Both these cases (and other cases except reaching recommended_value_msat) mean that
14651465
// paths_collection will be stopped because found_new_path==false.
14661466
// This is not necessarily a routing failure.
1467-
'path_construction: while let Some(RouteGraphNode { node_id, lowest_fee_to_node, total_cltv_delta, value_contribution_msat, path_htlc_minimum_msat, path_penalty_msat, path_length_to_node, .. }) = targets.pop() {
1467+
'path_construction: while let Some(RouteGraphNode { node_id, lowest_fee_to_node, total_cltv_delta, mut value_contribution_msat, path_htlc_minimum_msat, path_penalty_msat, path_length_to_node, .. }) = targets.pop() {
14681468

14691469
// Since we're going payee-to-payer, hitting our node as a target means we should stop
14701470
// traversing the graph and arrange the path out of what we found.
@@ -1530,7 +1530,9 @@ where L::Target: Logger {
15301530
// on some channels we already passed (assuming dest->source direction). Here, we
15311531
// recompute the fees again, so that if that's the case, we match the currently
15321532
// underpaid htlc_minimum_msat with fees.
1533+
debug_assert_eq!(payment_path.get_value_msat(), value_contribution_msat);
15331534
payment_path.update_value_and_recompute_fees(cmp::min(value_contribution_msat, final_value_msat));
1535+
value_contribution_msat = cmp::min(value_contribution_msat, final_value_msat);
15341536

15351537
// Since a path allows to transfer as much value as
15361538
// the smallest channel it has ("bottleneck"), we should recompute

0 commit comments

Comments
 (0)