Don't check lhs for genesis block

This commit is contained in:
Anca Zamfir
2021-12-20 00:36:23 +01:00
parent ba42727a9b
commit ea3398bde8
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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
View File
@@ -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