-
Notifications
You must be signed in to change notification settings - Fork 42
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: remove delegator address in WrappedFilePV, change init cmd and add migration cmd #434
Merged
gitferry
merged 5 commits into
babylonlabs-io:feat/bls-keystore-improvement
from
b-harvest:feat/wrapped-filepv-removal
Jan 24, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e657998
feat: add initcmd creating both comet and bls key files
wnjoon d296e09
feat: add migration cmd
wnjoon fb3ce52
feat: fix e2e_upgrade_test by adding new build tag
wnjoon efc8fcb
feat: update CHANGELOG
wnjoon bbe2efd
feat: verify migration after saving files and etc
wnjoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package app | ||
|
||
// This variable is only set true | ||
// when build tag is set to "e2e_upgrade" | ||
var IsE2EUpgradeBuildFlag bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build e2e_upgrade | ||
|
||
package app | ||
|
||
// init is used to include v1 upgrade testnet data | ||
// it is also used for e2e testing | ||
func init() { | ||
IsE2EUpgradeBuildFlag = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,47 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/babylonlabs-io/babylon/app" | ||
appparams "github.com/babylonlabs-io/babylon/app/params" | ||
"github.com/babylonlabs-io/babylon/privval" | ||
) | ||
|
||
const ( | ||
FlagPassword = "bls-password" | ||
) | ||
|
||
func CreateBlsKeyCmd() *cobra.Command { | ||
bech32PrefixAccAddr := appparams.Bech32PrefixAccAddr | ||
|
||
cmd := &cobra.Command{ | ||
Use: "create-bls-key [account-address]", | ||
Args: cobra.ExactArgs(1), | ||
Use: "create-bls-key", | ||
Short: "Create a pair of BLS keys for a validator", | ||
Long: strings.TrimSpace( | ||
fmt.Sprintf(`create-bls will create a pair of BLS keys that are used to | ||
Long: strings.TrimSpace(`create-bls will create a pair of BLS keys that are used to | ||
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 (via babylond init or babylond testnet). | ||
|
||
Example: | ||
$ babylond create-bls-key %s1f5tnl46mk4dfp4nx3n2vnrvyw2h2ydz6ykhk3r --home ./ | ||
$ babylond create-bls-key --home ./ | ||
`, | ||
bech32PrefixAccAddr, | ||
), | ||
), | ||
|
||
RunE: func(cmd *cobra.Command, args []string) error { | ||
homeDir, _ := cmd.Flags().GetString(flags.FlagHome) | ||
|
||
addr, err := sdk.AccAddressFromBech32(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var password string | ||
password, _ = cmd.Flags().GetString(FlagPassword) | ||
if password == "" { | ||
password = privval.NewBlsPassword() | ||
} | ||
return CreateBlsKey(homeDir, password, addr) | ||
password, _ := cmd.Flags().GetString(flagBlsPassword) | ||
createBlsKeyAndSave(homeDir, password) | ||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().String(flags.FlagHome, app.DefaultNodeHome, "The node home directory") | ||
cmd.Flags().String(FlagPassword, "", "The password for the BLS key. If a flag is set, the non-empty password should be provided. If a flag is not set, the password will be read from the prompt.") | ||
cmd.Flags().String(flagBlsPassword, "", "The password for the BLS key. If a flag is set, the non-empty password should be provided. If a flag is not set, the password will be read from the prompt.") | ||
return cmd | ||
} | ||
|
||
func CreateBlsKey(home, password string, addr sdk.AccAddress) error { | ||
privval.GenBlsPV( | ||
privval.DefaultBlsKeyFile(home), | ||
privval.DefaultBlsPasswordFile(home), | ||
password, | ||
addr.String(), | ||
) | ||
return nil | ||
// createBlsKeyAndSave creates a pair of BLS keys and saves them to files | ||
func createBlsKeyAndSave(homeDir, password string) { | ||
if password == "" { | ||
password = privval.NewBlsPassword() | ||
} | ||
privval.GenBlsPV(privval.DefaultBlsKeyFile(homeDir), privval.DefaultBlsPasswordFile(homeDir), password) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||
package cmd | ||||||
|
||||||
import ( | ||||||
"github.com/spf13/cobra" | ||||||
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags" | ||||||
"github.com/cosmos/cosmos-sdk/types/module" | ||||||
genutil "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" | ||||||
) | ||||||
|
||||||
func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { | ||||||
cosmosInitCmd := genutil.InitCmd(mbm, defaultNodeHome) | ||||||
cmd := &cobra.Command{ | ||||||
Use: cosmosInitCmd.Use, | ||||||
Short: cosmosInitCmd.Short, | ||||||
Long: cosmosInitCmd.Long, | ||||||
Args: cosmosInitCmd.Args, | ||||||
RunE: func(cmd *cobra.Command, args []string) error { | ||||||
if err := cosmosInitCmd.RunE(cmd, args); err != nil { | ||||||
return err | ||||||
} | ||||||
|
||||||
homeDir, _ := cmd.Flags().GetString(flags.FlagHome) | ||||||
password, _ := cmd.Flags().GetString(flagBlsPassword) | ||||||
createBlsKeyAndSave(homeDir, password) | ||||||
return nil | ||||||
}, | ||||||
} | ||||||
cmd.Flags().AddFlagSet(cosmosInitCmd.Flags()) | ||||||
cmd.Flags().String(flagBlsPassword, "", "The password for the BLS key. If a flag is set, the non-empty password should be provided. If a flag is not set, the password will be read from the prompt.") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed bbe2efd |
||||||
return cmd | ||||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think maybe we should extend
comsosInitCmd.Long
with BLS descriptionThere 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.
fixed bbe2efd