Skip to content

askrene-getroutes adaptive bounds - #9380

Draft
Lagrang3 wants to merge 2 commits into
ElementsProject:masterfrom
Lagrang3:xpay-adaptive-bounds
Draft

askrene-getroutes adaptive bounds#9380
Lagrang3 wants to merge 2 commits into
ElementsProject:masterfrom
Lagrang3:xpay-adaptive-bounds

Conversation

@Lagrang3

@Lagrang3 Lagrang3 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

After #9150, some flaws in askrene came to light. I've documented as much as I saw appropriate
in the code and commit messages, but for more details there was a thought process explained in #9282.

TLDR:

  • we update fake channeld to simulate an evolving network, liquidity is not just assigned but it moves when a payment succeeds,
  • in askrene's probability cost function we drop the assumption that the cost of X is not far from the cost of X+fees, we instead pessimistically assume a 1% fee attached to every amount,
  • min/max bounds are adaptively relaxed when there is evidence of our knowledge being wrong.

@Lagrang3 Lagrang3 added this to the v26.09 milestone Aug 5, 2026
@Lagrang3
Lagrang3 marked this pull request as draft August 5, 2026 07:07
Improved the fakenet simulation by moving funds after a payment
succeeds.

This triggers a bug in xpay. At PAYING Node ElementsProject#8 xpay fails after trying
many 1msat routes:
```
error: {'code': 209, 'message': "Timed out after after 842 attempts.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102199msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102197msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102196msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102195msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102194msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102193msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102192msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102191msat.
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198102190msat
...
We got temporary_channel_failure for 45210x2134x44171/0, assuming it can't carry 198101779msat.
Payment of 9996982msat reached destination, but timed out before the rest arrived..
Payment of 998000msat reached destination, but timed out before the rest arrived..
Payment of 3000000msat reached destination, but timed out before the rest arrived..
Payment of 197000000msat reached destination, but timed out before the rest arrived..
Payment of 91005018msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived..
...
Payment of 1msat reached destination, but timed out before the rest arrived..
Payment of 1msat reached destination, but timed out before the rest arrived.. "}
```

A lower bound learned for channel 45210x2134x44171 at a previous payment
is to blame. xpay thinks it has enough liquidity for ~198ksat 100% sure
and it keeps trying and failing, while refine produces 1msat alternative
payment routes after every MCF computation because fees don't fit even
for our current knowledge. As a matter of fact the computed routes are
attributed a very low probability of success at around ~0.4%. This is a
case for which our assumption that "the cost of X+fees is not much
greater than the cost of X" breaks down.

To fix this:
-  we need xpay to relax that lower bound. The multiple failures are
empirical evidence that our knowledge is wrong and we should correct it,
- the probability cost function should add a buffer for hypothetical
  fees, ie. New_cost(x) = Old_cost(x + fees).

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
When the known max and known min are about the same value, the
probability cost of sending x=value is zero and MCF will try it.
It doesn't take into account the possibility that when we hit that
channel the actual flow is x+fees. We adjust the min/max bounds
by a factor of 1/1.01 like if we had a 1% reserve for fees.

Changelog-Fixed: askrene-getroutes: Account for a worst case 1% fee in the flow amount when computing probability costs.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
@Lagrang3
Lagrang3 force-pushed the xpay-adaptive-bounds branch from 8ac9c19 to 7bca9fb Compare August 5, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant