From 3401eb241002e7e98426573da030dd20251cfdfc Mon Sep 17 00:00:00 2001 From: William Banfield <4561443+williambanfield@users.noreply.github.com> Date: Sat, 19 Feb 2022 14:53:18 -0500 Subject: [PATCH] types: add default values for the synchrony parameters (#7788) ## Summary This pull request adds a default set of values to the new Synchrony parameters. These values were chosen by after observation of three live networks: Emoney, Osmosis, and the Cosmos Hub. For the default Precision value, `505ms` was selected. The reasoning for this is summarized in https://github.com/tendermint/tendermint/issues/7724 For each observed chain, an experimental Message Delay was collected over a 24 hour period and an average over this period was calculated using this data. Values over 10s were considered outliers and treated separately for the average since the majority of observations were far below 10s. The message delay was calculated both for the quorum and the 'full' prevote. Description of the technique for collecting the experimental values can found in #7202. This value is calculated only using timestamps given by processes on the network, so large variation in values is almost certainly due to clock skew among the validator set. `12s` is proposed for the default MessageDelay value. This value would easily accomodates all non-outlier values, allowing even E-money's 4.25s value to be valid. This would also allow some validators with skewed clocks to still participate without allowing for huge variation in the timestamps produced by the network. Additionally, for the currently listed use-cases of PBTS, such as unbonding period, and light client trust period, the current bounds for these are in weeks. Adding a few seconds of tolerance by default is therefore unlikely to have serious side-effects. ## Data ### Cosmos Hub Observation Period: 2022-02-03 20:22-2022-02-04 20:22 Avg Full Prevote Message Delay: 1.27s Outliers: 11s,13s,50s,106s,144s Total Outlier Heights: 86 Avg Quorum Prevote Message Delay: .77s Outliers: 10s,14s,107s,144s Total Outlier Heights: 617 Total heights: 11528 ### Osmosis Observation Period: 2022-01-29 20:26-2022-01-28 20:26 Avg Quorum Prevote Message Delay: .46s Outliers: 21s,50s Total Outlier Heights: 26 NOTE: During the observation period, a 'full' prevote was not observed. Total heights: 13983 ### E-Money Observation Period: 2022-02-07 04:29-2022-02-08 04:29 Avg Full Prevote Message Delay: 4.25s Outliers: 12s,15s,39s Total Outlier Heights: 128 Avg Quorum Prevote Message Delay: .20s Outliers: 28s Total Outlier Heights: 15 Total heights: 3791 --- types/genesis.go | 5 ++++- types/params.go | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/types/genesis.go b/types/genesis.go index f711a7090..26c522638 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -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 } diff --git a/types/params.go b/types/params.go index 017ac5d15..fc9c4aaad 100644 --- a/types/params.go +++ b/types/params.go @@ -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 {