Skip to content
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

routing: improve BuildRoute robustness #6912

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

joostjager
Copy link
Contributor

@joostjager joostjager commented Sep 13, 2022

Applies the min_htlc channel policy in newRoute. Some routes cannot be reconstructed purely based on the final payment amount.

Additionally a sanity check for max_htlc is added.

With these changes, if becomes possible to simplify BuildRoute and remove the possibility of running into edge cases around min_htlc.

A follow-up to this is to let pathfinding consider channels that have a min_htlc above the running amount. This would for example allow a user to complete a 100 msat payment via a channel that has a 1000 msat min_htlc. The difference is paid in fees.

@joostjager joostjager marked this pull request as draft September 13, 2022 11:50
@joostjager joostjager changed the title routing: add newRoute htlc range checks routing: improve BuildRoute robustness Sep 13, 2022
Sanity check to prevent invalid routes from being constructed.
With newRoute being aware of min_htlc constraints, there
is no more need to do a forward pass in BuildRoute. This
also fixes potential edge cases where the forward pass
gets to a payment amount that still violates htlc ranges.

The downside of this simplification is that more value may
be dropped off along the path as fees rather than paying
extra to the final hop. However, as the primary intention
of the BuildRoute `min_amt` flag is to allow for cheap
probes, this change is likely to have no consequences.
@saubyk saubyk added the routing label Sep 13, 2022
@joostjager joostjager marked this pull request as ready for review September 14, 2022 12:50
}

pathEdges = append(pathEdges, policy)
edges[i] = policy
}

// Build and return the final route.
return newRoute(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am considering doing away with newRoute completely. BuildRoute already steps though the hops and could just as well build the final route structure on the fly. This would also uncover potential bugs in BuildRoute that are later smoothed over in the final newRoute pass.

For pathfinding this may be even more relevant. If pathfinding chooses a sub-optimal path because of a bug, newRoute may fix it without anyone noticing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented alternative in #6920

@lightninglabs-deploy
Copy link

@bitromortac: review reminder

@joostjager joostjager removed the request for review from bitromortac September 22, 2022 08:48
@joostjager joostjager marked this pull request as draft September 22, 2022 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants