mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-07 00:26:58 +00:00
proto: rename timing params to synchrony params (#7554)
This commit is contained in:
@@ -71,7 +71,7 @@ func TestBasicGenesisDoc(t *testing.T) {
|
||||
"app_hash":"",
|
||||
"app_state":{"account_owner": "Bob"},
|
||||
"consensus_params": {
|
||||
"timing": {"precision": "1", "message_delay": "10"},
|
||||
"synchrony": {"precision": "1", "message_delay": "10"},
|
||||
"validator": {"pub_key_types":["ed25519"]},
|
||||
"block": {"max_bytes": "100"},
|
||||
"evidence": {"max_age_num_blocks": "100", "max_age_duration": "10"}
|
||||
|
||||
+22
-22
@@ -41,7 +41,7 @@ type ConsensusParams struct {
|
||||
Evidence EvidenceParams `json:"evidence"`
|
||||
Validator ValidatorParams `json:"validator"`
|
||||
Version VersionParams `json:"version"`
|
||||
Timing TimingParams `json:"timing"`
|
||||
Synchrony SynchronyParams `json:"synchrony"`
|
||||
}
|
||||
|
||||
// HashedParams is a subset of ConsensusParams.
|
||||
@@ -76,9 +76,9 @@ type VersionParams struct {
|
||||
AppVersion uint64 `json:"app_version"`
|
||||
}
|
||||
|
||||
// TimingParams influence the validity of block timestamps.
|
||||
// SynchronyParams influence the validity of block timestamps.
|
||||
// TODO (@wbanfield): add link to proposer-based timestamp spec when completed.
|
||||
type TimingParams struct {
|
||||
type SynchronyParams struct {
|
||||
Precision time.Duration `json:"precision"`
|
||||
MessageDelay time.Duration `json:"message_delay"`
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func DefaultConsensusParams() *ConsensusParams {
|
||||
Evidence: DefaultEvidenceParams(),
|
||||
Validator: DefaultValidatorParams(),
|
||||
Version: DefaultVersionParams(),
|
||||
Timing: DefaultTimingParams(),
|
||||
Synchrony: DefaultSynchronyParams(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,10 +125,10 @@ func DefaultVersionParams() VersionParams {
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultTimingParams() TimingParams {
|
||||
func DefaultSynchronyParams() SynchronyParams {
|
||||
// TODO(@wbanfield): Determine experimental values for these defaults
|
||||
// https://github.com/tendermint/tendermint/issues/7202
|
||||
return TimingParams{
|
||||
return SynchronyParams{
|
||||
Precision: 10 * time.Millisecond,
|
||||
MessageDelay: 500 * time.Millisecond,
|
||||
}
|
||||
@@ -180,14 +180,14 @@ func (params ConsensusParams) ValidateConsensusParams() error {
|
||||
params.Evidence.MaxBytes)
|
||||
}
|
||||
|
||||
if params.Timing.MessageDelay <= 0 {
|
||||
return fmt.Errorf("timing.MessageDelay must be greater than 0. Got: %d",
|
||||
params.Timing.MessageDelay)
|
||||
if params.Synchrony.MessageDelay <= 0 {
|
||||
return fmt.Errorf("synchrony.MessageDelay must be greater than 0. Got: %d",
|
||||
params.Synchrony.MessageDelay)
|
||||
}
|
||||
|
||||
if params.Timing.Precision <= 0 {
|
||||
return fmt.Errorf("timing.Precision must be greater than 0. Got: %d",
|
||||
params.Timing.Precision)
|
||||
if params.Synchrony.Precision <= 0 {
|
||||
return fmt.Errorf("synchrony.Precision must be greater than 0. Got: %d",
|
||||
params.Synchrony.Precision)
|
||||
}
|
||||
|
||||
if len(params.Validator.PubKeyTypes) == 0 {
|
||||
@@ -234,7 +234,7 @@ func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool {
|
||||
return params.Block == params2.Block &&
|
||||
params.Evidence == params2.Evidence &&
|
||||
params.Version == params2.Version &&
|
||||
params.Timing == params2.Timing &&
|
||||
params.Synchrony == params2.Synchrony &&
|
||||
tmstrings.StringSliceEqual(params.Validator.PubKeyTypes, params2.Validator.PubKeyTypes)
|
||||
}
|
||||
|
||||
@@ -265,9 +265,9 @@ func (params ConsensusParams) UpdateConsensusParams(params2 *tmproto.ConsensusPa
|
||||
if params2.Version != nil {
|
||||
res.Version.AppVersion = params2.Version.AppVersion
|
||||
}
|
||||
if params2.Timing != nil {
|
||||
res.Timing.Precision = params2.Timing.Precision
|
||||
res.Timing.MessageDelay = params2.Timing.MessageDelay
|
||||
if params2.Synchrony != nil {
|
||||
res.Synchrony.Precision = params2.Synchrony.Precision
|
||||
res.Synchrony.MessageDelay = params2.Synchrony.MessageDelay
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -289,9 +289,9 @@ func (params *ConsensusParams) ToProto() tmproto.ConsensusParams {
|
||||
Version: &tmproto.VersionParams{
|
||||
AppVersion: params.Version.AppVersion,
|
||||
},
|
||||
Timing: &tmproto.TimingParams{
|
||||
MessageDelay: params.Timing.MessageDelay,
|
||||
Precision: params.Timing.Precision,
|
||||
Synchrony: &tmproto.SynchronyParams{
|
||||
MessageDelay: params.Synchrony.MessageDelay,
|
||||
Precision: params.Synchrony.Precision,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -313,9 +313,9 @@ func ConsensusParamsFromProto(pbParams tmproto.ConsensusParams) ConsensusParams
|
||||
Version: VersionParams{
|
||||
AppVersion: pbParams.Version.AppVersion,
|
||||
},
|
||||
Timing: TimingParams{
|
||||
MessageDelay: pbParams.Timing.MessageDelay,
|
||||
Precision: pbParams.Timing.Precision,
|
||||
Synchrony: SynchronyParams{
|
||||
MessageDelay: pbParams.Synchrony.MessageDelay,
|
||||
Precision: pbParams.Synchrony.Precision,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ func makeParams(args makeParamsArgs) ConsensusParams {
|
||||
Validator: ValidatorParams{
|
||||
PubKeyTypes: args.pubkeyTypes,
|
||||
},
|
||||
Timing: TimingParams{
|
||||
Synchrony: SynchronyParams{
|
||||
Precision: args.precision,
|
||||
MessageDelay: args.messageDelay,
|
||||
},
|
||||
@@ -242,10 +242,10 @@ func TestConsensusParamsUpdate(t *testing.T) {
|
||||
updatedParams: makeParams(makeParamsArgs{blockBytes: 1, blockGas: 2, evidenceAge: 3}),
|
||||
},
|
||||
{
|
||||
// update timing params
|
||||
// update synchrony params
|
||||
intialParams: makeParams(makeParamsArgs{evidenceAge: 3, precision: time.Second, messageDelay: 3 * time.Second}),
|
||||
updates: &tmproto.ConsensusParams{
|
||||
Timing: &tmproto.TimingParams{
|
||||
Synchrony: &tmproto.SynchronyParams{
|
||||
Precision: time.Second * 2,
|
||||
MessageDelay: time.Second * 4,
|
||||
},
|
||||
|
||||
+3
-3
@@ -91,11 +91,11 @@ func (p *Proposal) ValidateBasic() error {
|
||||
// the timestamp in this case is set to the preconfigured genesis time.
|
||||
// For more information on the meaning of 'timely', see the proposer-based timestamp specification:
|
||||
// https://github.com/tendermint/spec/tree/master/spec/consensus/proposer-based-timestamp
|
||||
func (p *Proposal) IsTimely(recvTime time.Time, tp TimingParams, initialHeight int64) bool {
|
||||
func (p *Proposal) IsTimely(recvTime time.Time, sp SynchronyParams, initialHeight int64) bool {
|
||||
// lhs is `proposedBlockTime - Precision` in the first inequality
|
||||
lhs := p.Timestamp.Add(-tp.Precision)
|
||||
lhs := p.Timestamp.Add(-sp.Precision)
|
||||
// rhs is `proposedBlockTime + MsgDelay + Precision` in the second inequality
|
||||
rhs := p.Timestamp.Add(tp.MessageDelay).Add(tp.Precision)
|
||||
rhs := p.Timestamp.Add(sp.MessageDelay).Add(sp.Precision)
|
||||
|
||||
if recvTime.Before(lhs) || (p.Height != initialHeight && recvTime.After(rhs)) {
|
||||
return false
|
||||
|
||||
@@ -297,12 +297,12 @@ func TestIsTimely(t *testing.T) {
|
||||
Timestamp: testCase.proposalTime,
|
||||
}
|
||||
|
||||
tp := TimingParams{
|
||||
sp := SynchronyParams{
|
||||
Precision: testCase.precision,
|
||||
MessageDelay: testCase.msgDelay,
|
||||
}
|
||||
|
||||
ti := p.IsTimely(testCase.recvTime, tp, testCase.genesisHeight)
|
||||
ti := p.IsTimely(testCase.recvTime, sp, testCase.genesisHeight)
|
||||
assert.Equal(t, testCase.expectTimely, ti)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user