Skip to content

path finding: Disable bit decoupling#2115

Merged
Roasbeef merged 4 commits into
lightningnetwork:masterfrom
halseth:disable-bit-decoupling
Dec 5, 2018
Merged

path finding: Disable bit decoupling#2115
Roasbeef merged 4 commits into
lightningnetwork:masterfrom
halseth:disable-bit-decoupling

Conversation

@halseth
Copy link
Copy Markdown
Contributor

@halseth halseth commented Oct 29, 2018

This PR consist of the first part of #2091 (Strict channel enabling):

  1. The path finding algorithm is modified to ignore the disable bit for local channels, allowing us to send payments on these channels even though they are publicly disabled. The assumption is that bandwidth hints of local channels will be set to a value reflecting their active status.

This essentially decouples the graph's disabled status from the local path finding, as the local channel status will be more up-to-date than what is found in the graph.

@halseth halseth mentioned this pull request Oct 29, 2018
Copy link
Copy Markdown
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM! you know it's good when the only comments are regarding commit msgs :P

Comment thread routing/missioncontrol.go Outdated
Comment thread routing/pathfind_test.go
Comment thread routing/pathfind.go Outdated
@Roasbeef Roasbeef added p2p Code related to the peer-to-peer behaviour discovery Peer and route discovery / whisper protocol related issues/PRs routing P3 might get fixed, nice to have labels Oct 31, 2018
@Roasbeef Roasbeef added this to the 0.5.2 milestone Oct 31, 2018
@halseth halseth requested a review from joostjager October 31, 2018 13:27
Comment thread routing/pathfind.go
// channel bandwidth than what is found in the graph.
bandwidthHints map[uint64]lnwire.MilliSatoshi
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This structs is quite a mix of parameters. How about creating two separate structs?

  • graphData (tx, graph, additionalEdges, bandwidthHints)

  • restrictions (ignoredNodes, ignoredEdges, feeLimit) (Absolute Time Lock Limit #1941 is adding a time lock limit to this)

And keep passing in sourceNode, targetNode and amt as direct function arguments. So 5 arguments in total.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That sounds like a reasonable way of splitting this up :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment thread routing/pathfind.go Outdated
// channel bandwidth than what is found in the graph.
// channel bandwidth than what is found in the graph. If set, it will
// override the capacities and disabled flags found in the graph when
// doing path finding. In particular, it should be set to the current
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If set, it will override the disabled flags found in the graph.

It isn't bandwidthHints that overrides the disabled flag, is it? Only the fact that a channel is local, overrides the disabled flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. I forgot to update the comment with the latest revision. I was contemplating whether it would also make sense to let the bandwidth hint override disabled flags for non-local channels, but figured for now that is not needed (as we don't use it).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@halseth halseth force-pushed the disable-bit-decoupling branch from 1e5366f to 40651f6 Compare November 6, 2018 12:28
Comment thread routing/pathfind_test.go Outdated
Comment thread routing/pathfind_test.go Outdated
cfromknecht
cfromknecht previously approved these changes Nov 9, 2018
Copy link
Copy Markdown
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@halseth halseth added P2 should be fixed if one has time and removed P3 might get fixed, nice to have labels Nov 13, 2018
@joostjager
Copy link
Copy Markdown
Contributor

I think as is it looks good, but I have two concerns about bandwidth hints:

  1. bandwidthhints and ignorededges overlap. an offline edge could also be passed in as an ignored edges, which may be clearer than using bandwidthhint (as the offline edge does have a bandwidth other than 0)
  2. bandwidthhints are bidirectional, which is not what it is in reality. maybe it could be redefined as bandwidthhint from smaller to larger node pubkey. the other way around, it is capacity - hint. This is also related to routing: prune single direction #2243 where directionality for ignored edges is added.

(but these are preexisting issues)

To avoid the findPath parameter list getting out of hand, we define new
structs that wraps the mandatory and optional parameters to findPath.
To decouple our own path finding from the graph state, we don't consider
the disable bit when attempting to use local channels. Instead the
bandwidth hints will be zero for local inactive channels.

We alos modify the unit test to check that the disable flag is ignored
for local edges.
This commit adds a new test that checks that the bandwidth hints are
considered correclty for local channels, and that disable flags are
ignored in this case.
@halseth
Copy link
Copy Markdown
Contributor Author

halseth commented Dec 4, 2018

bandwidthhints and ignorededges overlap. an offline edge could also be passed in as an ignored edges, which may be clearer than using bandwidthhint (as the offline edge does have a bandwidth other than 0)

Currently bandwidthHints are only used for local edges, while ignoredEdges are used for edges that fail during a paymentSession (most likely non-local edges?). I agree that this can be cleaned up. What about only passing in bandwidth hints, and set them to 0 for edges we want to ignore? We could also get rid of the ignored nodes by setting all their edges to bandwidth=0.

bandwidthhints are bidirectional, which is not what it is in reality. maybe it could be redefined as bandwidthhint from smaller to larger node pubkey. the other way around, it is capacity - hint. This is also related to #2243 where directionality for ignored edges is added.

Good observation! We should definitely make them bidirectional, as future more advanced routing might make use of that.

Sounds like these two improvements can go together in a follow-up PR or two, as it shouldn't be changing the behaviour achieved here, and as you mentioned are preexisting issues.

@joostjager
Copy link
Copy Markdown
Contributor

Yes, agree that this can be follow up PRs.

For those PRs: We can choose to use bandwidthHints to ignore edges, but then we need to have separate hints for both directions of a channel. That way, you can have a channel that has zero bandwidth in both directions (meaning both directions are disabled).

Alternatively, we could supply a bandwidth hint only for the direction smaller to greater pubkey and assume the opposite direction bandwidth as the capacity minus that bandwidth. In that case, it isn't possible anymore to disable both directions using the bandwidth hint.

@halseth
Copy link
Copy Markdown
Contributor Author

halseth commented Dec 4, 2018

I think explicitly having one hint for each direction is cleaner. That let us treat the directions induvidually. Also seems like the implicit method could lead to problems with the channel reserve (since bandwidth then not necessarily will be capacity-opposite bandwidht).

Copy link
Copy Markdown
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@Roasbeef Roasbeef merged commit 810afa9 into lightningnetwork:master Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discovery Peer and route discovery / whisper protocol related issues/PRs p2p Code related to the peer-to-peer behaviour P2 should be fixed if one has time routing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants