Skip to content

ChannelDetails::outbound_capacity_msat needs to be more exact #1126

Closed

Description

@TheBlueMatt

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)])

Activity

  1. added this to the 0.1 milestone on Oct 15, 2021
  2. devrandom commented on Dec 5, 2021

    @devrandom
    Member

    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)

  3. TheBlueMatt commented on Dec 7, 2021

    @TheBlueMatt
    CollaboratorAuthor

    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.

  4. jurvis commented on Mar 30, 2022

    @jurvis
    Contributor

    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.

    cc // @jkczyz

    P.S: please excuse my noob-ish questions, still new to applying my Lightning knowledge in code 😄

  5. TheBlueMatt commented on Mar 30, 2022

    @TheBlueMatt
    CollaboratorAuthor

    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!

  6. jurvis commented on Mar 31, 2022

    @jurvis
    Contributor

    @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!

  7. 3 remaining items

  8. tnull commented on Jan 18, 2023

    @tnull
    Contributor

    I also ran into this/a very related issue in a regtest setup with the ldk-sample node. While the channel is listed as:

    local_balance_msat: 5000000,
    available_balance_for_send_msat: 4000000,
    

    a payment of 500000msat doesn't go through and I'm hitting:

    if holder_balance_msat - amount_msat - commit_tx_fee_msat < chan_reserve_msat {
    return Err(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.

  9. TheBlueMatt commented on Feb 2, 2023

    @TheBlueMatt
    CollaboratorAuthor

    Had another user report of (I think) this again today. Gonna tag it 115 to bump priority.

  10. modified the milestones: 0.1, 0.0.115 on Feb 2, 2023
  11. naumenkogs commented on Mar 1, 2023

    @naumenkogs
    Contributor

    Working on this.

  12. TheBlueMatt commented on Apr 17, 2023

    @TheBlueMatt
    CollaboratorAuthor

    Slipping to 116.

  13. modified the milestones: 0.0.115, 0.0.116 on Apr 17, 2023
  14. TheBlueMatt commented on May 9, 2023

    @TheBlueMatt
    CollaboratorAuthor

    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.

  15. self-assigned this
    on May 15, 2023
  16. added a commit that references this issue on May 21, 2023
    a9f8a14
  17. added a commit that references this issue on Jun 6, 2023
    52a9057
  18. added a commit that references this issue on Jul 24, 2023
    b5745f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions