mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-20 06:06:15 +00:00
Prevote nil if not timely
This commit is contained in:
+2
-2
@@ -570,8 +570,8 @@ var testGenesisFmt = `{
|
||||
"time_iota_ms": "10"
|
||||
},
|
||||
"timing": {
|
||||
"message_delay": "200",
|
||||
"precision": "50"
|
||||
"message_delay": "500000000",
|
||||
"precision": "10000000"
|
||||
},
|
||||
"evidence": {
|
||||
"max_age_num_blocks": "100000",
|
||||
|
||||
@@ -41,7 +41,7 @@ const (
|
||||
testSubscriber = "test-client"
|
||||
|
||||
// genesis, chain_id, priv_val
|
||||
ensureTimeout = time.Millisecond * 200
|
||||
ensureTimeout = time.Second
|
||||
)
|
||||
|
||||
// A cleanupFunc cleans up any config / test files created for a particular
|
||||
|
||||
@@ -407,7 +407,7 @@ func TestProposerWaitsForGenesisTime(t *testing.T) {
|
||||
cfg := pbtsTestConfiguration{
|
||||
timingParams: types.TimingParams{
|
||||
Precision: 10 * time.Millisecond,
|
||||
MessageDelay: 10 * time.Millisecond,
|
||||
MessageDelay: 100 * time.Millisecond,
|
||||
},
|
||||
timeoutPropose: 10 * time.Millisecond,
|
||||
genesisTime: initialTime,
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
var (
|
||||
ErrInvalidProposalSignature = errors.New("error invalid proposal signature")
|
||||
ErrInvalidProposalPOLRound = errors.New("error invalid proposal POL round")
|
||||
ErrInvalidProposalNotTimely = errors.New("error invalid proposal un-timely block timestamp ")
|
||||
ErrAddingVote = errors.New("error adding vote")
|
||||
ErrSignatureFoundInPastBlocks = errors.New("found signature from the same key")
|
||||
|
||||
@@ -1886,6 +1887,15 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error {
|
||||
return ErrInvalidProposalPOLRound
|
||||
}
|
||||
|
||||
// Verify timely
|
||||
tp := types.TimingParams{
|
||||
Precision: cs.state.ConsensusParams.Timing.Precision,
|
||||
MessageDelay: cs.state.ConsensusParams.Timing.MessageDelay,
|
||||
}
|
||||
if proposal.POLRound == -1 && !proposal.IsTimely(tmtime.DefaultSource{}, tp) {
|
||||
return ErrInvalidProposalNotTimely
|
||||
}
|
||||
|
||||
p := proposal.ToProto()
|
||||
// Verify signature
|
||||
if !cs.Validators.GetProposer().PubKey.VerifySignature(
|
||||
|
||||
+2
-2
@@ -129,8 +129,8 @@ func DefaultTimingParams() TimingParams {
|
||||
// TODO(@wbanfield): Determine experimental values for these defaults
|
||||
// https://github.com/tendermint/tendermint/issues/7202
|
||||
return TimingParams{
|
||||
Precision: 1 * time.Nanosecond,
|
||||
MessageDelay: 1 * time.Nanosecond,
|
||||
Precision: 10 * time.Millisecond,
|
||||
MessageDelay: 500 * time.Millisecond,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -90,8 +90,8 @@ func (p *Proposal) ValidateBasic() error {
|
||||
// https://github.com/tendermint/spec/tree/master/spec/consensus/proposer-based-timestamp
|
||||
func (p *Proposal) IsTimely(clock tmtime.Source, tp TimingParams) bool {
|
||||
lt := clock.Now()
|
||||
lhs := lt.Add(-tp.Precision)
|
||||
rhs := lt.Add(tp.Precision).Add(tp.MessageDelay)
|
||||
lhs := lt.Add(-tp.Precision).Add(-tp.MessageDelay)
|
||||
rhs := lt.Add(tp.Precision)
|
||||
if lhs.Before(p.Timestamp) && rhs.After(p.Timestamp) {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user