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

lnd: add devrpc sub server and devrpc.ImportGraph to import graph dumps #6149

Merged
merged 6 commits into from
Jan 28, 2022

Conversation

bhandras
Copy link
Collaborator

@bhandras bhandras commented Jan 10, 2022

The PR adds the devrpc package which implements a subserver that is activated with the dev build tag. Additionally the PR adds the devrpc.ImportGraph call and lncli importgraph command to allow importing (large) graphs from dumps cleanly for performance and other testing purposes.

@bhandras bhandras marked this pull request as ready for review January 19, 2022 20:50
@bhandras bhandras changed the title [wip] lnd: RPC to import graph dumps to LND lnd: add devrpc sub server and devrpc.ImportGraph to import graph dumps Jan 19, 2022
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Yayy to the development only RPC 💯
This will be very useful for performance tests!

Just a few small comments, will run a full test run during my second pass.

lnrpc/devrpc/log.go Outdated Show resolved Hide resolved
lnd.go Outdated Show resolved Hide resolved
lnrpc/devrpc/dev.proto Show resolved Hide resolved
lnd.go Outdated Show resolved Hide resolved
Comment on lines 11 to 12
ImportGraph imports a ChannelGraph into the graph database. Shall not be
used for normal operation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does "shall not be used for normal operation" mean? That we don't use the graph data if we import it? Or that its only intended for testing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, so only for development purposes? I think "should only be used for development" is a bit clearer ?

Copy link
Collaborator Author

@bhandras bhandras Jan 24, 2022

Choose a reason for hiding this comment

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

Ok, so only for development purposes?

Yes.

I think "should only be used for development" is a bit clearer ?

Thanks, much better the way you phrased.

node := &channeldb.LightningNode{
HaveNodeAnnouncement: true,
LastUpdate: time.Unix(
int64(rpcNode.LastUpdate), 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will we always have a non-zero rpcNode.LastUpdate? If not, this will set to 1 sept 1970. Perhaps we should validate since its coming from user input?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How would validation look like for these timestamps? I suppose we could use a threshold of say 2019. Jan 1., but that's also not perfect. Also validating the timestamp may restrict testing.

Copy link
Collaborator

@carlaKC carlaKC Jan 25, 2022

Choose a reason for hiding this comment

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

Can we just check that the values are non-zero? Or do nodes sometimes not have a last update time?

If they can have zero times, then I think we should only set LastUpdate = time.Unix(rpcNode.LastUpdate,0) if its non-zero. That way we have an empty time.Time{} and .IsZero will work. As is, we set all zero values to unix epoch zero, which doesn't really make sense.

policy := &channeldb.ChannelEdgePolicy{
ChannelID: rpcEdge.ChannelId,
LastUpdate: time.Unix(
int64(rpcPolicy.LastUpdate), 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same time question here. Also we we need to validate any other fields, or are they checked later on when we do the import in UpdateEdgePolicy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Similarly what's a valid timestamp for a routing policy update?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Surely this can't be zero?

@@ -0,0 +1,67 @@
//go:build dev
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to update makefile's linter to include files behind build tags, or are they already covered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, we never covered files with the dev tag before. Added in separate commit.

lnd.go Show resolved Hide resolved
This commits adds the devrpc package which implements a subserver that
adds clean separation for RPC calls useful for development and
debugging. This subserver is only compiled in if the dev tag is set.
Furthermore the commit adds the devrpc.ImportGraph call which can
import a graph dump obtained from another node by calling DescribeGraph.
Since the graph dump does not include the auth proofs, the imported
channels will be considered private.
Copy link
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

tACK! Just think we need to validate 0 value timestamps, works a charm otherwise!

client, cleanUp := getDevClient(ctx)
defer cleanUp()

jsonFile := lncfg.CleanAndExpandPath(ctx.Args().First())
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: could check Nargs=1 here

@guggero guggero merged commit b77c1fb into lightningnetwork:master Jan 28, 2022
@Roasbeef Roasbeef added this to the v0.15.0 milestone Jan 28, 2022
guggero added a commit to guggero/lnd that referenced this pull request Jan 31, 2022
The API doc generator failed after merging lightningnetwork#6149 because of the `lncli
importgraph` tag in the proto file.
We could also fix the API doc generator by adding the "dev" build tag,
but not including any dev only features in the API docs is probably the
preferred path.
@bhandras bhandras deleted the graph_import_rpc branch September 12, 2023 15:27
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

Successfully merging this pull request may close these issues.

4 participants