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

Pay: use gossmap #4093

Merged

Conversation

rustyrussell
Copy link
Contributor

This is a simple translation, but it involves a routing fix and some enhancements.

Building on this to get more route information is a job for @cdecker.

(Moving getroute et-al out to a plugin is still in my todo list, as is random routing!)

@rustyrussell
Copy link
Contributor Author

Trivial rebase...

@rustyrussell
Copy link
Contributor Author

Ya trivial rebase.

Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Excellent change, I particularly like that since it is now synchronous we no longer end up trampling the channel_hints.

ACK 0bb0e54

Still seems a bit suboptimal to compute a route on a static map, and only afterwards considering things like route length, CLTV and fee constraints. We could add a view-layer on top of the gossmap, created for each dijkstra-call that keeps track of these parameters, and sets the distance to unreachable if any of these constraints is violated. If we add the struct payment to the scoring function we could even do this in the scoring function itself, not requiring us to change gossmap at all. But all that's for another time :-)

@@ -22,6 +22,9 @@ struct dijkstra {
/* NULL means it's been visited already. */
const struct gossmap_node **heapptr;

/* How we decide "best" */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/* How we decide "best" */
/* How we decide "best", lower is better */

Since I intuitively associate high scores with being better :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I'll do a followon cleanup commit.

struct amount_msat new_risk,
void *unused)
/* Prioritize costs over distance */
u64 route_score_cheaper(u32 distance,
Copy link
Member

Choose a reason for hiding this comment

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

Can we just use implementation of route_score_shorter and swap high and low bytes? Avoids duplicating the code.

common/gossmap.c Outdated
@@ -129,6 +130,18 @@ static void map_nodeid(const struct gossmap *map, size_t offset,
map_copy(map, offset, id, sizeof(*id));
}

static bool map_feature_set(const struct gossmap *map, int bit,
Copy link
Member

Choose a reason for hiding this comment

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

Could this be either is_set or get? Might be my Java past catching up with me, but set sounds like we're setting it :-)

common/gossmap.c Outdated
Comment on lines 876 to 879
if (map_feature_set(map, OPTIONAL_FEATURE(fbit),
c->cann_off + feature_len_off + 2, feature_len))
return OPTIONAL_FEATURE(fbit);
if (map_feature_set(map, COMPULSORY_FEATURE(fbit),
Copy link
Member

Choose a reason for hiding this comment

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

We could let map_feature_set return both optional and compulsory flags, in order to avoid calling it twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's fairly cheap, but since this is the only way we call it...

@cdecker
Copy link
Member

cdecker commented Oct 19, 2020

Tests using the gossip_store appear to be failing on Travis:

  • test_gossip_store_load
  • test_gossip_store_load_announce_before_update

Otherwise looking good 👍

@rustyrussell rustyrussell force-pushed the guilt/pay-map-gossip-store branch 2 times, most recently from 296fab9 to 1f48e7e Compare October 20, 2020 02:06
@rustyrussell
Copy link
Contributor Author

Ah, tests without COMPAT enabled. OK, fixed.

We were always ordering heap by distance, not score (which are different
if we are routing by cheapest, not shortest!).

This simplifies our callbacks, too.

Signed-off-by: Rusty Russell <[email protected]>
So we don't have to handle them at load time, either.

Signed-off-by: Rusty Russell <[email protected]>
We would return junk before.

Signed-off-by: Rusty Russell <[email protected]>
Faster than pulling the announce msg and parsing.  We need this to test
if the node supports TLV.

Signed-off-by: Rusty Russell <[email protected]>
Instead of a boutique message, use a "real" channel_announcement for
private channels (with fake sigs and pubkeys).  This makes it far
easier for gossmap to handle local channels.

Backwards compatible update, since we update old stores.

We also fix devtools/dump-gossipstore to know about the tombstone markers.

Since we increment our channel_announce count for local channels now,
the stats in the tests changed too.

Signed-off-by: Rusty Russell <[email protected]>
Start with attaching the payment to cmd (in case of failure), then steal
onto the plugin itself.

Signed-off-by: Rusty Russell <[email protected]>
So we can use this for routing determinations.

Signed-off-by: Rusty Russell <[email protected]>
This is a fairly direct translation.  Even so, it should be faster in
most cases, and and we can do more sophisticated things if we want.

This also handles disabled channels better.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Changed: plugins: `pay` will now try disabled channels as a last resort.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants