You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ChannelDetails::outbound_capacity_msat needs to be more exact #1126
I had an issue locally where I'd be stuck unable to send a payment because the router kept selecting a channel and use all of the availability listed as outbound_capacity_msat before adding other MPP hops. However, outbound_capacity_msat isn't exact, and slightly over-counts the amount we can reasonably send (as documented, and ignored in get_route). This resulted in an un-sendable payment. The sample gave me this:
ERROR: failed to send payment: PartialFailure([Err(Cannot send value that would put our balance under counterparty-announced channel reserve value (30000000)), Ok(()), Err(Cannot send value that would not leave enough to pay for fees. Pending value to self: 38978302. local_commit_tx_fee 1656000)])
There are a lot of comments in get_route, and I'm not sure which one is referred to in this issue. Perhaps add the issue ID in the relevant code comment?
(happy to add the issue ID in my currently in-flight PR)
Hmm, not sure which comment either, but it doesn't matter much, the solution is to make outbound_capacity_msat a lower bound instead of an upper bound, especially now that we're splitting "balance" out from it.
hey @TheBlueMatt, since #1200 needs this issue fixed first, I can try taking a stab at this.
I started combing around and noticed that we use the EffectiveCapacity::ExactLiquidity enum to wrap nodes who we know the exact liquidity for (essentially “first hop” nodes we have established channels to?). I also saw that we mostly use as_msat() to retrieve capacity in the router so we don’t discriminate based on the different EffectiveCapacity cases. Does that mean we’ll have to do some kind of a check on our candidate hops with an effective_capacity of EffectiveCapacity::ExactLiquidity, and then set its capacity as a lower bound instead of an upper bound for deciding which first hop to use?
Will love some thoughts/suggestions on where is the best spot in get_route to do this check.
No, I think we don't need to change the routing/scoring logic at all here - we do want to communicate to the router/scorer that we have some exact available outbound liquidity - exactly what that enum variant means. That said, we're not communicating the "exact" liquidity exactly, which is the issue here - we need to ensure the ChannelDetails::outbound_capacity_msat field is updated to not include pending htlcs, in-flight limits, etc, etc. This isn't gonna be a trivial thing to do exactly right, but if you want to go for it, take a look at the limits applied in Channel::send... and try to match them in the outbound capacity calculation. If you at least just apply a few more of the corner cases we're better than we started!
@TheBlueMatt thanks for adding more information! I will take a look and play around, and will attach a PR if I can come up with something. In the meantime, if anyone else knows better about what they're doing, please feel free to pick this up!
if holder_balance_msat - amount_msat - commit_tx_fee_msat < chan_reserve_msat {
returnErr(ChannelError::Ignore(format!("Cannot send value that would put our balance under counterparty-announced channel reserve value ({})", chan_reserve_msat)));
}
with
holder_balance_msat 5000000 - amount_msat 500000 - commit_tx_fee_msat 3584000 < chan_reserve_msat 1000000
Err: [Channel unavailable: Cannot send value that would put our balance under counterparty-announced channel reserve value (1000000)]
To fix this we should somehow include the estimated commit_tx_fee in AvailableBalance. Finding a sane value for this might however be not entirely trivial as next_local_commit_tx_fee_msat() of course calculates the estimation based off a concrete HTLC candidate.
Activity
devrandom commentedon Dec 5, 2021
There are a lot of comments in
get_route, and I'm not sure which one is referred to in this issue. Perhaps add the issue ID in the relevant code comment?(happy to add the issue ID in my currently in-flight PR)
TheBlueMatt commentedon Dec 7, 2021
Hmm, not sure which comment either, but it doesn't matter much, the solution is to make
outbound_capacity_msata lower bound instead of an upper bound, especially now that we're splitting "balance" out from it.jurvis commentedon Mar 30, 2022
hey @TheBlueMatt, since #1200 needs this issue fixed first, I can try taking a stab at this.
I started combing around and noticed that we use the
EffectiveCapacity::ExactLiquidityenum to wrap nodes who we know the exact liquidity for (essentially “first hop” nodes we have established channels to?). I also saw that we mostly useas_msat()to retrieve capacity in the router so we don’t discriminate based on the differentEffectiveCapacitycases. Does that mean we’ll have to do some kind of a check on our candidate hops with aneffective_capacityofEffectiveCapacity::ExactLiquidity, and then set its capacity as a lower bound instead of an upper bound for deciding which first hop to use?Will love some thoughts/suggestions on where is the best spot in
get_routeto do this check.cc // @jkczyz
P.S: please excuse my noob-ish questions, still new to applying my Lightning knowledge in code 😄
TheBlueMatt commentedon Mar 30, 2022
No, I think we don't need to change the routing/scoring logic at all here - we do want to communicate to the router/scorer that we have some exact available outbound liquidity - exactly what that enum variant means. That said, we're not communicating the "exact" liquidity exactly, which is the issue here - we need to ensure the
ChannelDetails::outbound_capacity_msatfield is updated to not include pending htlcs, in-flight limits, etc, etc. This isn't gonna be a trivial thing to do exactly right, but if you want to go for it, take a look at the limits applied inChannel::send...and try to match them in the outbound capacity calculation. If you at least just apply a few more of the corner cases we're better than we started!jurvis commentedon Mar 31, 2022
@TheBlueMatt thanks for adding more information! I will take a look and play around, and will attach a PR if I can come up with something. In the meantime, if anyone else knows better about what they're doing, please feel free to pick this up!
Separate `ChannelDetails`' outbound capacity from the next HTLC max
Separate `ChannelDetails`' outbound capacity from the next HTLC max
Separate `ChannelDetails`' outbound capacity from the next HTLC max
Separate `ChannelDetails`' outbound capacity from the next HTLC max
Separate `ChannelDetails`' outbound capacity from the next HTLC max
Separate `ChannelDetails`' outbound capacity from the next HTLC max
Separate `ChannelDetails`' outbound capacity from the next HTLC max
3 remaining items
tnull commentedon Jan 18, 2023
I also ran into this/a very related issue in a regtest setup with the
ldk-samplenode. While the channel is listed as:a payment of 500000msat doesn't go through and I'm hitting:
rust-lightning/lightning/src/ln/channel.rs
Lines 5653 to 5655 in 98417a1
with
To fix this we should somehow include the estimated
commit_tx_feeinAvailableBalance. Finding a sane value for this might however be not entirely trivial asnext_local_commit_tx_fee_msat()of course calculates the estimation based off a concrete HTLC candidate.TheBlueMatt commentedon Feb 2, 2023
Had another user report of (I think) this again today. Gonna tag it 115 to bump priority.
naumenkogs commentedon Mar 1, 2023
Working on this.
TheBlueMatt commentedon Apr 17, 2023
Slipping to 116.
TheBlueMatt commentedon May 9, 2023
With fees going up this is becoming more of an issue, at least against the dust limit, so we should try to do at least a targeted fix for that.
Consider counterparty commitment tx fees when assembling a route
Consider counterparty commitment tx fees when assembling a route
Consider counterparty commitment tx fees when assembling a route