-
Notifications
You must be signed in to change notification settings - Fork 20.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
cmd/geth: accountcmd no need to acquire the datadir lock #27084
Conversation
When a node is running it can modify the accounts in the keystore, e.g. through API or console. Maybe this would make sense after personal namespace has been fully deleted? (#26390) |
This is kind of a hack but you can temporarily check for |
this datadir is used for |
Regarding the concurrency model, right now, the semantics are as follows:
The mutex does not seem to be meant to cover the keystore area. But neither does it only access chaindata -- it's all leveldb databases (e.g. light), it's also the triecache, the jwtsecret and nodekey. Now, the changes in this PR modifies it, such that the mutex is simply not checked in certain conditions.
I think the PR is semantically correct -- it does respect the existing concurrency model. All in all, I'm not in favour of this added complexity for what I believe is a very niche usecase (afaiu, it's been the way it for at least 5+ years and I've never heard any complaints about it). |
An alternative fix that might be less hacky could be to add, so in addition to the existing
We add a third one, which is even more minimal, e.g. :
That one would have to use a different node constructor, e.g:
And that new constructor would only configure the e.g. keystore, but not initialize the http endpoints or open the chaindata. I don't know if that would be better, but it's possible. Consider it an idea, not a command :) |
@holiman Thank you very much for your detailed explanation, as well as the usage scenarios of mutex locks in the code, and your understanding of the tradeoffs in this PR. I will try to simplify the code change based on your suggestions. |
2a85dff
to
22844d5
Compare
@holiman PTAL, thanks |
I like to build on @holiman's idea and suggest not creating a |
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
This reverts commit ff6c0ee1b83c1d1bf155b0713aac566b9b17dea8. Signed-off-by: jsvisa <delweng@gmail.com>
This reverts commit 0d87f07a389cc3b426dc17525e1b2461d5468eb8. Signed-off-by: jsvisa <delweng@gmail.com>
This reverts commit fa4d47aa6752e3b81c4244c64e2a11815a2418f1. Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
This reverts commit a0d106d. Signed-off-by: jsvisa <delweng@gmail.com>
22844d5
to
f116f36
Compare
@s1na thanks for your advice, please take a look. |
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.
Please refactor setAccountManagerBackends
so instead of taking a Node
, it takes config, am, keydir
as params. Then in a new function makeAccountManager
you should read in config file if present similar to how makeConfigNode
does it and then set the manager backends.
We also need getKeyStoreDir
similar to how Node constructor uses it. Please make it a method of node.Config
and expose publicly.
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
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.
This PR turned out pretty clean in the end, LGTM
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, thanks!
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.
LGTM
) Makes the `geth account ... ` commands usable even if a geth-process is already executing, since the account commands do not read the chaindata, it was not required for those to use the same locking mechanism. --- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
) Makes the `geth account ... ` commands usable even if a geth-process is already executing, since the account commands do not read the chaindata, it was not required for those to use the same locking mechanism. --- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
…ereum#27084)" This reverts commit 59a8a24.
…ereum#27084)" This reverts commit 59a8a24.
Failed to run
geth account list
when the datadir was locked with a running geth instance: