types: add default values for the synchrony parameters

This commit is contained in:
William Banfield
2022-02-08 14:26:21 -05:00
parent 218a4d18d5
commit 95a60bd06c
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.MessageDelay == 0 && params.Synchrony.Precision == 0 {
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 {