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

cmd/geth: add developer account password support #17155

Closed
wants to merge 2 commits into from
Closed

cmd/geth: add developer account password support #17155

wants to merge 2 commits into from

Conversation

pavel-main
Copy link

During environment provisioning for integration testing, using same pre-defined deterministic values come in handy. Everyone becomes aware of team's specific conventions, e.g. "test server has X value for gas price", "Y for chain ID" etc.

Everytime geth starts in developer mode, it either generates new non-deterministic account or tries to unlock a specified keystore (by either --datadir or --keystore flags) with an empty string password. I need something in the middle - ability to unlock a custom keystore with specified password.

This feature is inspired by Truffle's --deterministic option (which might be non-trivial to implement here, considering the size of codebase): trufflesuite/ganache#24 (comment)

@karalabe
Copy link
Member

I'm not sure this is the correct use case though. The --dev mode was made to allow running a chain quickly to test stuff with. The reason we have support for the datadir is to allow saving your session for long running tasts. But `--dev will still create an account with an empty password, so that should be fine. You can even copy that particular account json key if you realy wanted to port it over to a different machine and/or CI setup.

What would be the use case for trying to open an existing account in developer mode? I'd consider that a dangerous move.

@pavel-main
Copy link
Author

@karalabe My personal use case is re-using same keystore on test environment with ephemeral private chain. While chain itself is being reset every iteration, the pre-generated keystore can be used again. Using empty passphrase is not an option, because of the software requirements.

I agree that it's kind of a special situation, but I don't see any danger here. This flag is part of dev group, so the unlocked keystore will only interact with developer chain.

@fjl
Copy link
Contributor

fjl commented Jul 10, 2018

Would it be possible for you to just copy a predefined keystore file into the dev datadir?

@pavel-main
Copy link
Author

@fjl That's exactly what I'm doing, but I want dev mode to support password-protected keystore. Right now it's trying to unlock it only with empty password, the thing I'm trying to make configurable.

@@ -1137,7 +1141,8 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
Fatalf("Failed to create developer account: %v", err)
}
}
if err := ks.Unlock(developer, ""); err != nil {
password := ctx.GlobalString(DeveloperPasswordFlag.Name)
Copy link
Member

Choose a reason for hiding this comment

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

You'd need to use this flag a bit higher too, when creating the developer account to remain consistent on all code paths.

Copy link
Author

Choose a reason for hiding this comment

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

@karalabe Thanks, updated my pull request

@pavel-main
Copy link
Author

pavel-main commented Sep 2, 2018

@karalabe Any tip on how-to pass these tests?

@karalabe
Copy link
Member

karalabe commented Jun 6, 2019

We've been discussing this, but we think there's a mostly simple workaround that allows you to use your own accounts already without having to jump into the rabbit hole of adding configuration flags for dev mode:

  • Start up Geth in current dev mode.
  • Copy your existing key into Geth's ephemeral keystore.
  • Do eth.sendTransaction({from: eth.account[0], to: eth.accounts[1], value: xxx}).

This will result in moving all the funds from the test account to your one and you can do whatever workflow you have. Would this solve your issue without having to make modifications to dev mode?

@karalabe karalabe closed this Jun 13, 2019
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.

4 participants