-
Notifications
You must be signed in to change notification settings - Fork 828
Client: Save node key #1067
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
Client: Save node key #1067
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
right, I don't think we should add a You can see in #1027 I actually parse them as The consistent key is great though, and I can add that to my newly updated libp2pserver file as well. Maybe we can create a helper func so the code isn't duplicated from rlpxserver. |
I think you are right. I will check if this is possible, since it might be that this string parser might choke upon the address string format. |
Just checked:
(First two bootnodes from mainnet Common). This parses the bootnodes wrong:
|
I can't come up with a consistent format scheme here, will open an issue. |
c5a26ca
to
4b0df76
Compare
@jochem-brouwer can you give this another look at some PIT? |
Will make this one merge-ready ASAP @holgerd77 😄 |
@jochem-brouwer can you do an update here? |
(if time permits, not super urgent, but would be nice to get this finished) |
@holgerd77 Yep, sorry forgot about this one. Will probably do today, but by end of this weekend the latest. |
No problem. 😄 |
Just rebased this one. If we want to introduce this node key into a new database (which we currently don't have) I am facing the problem where I should put the database. The logical place for this database would be to be in Config. Would it make sense to add a global config DB here? This would depend on the data dir, so we don't use the same config for e.g. mainnet and rinkeby. |
4b0df76
to
518eaea
Compare
@jochem-brouwer yeah, I think it makes sense to add a global config DB and the
I am not sure here, we'll likely have both global configuration parameters as well as chain-specific ones. Would it be a way to simplify and use one DB for both, and then prefix keys, so e.g. |
If we want to have global config and also chain-specific config, would it then make sense to introduce a global database and also a chain-specific one? |
For me having 5 databases for 20 config parameters sound a bit overblown, but I'm also really no expert here. Would be happy on further voices. |
150e069
to
6df134e
Compare
6df134e
to
f1854b4
Compare
I rebased this and added a client config leveldb in the network directory for getting and setting the client key. |
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.
Nice, LGTM! 😄 Will directly use this to more comfortably debug #1147, hehe 😛 (really annoying to always copy over a new enode ID on every new test run)
@@ -175,11 +175,14 @@ async function run() { | |||
} | |||
|
|||
const common = new Common({ chain, hardfork: 'chainstart' }) | |||
const datadir = args.datadir ?? Config.DATADIR_DEFAULT |
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.
Won't make this a blocker, but this shouldn't be necessary since datadir
has a local CLI-specific default (first was afraid that this would actually change the default, but this is not the case)? 🤔
Ah, and also tested this locally and can confirm that this works, client key / network URL is perceived. |
const config = new Config({ | ||
common, | ||
syncmode: args.syncmode, | ||
lightserv: args.lightserv, | ||
datadir: args.datadir, | ||
datadir, | ||
key, |
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.
I wonder though if we want to make the name of this option a bit more expressive?
@ryanio on a closer look I think this is logically wrong, the client key from the DB shouldn't be re-passed in to When trying to fix this (with Will rework this a bit along #1147. |
@ryanio Update: ok, I am slowly getting why you are doing this, seems this has again this I would still assume that this is structurally not correct and we should give this some additional thought (it just shouldn't be necessary to have access to the configuration database to actually create a |
@holgerd77 ah thanks, yeah I had some challenges with the async nature of saving or getting the client key from the db, so I had to move the async part out of the config/server instantiation. |
This PR ensures that we save the node key to disk. This is saved in the root directory of the current network. This way, we ensure that we will re-use the enode, such that we can quickly reconnect, or add our client as a bootnode. This would not be possible if it is not saved, since then our enode keeps changing every time we reboot the client.