Browse Source

complete

wb/issue-8156
William Banfield 2 years ago
parent
commit
34f05fd6c4
No known key found for this signature in database GPG Key ID: EFAD3442BF29E3AC
3 changed files with 55 additions and 17 deletions
  1. +12
    -17
      internal/consensus/state.go
  2. +3
    -0
      internal/rpc/core/consensus.go
  3. +40
    -0
      types/params.go

+ 12
- 17
internal/consensus/state.go View File

@ -1452,11 +1452,7 @@ func (cs *State) enterPrevote(ctx context.Context, height int64, round int32) {
}
func (cs *State) proposalIsTimely() bool {
sp := types.SynchronyParams{
Precision: cs.state.ConsensusParams.Synchrony.Precision,
MessageDelay: cs.state.ConsensusParams.Synchrony.MessageDelay,
}
sp := cs.state.ConsensusParams.Synchrony.SynchronyParamsOrDefaults()
return cs.Proposal.IsTimely(cs.ProposalReceiveTime, sp, cs.Round)
}
@ -1482,6 +1478,7 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32
return
}
sp := cs.state.ConsensusParams.Synchrony.SynchronyParamsOrDefaults()
if cs.Proposal.POLRound == -1 && cs.LockedRound == -1 && !cs.proposalIsTimely() {
logger.Debug("prevote step: Proposal is not timely; prevoting nil",
"proposed",
@ -1489,9 +1486,9 @@ func (cs *State) defaultDoPrevote(ctx context.Context, height int64, round int32
"received",
tmtime.Canonical(cs.ProposalReceiveTime).Format(time.RFC3339Nano),
"msg_delay",
cs.state.ConsensusParams.Synchrony.MessageDelay,
sp.MessageDelay,
"precision",
cs.state.ConsensusParams.Synchrony.Precision)
sp.Precision)
cs.signAddVote(ctx, tmproto.PrevoteType, nil, types.PartSetHeader{})
return
}
@ -2667,11 +2664,12 @@ func repairWalFile(src, dst string) error {
}
func (cs *State) proposeTimeout(round int32) time.Duration {
p := cs.state.ConsensusParams.Timeout.Propose
tp := cs.state.ConsensusParams.Timeout.TimeoutParamsOrDefaults()
p := tp.Propose
if cs.config.UnsafeProposeTimeoutOverride != 0 {
p = cs.config.UnsafeProposeTimeoutOverride
}
pd := cs.state.ConsensusParams.Timeout.ProposeDelta
pd := tp.ProposeDelta
if cs.config.UnsafeProposeTimeoutDeltaOverride != 0 {
pd = cs.config.UnsafeProposeTimeoutDeltaOverride
}
@ -2681,11 +2679,12 @@ func (cs *State) proposeTimeout(round int32) time.Duration {
}
func (cs *State) voteTimeout(round int32) time.Duration {
v := cs.state.ConsensusParams.Timeout.Vote
tp := cs.state.ConsensusParams.Timeout.TimeoutParamsOrDefaults()
v := tp.Vote
if cs.config.UnsafeVoteTimeoutOverride != 0 {
v = cs.config.UnsafeVoteTimeoutOverride
}
vd := cs.state.ConsensusParams.Timeout.VoteDelta
vd := tp.VoteDelta
if cs.config.UnsafeVoteTimeoutDeltaOverride != 0 {
vd = cs.config.UnsafeVoteTimeoutDeltaOverride
}
@ -2711,12 +2710,8 @@ func (cs *State) bypassCommitTimeout() bool {
func (cs *State) calculateProposalTimestampDifferenceMetric() {
if cs.Proposal != nil && cs.Proposal.POLRound == -1 {
tp := types.SynchronyParams{
Precision: cs.state.ConsensusParams.Synchrony.Precision,
MessageDelay: cs.state.ConsensusParams.Synchrony.MessageDelay,
}
isTimely := cs.Proposal.IsTimely(cs.ProposalReceiveTime, tp, cs.Round)
sp := cs.state.ConsensusParams.Synchrony.SynchronyParamsOrDefaults()
isTimely := cs.Proposal.IsTimely(cs.ProposalReceiveTime, sp, cs.Round)
cs.metrics.ProposalTimestampDifference.With("is_timely", fmt.Sprintf("%t", isTimely)).
Observe(cs.ProposalReceiveTime.Sub(cs.Proposal.Timestamp).Seconds())
}


+ 3
- 0
internal/rpc/core/consensus.go View File

@ -113,6 +113,9 @@ func (env *Environment) ConsensusParams(ctx context.Context, heightPtr *int64) (
return nil, err
}
consensusParams.Synchrony = consensusParams.Synchrony.SynchronyParamsOrDefaults()
consensusParams.Timeout = consensusParams.Timeout.TimeoutParamsOrDefaults()
return &coretypes.ResultConsensusParams{
BlockHeight: height,
ConsensusParams: consensusParams}, nil


+ 40
- 0
types/params.go View File

@ -147,7 +147,22 @@ func DefaultSynchronyParams() SynchronyParams {
Precision: 505 * time.Millisecond,
MessageDelay: 12 * time.Second,
}
}
// SynchronyParamsOrDefaults returns the SynchronyParams, filling in any zero values
// with the Tendermint defined default values.
func (s SynchronyParams) SynchronyParamsOrDefaults() SynchronyParams {
// TODO: Remove this method and all uses once development on v0.37 begins.
// See: https://github.com/tendermint/tendermint/issues/8187
defaults := DefaultSynchronyParams()
if s.Precision == 0 {
s.Precision = defaults.Precision
}
if s.MessageDelay == 0 {
s.MessageDelay = defaults.MessageDelay
}
return s
}
func DefaultTimeoutParams() TimeoutParams {
@ -161,6 +176,31 @@ func DefaultTimeoutParams() TimeoutParams {
}
}
// TimeoutParamsOrDefaults returns the SynchronyParams, filling in any zero values
// with the Tendermint defined default values.
func (t TimeoutParams) TimeoutParamsOrDefaults() TimeoutParams {
// TODO: Remove this method and all uses once development on v0.37 begins.
// See: https://github.com/tendermint/tendermint/issues/8187
defaults := DefaultTimeoutParams()
if t.Propose == 0 {
t.Propose = defaults.Propose
}
if t.ProposeDelta == 0 {
t.ProposeDelta = defaults.ProposeDelta
}
if t.Vote == 0 {
t.Vote = defaults.Vote
}
if t.VoteDelta == 0 {
t.VoteDelta = defaults.VoteDelta
}
if t.Commit == 0 {
t.Commit = defaults.Commit
}
return t
}
// ProposeTimeout returns the amount of time to wait for a proposal.
func (t TimeoutParams) ProposeTimeout(round int32) time.Duration {
return time.Duration(


Loading…
Cancel
Save