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

feat(cli): generate account key if not specified #3587

Conversation

1garo
Copy link
Contributor

@1garo 1garo commented Nov 17, 2023

Changes

  • If user don't specifcy account key in the cli flags, we generate.

Tests

go run cmd/gossamer/main.go --chain westend-dev

Issues

#3255

Primary Reviewer

@kanishkatn

@1garo 1garo changed the title WIP feat(cli): generate account key if not specified Nov 17, 2023
Copy link

codecov bot commented Nov 17, 2023

Codecov Report

Attention: Patch coverage is 5.00000% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 51.75%. Comparing base (d1ca7aa) to head (41b76cf).
Report is 36 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development    #3587      +/-   ##
===============================================
+ Coverage        50.51%   51.75%   +1.24%     
===============================================
  Files              230      232       +2     
  Lines            29006    23793    -5213     
===============================================
- Hits             14653    12315    -2338     
+ Misses           12856     9972    -2884     
- Partials          1497     1506       +9     

Copy link
Contributor

@kanishkatn kanishkatn left a comment

Choose a reason for hiding this comment

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

I'm still looking into the error!

Comment on lines +151 to +166
case "default":
if keyStore.Type() == "ed25519" {
kp, err := ed25519.GenerateKeypair()
if err != nil {
return err
}

return keyStore.Insert(kp)
} else {
kp, err := sr25519.GenerateKeypair()
if err != nil {
return err
}

return keyStore.Insert(kp)
}
Copy link
Contributor

@kanishkatn kanishkatn Nov 17, 2023

Choose a reason for hiding this comment

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

We currently only have the test key flow in the CLI. Check https://github.com/1garo/gossamer/blob/feat/generate-account-if-not-specified/cmd/gossamer/commands/root.go#L577

I feel we should separate out the flow for the keystore setup in the cmd package instead of this change. The rust implementation has --dev flag; maybe we could add the same!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean something like subkey?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe account generate already do that, I don't know if I really understood what you meant

Copy link
Contributor

Choose a reason for hiding this comment

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

I spent some more time going through the code. Thank you for your patience and time!

I believe we don't have the need to generate an account if not specified since we're still in development and only need development accounts.

If we want to support the use of auto-generated or external accounts, we'll have to

  • Add a new flag dev to enable the clear separation for the development runs
  • Clear separation for the development config
  • Store the auto generated account in disk
  • Ability to load the account from disk

I think this isn't a priority for us at the moment. I'll update the issue.

@1garo
Copy link
Contributor Author

1garo commented Nov 17, 2023

I'm still looking into the error!

I managed to make the error go away adding keyRing.Default() and reusing alice's grandpa priv key on ed25519PrivateKeys (adding a new index with the same value), so I feel that is something related to that, maybe we should be able to tell BABE about this new key, something like that

@EclesioMeloJunior
Copy link
Member

@kanishkatn regards this I think we don't need to introduce the --dev flag to separate development runs, actually it is possible to use development keys, such as alice or bob in any environment, so we should be able to use auto-generated in any environment also.

The following command should generate an account for me

./bin/gossamer --chain westend

But this following command should not generate an account but use alice test account instead

./bin/gossamer --chain westend --alice

I agree with these 2 specifications:

  • Store the auto-generated account in the disk
  • Ability to load the account from disk

@kanishkatn
Copy link
Contributor

@EclesioMeloJunior I agree. Thank you!

@q9f
Copy link
Contributor

q9f commented Jan 16, 2024

@1garo do you want to continue working on this or shall we take this over?

@q9f q9f added A-stale issue or PR is deprecated and needs to be closed. S-cli issue related to Gossamer CLI. labels Jan 16, 2024
@1garo
Copy link
Contributor Author

1garo commented Jan 16, 2024

I definitely can continue working on it!

@dimartiro
Copy link
Contributor

dimartiro commented Mar 28, 2024

Hey @1garo, how are the things going? Are you planning to continue working on this PR or can we close it as stale?

Let us know if you need any help

Thks!

@1garo
Copy link
Contributor Author

1garo commented Apr 3, 2024

Hey @1garo, how are the things going? Are you planning to continue working on this PR or can we close it as stale?

Let us know if you need any help

Thks!

Sorry for the delayed response, I will not be able to work on the PR.

Feel free to close or if someone wants to get the issue it's okay for me.

@dimartiro
Copy link
Contributor

Hey @1garo, how are the things going? Are you planning to continue working on this PR or can we close it as stale?
Let us know if you need any help
Thks!

Sorry for the delayed response, I will not be able to work on the PR.

Feel free to close or if someone wants to get the issue it's okay for me.

Thanks @1garo I'll close it for now.
Thanks for your contribution and I'm looking forward to see you around again.
Feel free to take any other issue or resume this one in the future 💪

@dimartiro dimartiro closed this Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stale issue or PR is deprecated and needs to be closed. S-cli issue related to Gossamer CLI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants