mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-20 06:06:15 +00:00
Don't check lhs for genesis block
This commit is contained in:
@@ -1902,7 +1902,7 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error {
|
||||
Precision: cs.state.ConsensusParams.Timing.Precision,
|
||||
MessageDelay: cs.state.ConsensusParams.Timing.MessageDelay,
|
||||
}
|
||||
if proposal.POLRound == -1 && !proposal.IsTimely(tmtime.DefaultSource{}, tp) {
|
||||
if proposal.POLRound == -1 && !proposal.IsTimely(tmtime.DefaultSource{}, tp, cs.state.InitialHeight) {
|
||||
return ErrInvalidProposalNotTimely
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -88,11 +88,11 @@ func (p *Proposal) ValidateBasic() error {
|
||||
//
|
||||
// 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(clock tmtime.Source, tp TimingParams) bool {
|
||||
func (p *Proposal) IsTimely(clock tmtime.Source, tp TimingParams, genesisHeight int64) bool {
|
||||
lt := clock.Now()
|
||||
lhs := lt.Add(-tp.Precision).Add(-tp.MessageDelay)
|
||||
rhs := lt.Add(tp.Precision)
|
||||
if lhs.Before(p.Timestamp) && rhs.After(p.Timestamp) {
|
||||
if (p.Height == genesisHeight || lhs.Before(p.Timestamp)) && rhs.After(p.Timestamp) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user