Repository navigation
Conversation
4eda748 to
f79367b
Compare
Add onion budget and payload constructors to the internal xpay API. Onion budget computation can be used to know a realistic number of hops that constraints our payment before calling askrene. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
bb8a219 to
67679bd
Compare
|
It was tricky to add a new feature cost (to have maxhops). Some changes were needed in |
|
Overall the per-hop penalty and maxhops do what a rebalancer wants: shorter routes and more requests settled in full. I looked at what happens with the xrebalance plugin using this algorithm. I ran the askrene commits at 67679bd offline against a mainnet gossip snapshot (about 30,000 channels with real capacities), sending 120 getroutes requests of the kind xrebalance makes when rebalancing (multi-part, 50M to 2.4B msat, 300 and 600 ppm fee budgets), and the same 120 against master. Three results:
The abort. combine_cost_function() asserts that the four weights (fees, delay, hop count, probability) sum to exactly 1.0, The fee weight. On master the first solve uses mu = 1 of MU_MAX = 100, so fees weigh 1% against probability 99%. linear_routes() now starts mu at 0.1 with probability at 0.88. To tell this apart from the per-hop change I ran the 120 requests three ways with the assertion fixed: master, the series as is, and the series with mu = 0.01 (probability 0.97). The per-hop factor does what the changelog says at either starting point: routes average 5.5 hops instead of 7.1, the longest is 12 or 13 instead of 19, and 99 requests find routes for the full amount instead of 88. The starting mu is a separate effect. At 0.1 the routes are cheaper, 270 ppm of the delivered amount against 321 on master, but less likely to succeed, median probability_ppm 972,997 against 994,735, and the solver finishes in half the time because it needs fewer retries. At 0.01 the fee rate and probability come back near master's (333 ppm, 983,433) and the shorter routes stay. If the new starting point is intended, a changelog line would help callers that tune maxfee around the old behavior. If not, 0.01 reproduces the old weighting. maxhops. With limits of 20, 12 and 8 the results were identical or nearly identical to no limit: no route was longer than 13 hops, 12 changed one request's routes and 8 changed seven, with no cost in delivered amount or fee rate. An unreachable limit fails with PAY_ROUTE_NOT_FOUND and "excessive hop count", which a caller that already treats 205 as "no route" handles without change. |
Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Added an homogeneous and constant cost to every hop in the MCF solver. Changelog-Changed: askrene-getroutes: penalizes every extra hop in every route with an homogeneous and constant probability of failure of 1%, as a consequence askrene will slightly prefer smaller routes. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Treat all cost features as the same type of variable. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Use cost dials normalized to 1 to combine the cost of different features. This is a generalization of the mu factor combination with medians ratio applied to more than 2 features: fees and delays. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-Added: askrene: getroutes: maxhops, a parameter to limit the length of the paths in the solutions. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-Fixed: xpay: Clamp the length of the payment routes using askrene's maxhops option aiming at producing routes that fit the data limits in the onion packet. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
67679bd to
c7dcc9a
Compare
Addresses: #9156
Supersedes: #9539
This PR adds a new constraint into askrene:
maxhops, to limit the length of the routes.Hard constraints of path length is not possible under the current implementation, minimum cost flows
do not allow that. Our approach is to add a constant cost per hop (a similar tweak in renepay #7540 was already deployed)
and scale that cost until the computed routes fit the
maxhopsconstraints.Fewer hops are expected with a base cost per hops and a
getroutesfailure if no routing solutionsare found satisfying
maxhopsconstraint.On
xpaywe compute theonion budgetfor each payment as the maximum number of hops we can afford to put insidean onion message given the hard limit of 1300 bytes for the onion package, payment amount, blockheight and tail
(ie. final payload in the case of bolt11 and blinded path plus final payload in the case of bolt12).
The onion budget is passed down to
getroutesso that solutions will not exceed it.No more "Could not create payment onion: path too long!" errors are expected afterwards, instead we might
get an error from
getroutesif no solutions can be found with themaxhopslimit.TODO:
onion_budget,maxhopsconstraint intoaskrene,maxhopsinaskrene,xpaywith heavy final payloads bolt11,xpaywith heavy final payloads bolt12,maxhopsfrom a developer option to a user option and add documentation formaxhops,