Compare commits

...

2 Commits

Author SHA1 Message Date
William Banfield
fada18b21a check against zero value for struct 2022-02-08 15:12:21 -05:00
William Banfield
77958a8834 types: add default values for the synchrony parameters 2022-02-08 14:26:21 -05:00
2 changed files with 15 additions and 5 deletions

View File

@@ -113,7 +113,10 @@ func (genDoc *GenesisDoc) ValidateAndComplete() error {
if genDoc.ConsensusParams == nil {
genDoc.ConsensusParams = DefaultConsensusParams()
} else if err := genDoc.ConsensusParams.ValidateConsensusParams(); err != nil {
}
genDoc.ConsensusParams.Complete()
if err := genDoc.ConsensusParams.ValidateConsensusParams(); err != nil {
return err
}

View File

@@ -128,11 +128,12 @@ func DefaultVersionParams() VersionParams {
}
func DefaultSynchronyParams() SynchronyParams {
// TODO(@wbanfield): Determine experimental values for these defaults
// https://github.com/tendermint/tendermint/issues/7202
return SynchronyParams{
Precision: 500 * time.Millisecond,
MessageDelay: 3 * time.Second,
// 505ms was selected as the default to enable chains that have validators in
// mixed leap-second handling environments.
// For more information, see: https://github.com/tendermint/tendermint/issues/7724
Precision: 505 * time.Millisecond,
MessageDelay: 12 * time.Second,
}
}
@@ -145,6 +146,12 @@ func (val *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool {
return false
}
func (params *ConsensusParams) Complete() {
if params.Synchrony == (SynchronyParams{}) {
params.Synchrony = DefaultSynchronyParams()
}
}
// Validate validates the ConsensusParams to ensure all values are within their
// allowed limits, and returns an error if they are not.
func (params ConsensusParams) ValidateConsensusParams() error {