-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use any as validator pubkey #7597
Conversation
f23fb0c
to
324f31a
Compare
Codecov Report
@@ Coverage Diff @@
## master #7597 +/- ##
==========================================
- Coverage 54.21% 54.15% -0.06%
==========================================
Files 611 611
Lines 38464 38556 +92
==========================================
+ Hits 20852 20881 +29
- Misses 15503 15543 +40
- Partials 2109 2132 +23 |
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.
Some tests are still failing, one in particular (TestRandomizedGenState
in x/staking/simulation/genesis_test.go
) is because you need to implement UnpackInterfaces
on staking GenesisState
(since it has a list of validators in it with Any
values).
Also, it seems like there's an issue in func (v Validator) MinEqual(other Validator) bool
in x/staking/types/validator.go
, when comparing the ConsensusPubkey
s, I'd say you need to GetCachedValue()
on the ConsensusPubkey
s first and then use Equals
function from cryptotypes.PubKey
to compare them.
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.
Didn't go through everything yet, here are some first comments
Use gRPC in GetCmdQueryValidators
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.
Few small stylistic things, and one question about an error handling. Pre-approving as I don't consider any of them blockers.
Massive lift @robert-zaremba! Thanks for pushing this through 🎉
And big kudos to team effort from @amaurymartiny & @blushi for helping with test debugging throughout :)
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.
Overall lgtm 👍, small nits only
(I also changed the title to something more explicit)
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
@@ -410,7 +410,9 @@ func TestTallyJailedValidator(t *testing.T) { | |||
|
|||
_ = staking.EndBlocker(ctx, app.StakingKeeper) | |||
|
|||
app.StakingKeeper.Jail(ctx, sdk.ConsAddress(val2.GetConsPubKey().Address())) | |||
consKey, err := val2.TmConsPubKey() |
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.
why does this need to be a tendermint key? It seems this PR intertwined Tendermint keys even deeper into the sdk..
@@ -12,7 +12,11 @@ import ( | |||
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, stakingKeeper types.StakingKeeper, data *types.GenesisState) { | |||
stakingKeeper.IterateValidators(ctx, | |||
func(index int64, validator stakingtypes.ValidatorI) bool { | |||
keeper.AddPubkey(ctx, validator.GetConsPubKey()) | |||
consPk, err := validator.TmConsPubKey() |
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.
this doesnt need to be a tendermint key. I believe the only places that need to be tendermint keys is where it is going to Tendermint. Within the sdk you can use sdk's keys
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.
Why? this is a consensus key, and it's coming from Tendermint. I'm not very familiar with the tendermint side. I assume that when we get a tendermint key then we should use it consistently as a tendermint key except when we serialize it in SDK objects.
@marbar3778 could you confirm?
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.
Tendermint doesn't care how its handled. The reason you would want to handle it with your own key is to disentangle Tendermint from the inner workings of the sdk. You can use tendermint ed25519 keys here but then what is the point of having your own?
Will this PR be backported to stargate?
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.
To be able to serialize it in SDK structures / messages.
* protobuf pubkey type update * wip2 * wip3 * solving types.NewValidator issues * remove bech32 from validator type assignment * update Validator interface * Changelog update * wip4 * update genutil * fix simapp & x/ibc/testing tests * update staking * changelog update * fix import cycle in tests * fix amino panic on TestValidatorMarshalUnmarshalJSON * fix TestValidatorMarshalUnmarshalJSON consensus_pubkey check * Add UnpackInterfaces to HistoricalInfo * fix TestHistoricalInfo * update todos * fix: Expecting ed25519.PubKey to implement proto.Message * fix linter issues * Fix migrate test * Update CHANGELOG.md Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * review comments * cosmetic changes * add UnpackInterfaces got GenesisRandomized test * Validator.Equal reuses Validator.MinEqual * fix test * use Validator.Equal in tests * Fix staking simulation TestRandomizedGenState * Remove TODO * use HistoricalInfo.Equal * use proto.Equal * rename Validator.GetConsPubKey to TmConsPubKey * prefer require.Equal over reflect.DeepEqual * SetHistoricalInfo using a pointer * Fix TestQueryDelegation test * Fix TestQueryValidators test * Fix TestSimulateMsgUnjail test * experiement with LegacyAmino instances * Register codecs in all simapp tests * Fix cli_test compilation problems * fix typo sdk -> std * fix typo * fix TestPlanStringer * Rename to MakeEncodingConfig * Remove RegisterCodecsTests * Use gRPC in GetCmdQueryValidators * Empty status * fix info log check * linter fixes * rename simapparams to simappparams * Update simapp/test_helpers.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * comments updates * use valAddr1 instead of sdk.ValAddress(pk1.Address().Bytes()) Co-authored-by: Cory Levinson <cjlevinson@gmail.com> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
* protobuf pubkey type update * wip2 * wip3 * solving types.NewValidator issues * remove bech32 from validator type assignment * update Validator interface * Changelog update * wip4 * update genutil * fix simapp & x/ibc/testing tests * update staking * changelog update * fix import cycle in tests * fix amino panic on TestValidatorMarshalUnmarshalJSON * fix TestValidatorMarshalUnmarshalJSON consensus_pubkey check * Add UnpackInterfaces to HistoricalInfo * fix TestHistoricalInfo * update todos * fix: Expecting ed25519.PubKey to implement proto.Message * fix linter issues * Fix migrate test * Update CHANGELOG.md Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * review comments * cosmetic changes * add UnpackInterfaces got GenesisRandomized test * Validator.Equal reuses Validator.MinEqual * fix test * use Validator.Equal in tests * Fix staking simulation TestRandomizedGenState * Remove TODO * use HistoricalInfo.Equal * use proto.Equal * rename Validator.GetConsPubKey to TmConsPubKey * prefer require.Equal over reflect.DeepEqual * SetHistoricalInfo using a pointer * Fix TestQueryDelegation test * Fix TestQueryValidators test * Fix TestSimulateMsgUnjail test * experiement with LegacyAmino instances * Register codecs in all simapp tests * Fix cli_test compilation problems * fix typo sdk -> std * fix typo * fix TestPlanStringer * Rename to MakeEncodingConfig * Remove RegisterCodecsTests * Use gRPC in GetCmdQueryValidators * Empty status * fix info log check * linter fixes * rename simapparams to simappparams * Update simapp/test_helpers.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * comments updates * use valAddr1 instead of sdk.ValAddress(pk1.Address().Bytes()) Co-authored-by: Cory Levinson <cjlevinson@gmail.com> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Description
Validator ConsensusPubKey type migration from string (bech32) to Any
closes: #7447 (partially)
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes