Skip to content

Consider existing in-flight HTLCs when routing #1267

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

Closed
TheBlueMatt opened this issue Jan 19, 2022 · 7 comments
Closed

Consider existing in-flight HTLCs when routing #1267

TheBlueMatt opened this issue Jan 19, 2022 · 7 comments
Milestone

Comments

@TheBlueMatt
Copy link
Collaborator

lnd has a very long-standing bug where if you go to send a payment and it decides to split the payment, it may try to send both over the same channel, even if the channel does not have sufficient capacity to handle both parts. Instead, one part will be sent, and the other part will fail, leaving the payment to wait until the MPP times out. This is worse when paying an LDK client because of #1050. However, even on the sending side I believe we actually have the same bug. We should check for this and figure out how to handle this.

@TheBlueMatt TheBlueMatt modified the milestones: 0.1, 0.1.1 Jan 19, 2022
@jkczyz
Copy link
Contributor

jkczyz commented May 17, 2022

However, even on the sending side I believe we actually have the same bug. We should check for this and figure out how to handle this.

Is bookkept_channels_liquidity_available_msat (renamed in #1456 ) suppose to handles this?

let mut bookkept_channels_liquidity_available_msat = HashMap::with_capacity(network_nodes.len());

(cc: @jurvis)

@TheBlueMatt
Copy link
Collaborator Author

Yes, that handles it in the first route fetch, but we don't do any kind of bookkeeping across path retries. I'll be honest I'm not 100% sure what I was referring to here, but I think it was on retry, or certainly that would make sense.

@jkczyz
Copy link
Contributor

jkczyz commented Jun 15, 2022

@jurvis and I were chatting about this recently. IIUC, the problem can be more generally stated as accounting for known in-flight HTLCs across all our outstanding payments. Either way, the question may be how to keep track of this and what that means for the find_route / Router API.

One idea would be to track these in-flight HTLCs either separately or as part of the NetworkGraph. Perhaps the EventHandler implementation for NetworkGraph could manage this accounting. Thoughts?

@jkczyz
Copy link
Contributor

jkczyz commented Jun 15, 2022

One idea would be to track these in-flight HTLCs either separately or as part of the NetworkGraph. Perhaps the EventHandler implementation for NetworkGraph could manage this accounting. Thoughts?

Ah, but that would only be helpful for removing HTLCs which are no longer in flight. Adding them would require a mutable NetworkGraph. So maybe an auxiliary data structure would be needed.

Edit: Hmmm... such a data structure would need to be mutated when actually sending the payment (i.e., in ChannelManager). The coordination seems complicated. 🙁

@TheBlueMatt
Copy link
Collaborator Author

Yea it's really not clear to me what the right answer is here, I think naively the simplest approach is to store extra information in the InvoicePayer that can then be passed to find_route, some kind of in-flight tracking struct which can be efficiently queried for channel balance information.

@tnull
Copy link
Contributor

tnull commented Jun 16, 2022

I think an issue I encountered in #1526 is somewhat related: when calculating the minimum per-path value contribution, it would be nice to do this dynamically, i.e., allow a lower contribution for subsequent paths, if we have collected paths that contribute a good amount already. However, this is currently hard to do with the current logic in get_route, since at the time of collecting/checking paths we're not aware which other paths will end up in the final route. If we as of this issue would find a way to reliably track the state of all the MPP arms during routing, it may be worth having another look at this.

@TheBlueMatt TheBlueMatt changed the title Evaluate Payment Split Reliability Consider existing in-flight HTLCs when routing Jul 12, 2022
@tnull
Copy link
Contributor

tnull commented May 20, 2023

Closing as addressed in #1643.

@tnull tnull closed this as completed May 20, 2023
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

No branches or pull requests

3 participants