Skip to content

Commit

Permalink
routing: fix mc blinded path behaviour.
Browse files Browse the repository at this point in the history
Because we hot swap the target public key when sending to a
blinded path (pathfinding logic to enable mpp support for blinded
payments) we penalize the first hop after the intro node.
Also added a TODO which only keeps the mc data for blinded paths
in memory and discards it afterwards, because this data will never
be reused as soon as the invoice is expired or settled.
  • Loading branch information
ziggie1984 committed Nov 28, 2024
1 parent 41c2521 commit a1ed30d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 19 additions & 5 deletions routing/result_interpretation.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,25 @@ func (i *interpretedResult) processPaymentOutcomeIntermediate(route *mcRoute,
if introIdx == len(route.hops.Val)-1 {
i.finalFailureReason = &reasonError
} else {
// If there are other hops between the recipient and
// introduction node, then we just penalize the last
// hop in the blinded route to minimize the storage of
// results for ephemeral keys.
i.failPairBalance(route, len(route.hops.Val)-1)
// Penalize the first hop after the introduction node.
// This makes sure we do not retry this blinded path
// in our path finding logic with the same amount.
// In the pathfinding logic for blinded routes we swap
// the target pubkey for a general one so that
// multi-path payment can be attempted, so the last
// hop is not the one that we are considering during
// pathfinding. The case where the next hop after the
// introduction node is the final recipient is handled
// above, where we punish nothing but abort the payment
// by reporting a final failure reason.
//
// TODO(ziggie): Make sure we only keep mc data for
// blinded paths, in both the success and failure case,
// in memory during the time of the payment and remove
// it afterwards. Blinded paths and their blinded hop
// keys are always changing per blinded route so there
// is no point in persisting this data.
i.failPairBalance(route, introIdx)
}

// In all other cases, we penalize the reporting node. These are all
Expand Down
4 changes: 2 additions & 2 deletions routing/result_interpretation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ var resultTestCases = []resultTestCase{
pairResults: map[DirectedNodePair]pairResult{
getTestPair(0, 1): successPairResult(100),
getTestPair(1, 2): successPairResult(99),
getTestPair(3, 4): failPairResult(88),
getTestPair(2, 3): failPairResult(95),
},
},
},
Expand All @@ -567,7 +567,7 @@ var resultTestCases = []resultTestCase{
expectedResult: &interpretedResult{
pairResults: map[DirectedNodePair]pairResult{
getTestPair(0, 1): successPairResult(100),
getTestPair(2, 3): failPairResult(75),
getTestPair(1, 2): failPairResult(90),
},
},
},
Expand Down

0 comments on commit a1ed30d

Please sign in to comment.