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: checkpointing/add create-bls-key cli #162

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

gitferry
Copy link
Contributor

@gitferry gitferry commented Sep 29, 2022

This PR added a new command create-bls-key to create a pair of BLS keys for the validator. This command should be run after priv_validator_key.json is generated via babylond init or babylond testnet.

An example of running this command is as follows.

babylond create-bls-key bbn1t2svgewfu5xd2dze5ty7lrvdwr7sf56agu6aa7

After the command is successfully executed, the content of the priv_validator_key.json should be like the following:

{
  "acc_address": "bbn1t2svgewfu5xd2dze5ty7lrvdwr7sf56agu6aa7",
  "address": "63AB4055C2E9FB554C20802BD5C1C7A000BE72B7",
  "pub_key": {
    "type": "tendermint/PubKeyEd25519",
    "value": "LMFLhKVaEtg4B4okjRhEohDS0zHjsTlBA2sP46buZf8="
  },
  "priv_key": {
    "type": "tendermint/PrivKeyEd25519",
    "value": "lI+wnSyPqIrtdZxJwXEVIqZShOQWjDaNjFR/ilH6hhEswUuEpVoS2DgHiiSNGESiENLTMeOxOUEDaw/jpu5l/w=="
  },
  "bls_pub_key": "oJjEhYzQkXEhbSBh3lwqTEo/vdEROLpISODgjtv1l9rZ028SiYLHTMgjoTjK4szbDe6bSZ3iUzjyLTnA48DN7q5z6UaPIfvHszuO8TYVUZ0c/IKH7SkJ0RQQc8z1X9/R",
  "bls_priv_key": "XrRLL/9ooimUK86tCl0m5+9V6peDnv0AeaoqK+1/Kfw="
}

This command is a prerequisite of adding a validator with BLS keys.

@aakoshh
Copy link
Contributor

aakoshh commented Oct 4, 2022

Can you add an example of how this command is called to the PR description?


func createBlsKeyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create-bls-key [account-address]",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use: "create-bls-key [account-address]",
Use: "create-bls-key [--account-address <bbn-account-address>]",

[] brackets mean this flag is optional, and the example should contain -- to show it's a flag, otherwise I would think the way to call this is create-bls-key or crate-bls-key bbn1f5tnl46mk4dfp4nx3n2vnrvyw2h2ydz6ykhk3r.

If it's not an optional parameter than maybe it should be an arg instead of a flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right. It should an arg instead of a flag. Thanks!

babylond create-bls-key --account-address bbn1f5tnl46mk4dfp4nx3n2vnrvyw2h2ydz6ykhk3r --home ./
`,
RunE: func(cmd *cobra.Command, _ []string) error {
homeDir, _ := cmd.Flags().GetString(flags.FlagHome)
Copy link
Contributor

Choose a reason for hiding this comment

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

The error is ignored here, but not for the account address. Does that mean this is optional, but the other isn't?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other one is an arg instead of a flag. FlagHome is optional. There's a default value for that.

send BLS signatures for checkpointing.

BLS keys are stored along with other validator keys in priv_validator_key.json,
which should exist before running the command.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can mention which command creates those files.

}
pv := privval.LoadWrappedFilePV(keyPath, statePath)
wrappedPV := privval.NewWrappedFilePV(pv.GetValPrivKey(), bls12381.GenPrivKey(), keyPath, statePath)
wrappedPV.SetAccAddress(addr)
Copy link
Contributor

Choose a reason for hiding this comment

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

So it automatically saves itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, when we set the account address, we should save the file.

Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

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

Looks good apart from some possible enhancements to make sure the user actually passes some values.

@gitferry
Copy link
Contributor Author

gitferry commented Oct 6, 2022

Thanks @aakoshh for your comments. I changed the account address into an arg instead of a flag. I also added an example in the description of the PR. Please see the updates. Thanks!

@gitferry
Copy link
Contributor Author

gitferry commented Oct 9, 2022

Hi @aakoshh, just a kind reminder that this PR might need another round of review. Thanks!

Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for the changes!

@gitferry gitferry merged commit b24cade into main Oct 10, 2022
@gitferry gitferry deleted the checkpointing/create-bls-cli branch October 10, 2022 02:22
vitsalis pushed a commit that referenced this pull request Jan 21, 2024
* Initial version of doc for btc scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants