types: migrate params to protobuf (#4962)

This commit is contained in:
Marko
2020-06-05 15:29:53 +02:00
committed by GitHub
parent d4f1876d12
commit 9ef266b88f
28 changed files with 494 additions and 867 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/tendermint/tendermint/libs/fail"
"github.com/tendermint/tendermint/libs/log"
mempl "github.com/tendermint/tendermint/mempool"
tmproto "github.com/tendermint/tendermint/proto/types"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types"
)
@@ -365,7 +366,7 @@ func getBeginBlockValidatorInfo(block *types.Block, stateDB dbm.DB) (abci.LastCo
}
func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate,
params types.ValidatorParams) error {
params tmproto.ValidatorParams) error {
for _, valUpdate := range abciUpdates {
if valUpdate.GetPower() < 0 {
return fmt.Errorf("voting power can't be negative %v", valUpdate)
@@ -377,7 +378,7 @@ func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate,
// Check if validator's pubkey matches an ABCI type in the consensus params
thisKeyType := valUpdate.PubKey.Type
if !params.IsValidPubkeyType(thisKeyType) {
if !types.IsValidPubkeyType(params, thisKeyType) {
return fmt.Errorf("validator %v is using pubkey %s, which is unsupported for consensus",
valUpdate, thisKeyType)
}
@@ -417,8 +418,8 @@ func updateState(
lastHeightParamsChanged := state.LastHeightConsensusParamsChanged
if abciResponses.EndBlock.ConsensusParamUpdates != nil {
// NOTE: must not mutate s.ConsensusParams
nextParams = state.ConsensusParams.Update(abciResponses.EndBlock.ConsensusParamUpdates)
err := nextParams.Validate()
nextParams = types.UpdateConsensusParams(state.ConsensusParams, abciResponses.EndBlock.ConsensusParamUpdates)
err := types.ValidateConsensusParams(nextParams)
if err != nil {
return state, fmt.Errorf("error updating consensus params: %v", err)
}