Closed JssDWt closed 7 months ago
From @cdecker: "Here's the selection code in v24.02: https://github.com/ElementsProject/lightning/blob/9b83b8b9674712bdb8af2d3c4e158eee1bf47b8f/lightningd/pay.c#L804-L855
This is the place where we can determine if a channel has sufficient capacity.
You could blacklist the one scid in that code if it's a one off, or you can add your selection criteria yourself."
Ok, found an easy way to disable the switch of the channel: have different feerates on them, or different base-fees.
The reason is we only switch if they both match:
Notice in particular these lines:
Causing best
to be hint
at the end if no other channel has the same fees.
The error appears to hint at the fact that channel_amount_spendable()
appears to not account correctly for reserve amounts, causing
to not discard a channel that is too small when trying. I assume by the way that this is a regular occurrence since due to the concurrency and possibility for balance changes between a channel beign picked and it being used, which may always cause this.
Ok, found an easy way to disable the switch of the channel: have different feerates on them, or different base-fees.
I don't think that would help with the issue, because quite a few failed forwards were actually using the channel in question initially.
I assume by the way that this is a regular occurrence since due to the concurrency and possibility for balance changes between a channel beign picked and it being used, which may always cause this.
It's definitely a regular occurrence. In the last 10 hours it affected approximately 93% of forwards.
Note that spendable_msat
is 225135, so it's very close to being depleted.
This issue is solved.
The issue was a difference in fee policies between two groups of channels. There were 3 depleted channels and they had a slightly different fee policy than the other channels that did have enough liquidity. So if the sender decided to send over channel A, which was depleted, the best_channel
function would only consider other channels with the same fee policy. But those channels were depleted too. So it would pick the 'best' depleted one, which was consistently the same channel, aka the one with 225 sat to spend.
Aligning the fees among all channels with the same peer solved the problem. If the sender now selects a random channel, the htlc is always forwarded over the channel with the largest spendable balance, as is expected.
Issue and Steps to Reproduce
getinfo
outputlogs
What you see here is a htlc coming in over channel A with peer
03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f
with htlc_id=514. It is then forwarded to peer0264a62a4307d701c04a46994ce5f5323b1ca28c80c66b73c631dbcb0990d6e835
. You see it's picking a 'better' channel for the route than the one requested. but this better channel is unable to route the htlc. So it should have picked yet another one.