-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pay: respect maxfeepercent when choosing a shadow route #3693
pay: respect maxfeepercent when choosing a shadow route #3693
Conversation
771b64b
to
3ad208b
Compare
3ad208b
to
aea9467
Compare
I gave the docs a more thorough read, and, it turns out, they are actually correct:
So, it only claims that route randomisation respects Anyway, docs aside, there are two things here:
I think that this PR is definitely an improvement on (1), as it makes the behaviour more predictable. It also resolves (2), assuming that |
Right, amended the OP.
Actually you can in developer mode this PR hid a disabling parameter (
I think it can, but It does default to 50%.
It doesn't if the receiving peer has channel signaling a
Maybe, or put a treshold for it to take effect ? Like >10sat. |
Don't know if I introduced it with this patch, but |
Hmm I'm thinking that maybe we should still add the CLTV delta in this case, just not the amount. |
OK, so the test sometimes passes before the changes anyway, so let's make it firmer. Otherwise, excellent. Needs "Changelog-Fixed: pay: don't send occasional wrong amount for tiny amounts" and "Changelog-Changed: pay: respect maxfeepercent when creating shadow routes" though. diff --git a/tests/test_pay.py b/tests/test_pay.py
index c1373652f..af37eb0f9 100644
--- a/tests/test_pay.py
+++ b/tests/test_pay.py
@@ -462,18 +462,22 @@ def test_pay_maxfee_shadow(node_factory):
lambda: len(l1.rpc.listchannels(source=l2.info["id"])["channels"]) > 1
)
- # A tiny amount, we must not add the base_fee between l2 and l3
- amount = 2
- bolt11 = l2.rpc.invoice(amount, "tiny", "tiny")["bolt11"]
- pay_status = l1.rpc.pay(bolt11)
- assert pay_status["amount_msat"] == Millisatoshi(amount)
-
- # A bigger amount, shadow routing could have been used but we set a low
- # maxfeepercent.
- amount = 20000
- bolt11 = l2.rpc.invoice(amount, "bigger", "bigger")["bolt11"]
- pay_status = l1.rpc.pay(bolt11, maxfeepercent="0.000001")
- assert pay_status["amount_msat"] == Millisatoshi(amount)
+ # shadow routes are a bit random, so run multiple times.
+ for i in range(5):
+ # A tiny amount, we must not add the base_fee between l2 and l3
+ amount = 2
+ bolt11 = l2.rpc.invoice(amount, "tiny.{}".format(i), "tiny")["bolt11"]
+ pay_status = l1.rpc.pay(bolt11)
+ assert pay_status["amount_msat"] == Millisatoshi(amount)
+
+ # shadow routes are a bit random, so run multiple times.
+ for i in range(5):
+ # A bigger amount, shadow routing could have been used but we set a low
+ # maxfeepercent.
+ amount = 20000
+ bolt11 = l2.rpc.invoice(amount, "big.{}".format(i), "bigger")["bolt11"]
+ pay_status = l1.rpc.pay(bolt11, maxfeepercent="0.000001")
+ assert pay_status["amount_msat"] == Millisatoshi(amount)
def test_sendpay(node_factory): |
You can always use the lowlevel |
Ok, I usually comment out the randomization to test shadow routing :) Lines 1107 to 1108 in 34ed209
|
Fixed-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
And the percentage of the initial amount, not the constently increasing one ! Changelog-Fixed: pay: we now respect maxfeepercent, even for tiny amounts. Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
aea9467
to
7993285
Compare
Yes, that’s what I was considering, but I would also need to
For that I'd need to know the parameters of the channel, and rather than keeping track of them, it’s much easier to just cal |
Yes, pay will retry, but via a different path (if any available) which is probably not what you want? It won't wait for peers to come online or anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack 7993285
We claim to do so in the manpage.I was wrongfixes #3684