Add ValidatorPubkeyTypes as a consensus param#2636
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2636 +/- ##
===========================================
- Coverage 61.72% 61.54% -0.19%
===========================================
Files 207 207
Lines 16942 16939 -3
===========================================
- Hits 10458 10425 -33
- Misses 5622 5649 +27
- Partials 862 865 +3
|
|
Should |
types/params.go
Outdated
| } | ||
|
|
||
| if len(params.ValidatorPubkeyTypes) == 0 { | ||
| return cmn.NewError("len(ValidatorPubkeyTypes) must be greater than 0.") |
ebuchman
left a comment
There was a problem hiding this comment.
So this is just to add it to the ConsensusParams. Enforcement will come in a second PR? Or do you want to add that here.
types/params.go
Outdated
| type ConsensusParams struct { | ||
| BlockSize `json:"block_size_params"` | ||
| EvidenceParams `json:"evidence_params"` | ||
| BlockSize `json:"block_size_params"` |
There was a problem hiding this comment.
Thinking about this, we can probably drop the Params and _params suffixes from these fields.
Also I wonder if the ConsensusParams is a good place for Version to live? Then we don't need to add anything to EndBlock for the app to update the versions, its just part of the ConsensusParams.
As for this PR, maybe we should have a new struct to hold the pubkey types? Could be called Signatures or Cryptography or Validators or something ?
There was a problem hiding this comment.
This makes a lot of sense for app version imo.
Re new struct, sure I think Validators makes sense! I do think having the params suffix is nice for disambiguation when your looking at types.
There was a problem hiding this comment.
Cool. Let's go with Validators.
Yeh, Params makes sense for the types, but it's redundant for the field names. I guess here it's all embedded structs, but maybe it shouldn't be, and then we can have proper field names and struct type name distinctions.
types/params.go
Outdated
| } | ||
|
|
||
| // DefaultValidatorPubkeyTypes Params returns a default set of pubkey types to | ||
| // be accepted for validators. |
There was a problem hiding this comment.
Comment should tell us what the default is
types/params.go
Outdated
| if params2.EvidenceParams != nil { | ||
| res.EvidenceParams.MaxAge = params2.EvidenceParams.MaxAge | ||
| } | ||
| if params2.ValidatorPubkeyTypes != nil { |
There was a problem hiding this comment.
Works for structs but not sure if we might just end up with a non-nil empty list here?
|
My plan was to add enforcement in a second PR. (Primarily because I was unsure what function should be aware of the consensus params when getting the validator set updates) |
|
Is this good to merge? I'd like to get it in soon before we make another .proto change and I have to fix the merge conflict |
ebuchman
left a comment
There was a problem hiding this comment.
I'm not sure if we want to use the Amino routes here. Technically ABCI knows nothing about amino routes, and the pubkey types just have two string types now, "ed25519" and "secp256k1". We should be consistent here - either we add the amino routes to the base pubkey types, or we use the simple names in the validator pubkey types...
Otherwise, this looks great. Thanks Dev.
types/params.go
Outdated
| params.EvidenceParams.MaxAge) | ||
| } | ||
|
|
||
| if len(params.Validator.ValidatorPubkeyTypes) == 0 { |
There was a problem hiding this comment.
Should we also validate that the types given are known?
types/params.go
Outdated
| } | ||
|
|
||
| func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool { | ||
| if params.BlockSize == params2.BlockSize && |
There was a problem hiding this comment.
We can just return this conjunction instead of using the conditional
I'll change it here, but I don't really get why ABCI wouldn't just use the amino routes / why we don't make the amino routes match whats used in ABCI. (I actually think the amino routes should be whats currently used in ABCI. The |
96b7d2c to
241bf3d
Compare
|
The redundant field names components (#2698) were driving me nuts so I fixed it :P |
| ABCIPubKeyTypeSecp256k1 = "secp256k1" | ||
| ) | ||
|
|
||
| // TODO: Make non-global by allowing for registration of more pubkey types |
There was a problem hiding this comment.
is there an associated issue?
| stringSliceEqual(params.Validator.PubKeyTypes, params2.Validator.PubKeyTypes) | ||
| } | ||
|
|
||
| func stringSliceEqual(a, b []string) bool { |
| res.Evidence.MaxAge = params2.Evidence.MaxAge | ||
| } | ||
| if params2.Validator != nil { | ||
| res.Validator.PubKeyTypes = params2.Validator.PubKeyTypes |
There was a problem hiding this comment.
Should we copy here?
Also I wonder if it makes sense to use Amino naming in the types#ConsensusParams but ABCI naming in the abci#ConsensusParams. Is that crazy? Or maybe we put an empty PubKey of the respective type in the types#ConsensusParams instead of strings.
There was a problem hiding this comment.
Good idea, it probably is best to copy.
* Enforce validators can only use the correct pubkey type * adapt to variable renames * Address comments from #2636 * separate updating and validation logic * update spec * Add test case for TestStringSliceEqual, clarify slice copying code * Address @ebuchman's comments * Split up testing validator update execution, and its validation
Ref #2414