-
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
feat: remove delegator address in WrappedFilePV, change init cmd and add migration cmd #434
Conversation
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.
In general looks good to me! Let's wait approval from @KonradStaniec. Some comments:
cmd/babylond/cmd/init.go
Outdated
}, | ||
} | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
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.") | |
cmd.Flags().String(flagBlsPassword, "", "The password for the BLS key. If the 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 comment
The reason will be displayed to describe this comment to others. Learn more.
fixed bbe2efd
cmd/babylond/cmd/init.go
Outdated
cmd := &cobra.Command{ | ||
Use: cosmosInitCmd.Use, | ||
Short: cosmosInitCmd.Short, | ||
Long: cosmosInitCmd.Long, |
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 description
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.
fixed bbe2efd
cmd/babylond/cmd/migrate.go
Outdated
Long: strings.TrimSpace(`migrate splits the contents of the priv_validator_key.json file, | ||
which contained both the bls and comet keys used in previous versions, into separate files. | ||
|
||
BLS keys are stored along with other validator keys in priv_validator_key.json in previous version, | ||
which should exist before running the command (via babylond init or babylond testnet). | ||
|
||
NOTE: Before proceeding with the migration, ensure you back up the priv_validator_key.json file to a secure location. | ||
This will help prevent potential loss of critical validator information in case of issues during the migration process. | ||
|
||
Example: | ||
$ babylond migrate-bls-key --home ./ | ||
`, |
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.
Long: strings.TrimSpace(`migrate splits the contents of the priv_validator_key.json file, | |
which contained both the bls and comet keys used in previous versions, into separate files. | |
BLS keys are stored along with other validator keys in priv_validator_key.json in previous version, | |
which should exist before running the command (via babylond init or babylond testnet). | |
NOTE: Before proceeding with the migration, ensure you back up the priv_validator_key.json file to a secure location. | |
This will help prevent potential loss of critical validator information in case of issues during the migration process. | |
Example: | |
$ babylond migrate-bls-key --home ./ | |
`, | |
Long: strings.TrimSpace(`Migration splits the contents of the priv_validator_key.json file, | |
which contained both the bls and comet keys used in previous versions, into separate files. | |
BLS keys are stored along with the Ed25519 validator key in priv_validator_key.json in the previous version, | |
which should exist before running the command (via babylond init or babylond testnet). | |
NOTE: Before proceeding with the migration, ensure you back up the priv_validator_key.json file to a secure location. | |
This will help prevent potential loss of critical validator information in case of issues during the migration process. | |
Example: | |
$ babylond migrate-bls-key --home ./ | |
`, |
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.
fixed bbe2efd
cmd/babylond/cmd/migrate.go
Outdated
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.
migrate.go -> migrate_bls.go
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.
How about changing it to migrate_bls_key.go for consistency with create_bls_key.go?
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.
fixed bbe2efd
cmd/babylond/cmd/migrate.go
Outdated
filepath := cmtcfg.PrivValidatorKeyFile() | ||
|
||
if !cmtos.FileExists(filepath) { | ||
return fmt.Errorf("priv_validator_key.json of previous version not found") |
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.
return fmt.Errorf("priv_validator_key.json of previous version not found") | |
return fmt.Errorf("priv_validator_key.json of previous version not found in %s", filepath) |
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.
fixed bbe2efd
|
||
"github.com/babylonlabs-io/babylon/crypto/bls12381" | ||
checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
cmtcrypto "github.com/cometbft/cometbft/crypto" | ||
cmtprivval "github.com/cometbft/cometbft/privval" | ||
) | ||
|
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.
let's add var _ keeper.BlsSigner = &WrappedFilePV{}
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.
fixed bbe2efd
testutil/signer/private.go
Outdated
@@ -34,8 +35,12 @@ func SetupTestPrivSigner() (*signer.PrivSigner, error) { | |||
return privSigner, nil | |||
} | |||
|
|||
func GenesisKeyFromPrivSigner(ps *signer.PrivSigner) (*checkpointingtypes.GenesisKey, error) { | |||
valKeys, err := privval.NewValidatorKeys(ps.WrappedPV.GetValPrivKey(), ps.WrappedPV.GetBlsPrivKey()) | |||
// func GenesisKeyFromPrivSigner(ps *signer.PrivSigner, delegatorAddress sdk.ValAddress) (*checkpointingtypes.GenesisKey, error) { |
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.
leftover?
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.
fixed bbe2efd
x/checkpointing/keeper/bls_signer.go
Outdated
@@ -9,10 +9,10 @@ import ( | |||
) | |||
|
|||
type BlsSigner interface { | |||
GetAddress() sdk.ValAddress | |||
// GetAddress() sdk.ValAddress |
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.
leftover?
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.
fixed bbe2efd
_, _, err := curValSet.FindValidatorWithIndex(signer) | ||
|
||
valConsAddr := k.GetConAddressFromPubkey() | ||
val, err := k.GetValidatorByConsAddr(ctx, valConsAddr) |
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 wondered if we need this check at all, given that ExtendVote
is only called if the validator is in the validator set. Wdyt? @KonradStaniec
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 would leave it tbh it is not a big cost, and if something change on cometbft side (or they will be some bug) we will quickly catch it after upgrade
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.
@KonradStaniec
According to what you said, I think it would be a good idea to discuss this in the next PR.
x/checkpointing/vote_ext_test.go
Outdated
// WARN | ||
// This test code became untestable after deleting the DelegatorAddress field. | ||
// | ||
// // FuzzExtendVote_NotInValidatorSet tests the case where the | ||
// // private signer is not in the validator set | ||
// func FuzzExtendVote_NotInValidatorSet(f *testing.F) { | ||
// datagen.AddRandomSeedsToFuzzer(f, 10) | ||
|
||
// f.Fuzz(func(t *testing.T, seed int64) { | ||
// r := rand.New(rand.NewSource(seed)) | ||
// // generate the validator set with 10 validators as genesis | ||
// genesisValSet, ps, err := datagen.GenesisValidatorSetWithPrivSigner(10) | ||
// require.NoError(t, err) | ||
|
||
// // the private signer is not included in the validator set | ||
// helper := testhelper.NewHelperWithValSetNoSigner(t, genesisValSet, ps) | ||
|
||
// ek := helper.App.EpochingKeeper | ||
|
||
// epoch := ek.GetEpoch(helper.Ctx) | ||
// require.Equal(t, uint64(1), epoch.EpochNumber) | ||
|
||
// // go to block 10, reaching epoch boundary | ||
// interval := ek.GetParams(helper.Ctx).EpochInterval | ||
// for i := uint64(0); i < interval-2; i++ { | ||
// _, err := helper.ApplyEmptyBlockWithSomeInvalidVoteExtensions(r) | ||
// require.NoError(t, err) | ||
// } | ||
|
||
// req := &abci.RequestExtendVote{ | ||
// Hash: datagen.GenRandomByteArray(r, types.HashSize), | ||
// Height: 10, | ||
// } | ||
|
||
// // error is expected because the BLS signer in not | ||
// // in the validator set | ||
// _, err = helper.App.ExtendVote(helper.Ctx, req) | ||
// require.Error(t, err) | ||
// }) | ||
// } |
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.
Think we can remove it
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.
fixed bbe2efd
Totally agree with the suggestion! For bls signing, the comet pv is not needed. |
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.
apart from some leftover commented code, lgtm!
_, _, err := curValSet.FindValidatorWithIndex(signer) | ||
|
||
valConsAddr := k.GetConAddressFromPubkey() | ||
val, err := k.GetValidatorByConsAddr(ctx, valConsAddr) |
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 would leave it tbh it is not a big cost, and if something change on cometbft side (or they will be some bug) we will quickly catch it after upgrade
Commit Summary bbe2efd
|
This PR includes the following changes:
1. Remove delegator address in WrappedFilePV:
2. Addition of InitCmd:
3. BLS Key File Migration:
4. Fix for
e2e-run-upgrade-v1
Error:babylond start
checks the priv_validator_key.json file, and if it is in an older format, it is automatically migrated.And we suggest a new discussion about lightweight BlsSigner interface with remove FilePVKey from comet in WrappedFilePV.
x/checkpointing
module.