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

cli: generate account key if not specified #3255

Open
kanishkatn opened this issue May 11, 2023 · 12 comments
Open

cli: generate account key if not specified #3255

kanishkatn opened this issue May 11, 2023 · 12 comments
Labels
S-cli issue related to Gossamer CLI.

Comments

@kanishkatn
Copy link
Contributor

Issue summary

If the account key is not specified in the cli flags, we need to generate one for the user.

@danforbes
Copy link
Contributor

What is the current behavior?

@danforbes danforbes added the CLI label May 15, 2023
@kanishkatn
Copy link
Contributor Author

What is the current behavior?

For westend-dev and westend-local, it defaults to alice.
For the rest,

  • as a full-node, it runs without a key.
  • as a validator, the node crashes

In substrate, if we're using custom keys, the docs takes us through creating the keystore first before running the node.

@1garo
Copy link
Contributor

1garo commented Nov 13, 2023

wanted to contribute to this issue, is it okay?

@kanishkatn
Copy link
Contributor Author

Of course @1garo ! I am off at the moment and can provide more context in a couple of days!

@1garo
Copy link
Contributor

1garo commented Nov 13, 2023

Of course @1garo ! I am off at the moment and can provide more context in a couple of days!

Sounds great, in the meantime I'm gonna take a look if I can have some progress.

@kanishkatn
Copy link
Contributor Author

kanishkatn commented Nov 15, 2023

Hey @1garo,
Here's where the account is being parsed: https://github.com/ChainSafe/gossamer/blob/development/cmd/gossamer/commands/utils.go#L322

With the current default config setup, we won't have a scenario where the account would be empty. We want to remove the default values for account and generate one it if it is empty.

Happy to answer any questions you have!

@1garo
Copy link
Contributor

1garo commented Nov 16, 2023

I was able to generate the default keypair, I added a "default" case to LoadKeystore, and used ed25519.GenerateKeypair() and sr25519.GenerateKeypair() to generate the pairs (ed25519 for grandpa).

It passes but later on broke at:

2023-11-16T13:56:37-03:00 CRITICAL failed to run block production engine: cannot handle epoch: cannot initiate and get epoch handler: failed to initiate epoch: cannot get epoch data and start slot: cannot get latest epoch data: cannot get authority index: key not in BABE authority data	pkg=babe

@1garo
Copy link
Contributor

1garo commented Nov 16, 2023

Seems like that by generating this new pair, their public key is not understood as a Authority, because it fails in the getAuthorityIndex function in the following code:

	for i, auth := range Authorities {
		if bytes.Equal(pub.Encode(), auth.Key.Encode()) {
			return uint32(i), nil
		}
	}

@kanishkatn
Copy link
Contributor Author

Hey @1garo , could you create a draft PR? We could move the conversation there!

@1garo
Copy link
Contributor

1garo commented Nov 17, 2023

Of course, it's created: #3587

@kanishkatn
Copy link
Contributor Author

kanishkatn commented Nov 17, 2023

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. @EclesioMeloJunior could you confirm?

Further, 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 and production runs
  • Create clear separation for the development config
  • Store the auto generated account in disk
  • Ability to load the account from disk

Thank you for your time and patience @1garo ! I believe this separation isn't a priority for us (core contributors) at the moment. If you're interested in contributing to CLI, I can create issues.

@kanishkatn kanishkatn mentioned this issue Nov 18, 2023
5 tasks
@1garo
Copy link
Contributor

1garo commented Nov 20, 2023

Thank you for your time and patience @1garo ! I believe this separation isn't a priority for us (core contributors) at the moment. If you're interested in contributing to CLI, I can create issues.

I would love to! I feel that contributing to the CLI could help me understand gossamer better, so it's a win-win.

@P1sar P1sar removed CLI labels Jan 15, 2024
@P1sar P1sar added the S-cli issue related to Gossamer CLI. label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-cli issue related to Gossamer CLI.
Projects
None yet
Development

No branches or pull requests

4 participants