-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
ebd9f68
to
2871c7d
Compare
devrpc
sub server and devrpc.ImportGraph
to import graph dumps
2871c7d
to
9386ab5
Compare
There was a problem hiding this 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.
97d4cd0
to
83ec7b3
Compare
lnrpc/devrpc/dev.proto
Outdated
ImportGraph imports a ChannelGraph into the graph database. Shall not be | ||
used for normal operation. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.
83ec7b3
to
39ea802
Compare
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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
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.
The PR adds the
devrpc
package which implements a subserver that is activated with thedev
build tag. Additionally the PR adds thedevrpc.ImportGraph
call andlncli importgraph
command to allow importing (large) graphs from dumps cleanly for performance and other testing purposes.