Use proposer timestamp instead of genesis time for height 1 block time (#7541)

This commit is contained in:
Anca Zamfir
2022-01-27 10:33:17 -05:00
committed by William Banfield
parent 7fbad97e69
commit 71923c8442
9 changed files with 87 additions and 117 deletions
+2 -9
View File
@@ -8,6 +8,7 @@ import (
"time"
"github.com/gogo/protobuf/proto"
tmtime "github.com/tendermint/tendermint/libs/time"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
@@ -263,18 +264,10 @@ func (state State) MakeBlock(
// Build base block with block data.
block := types.MakeBlock(height, txs, commit, evidence)
// Set time.
var timestamp time.Time
if height == state.InitialHeight {
timestamp = state.LastBlockTime // genesis time
} else {
timestamp = time.Now()
}
// Fill rest of header with state data.
block.Header.Populate(
state.Version.Consensus, state.ChainID,
timestamp, state.LastBlockID,
tmtime.Now(), state.LastBlockID,
state.Validators.Hash(), state.NextValidators.Hash(),
state.ConsensusParams.HashConsensusParams(), state.AppHash, state.LastResultsHash,
proposerAddress,
+2 -2
View File
@@ -117,8 +117,8 @@ func validateBlock(state State, block *types.Block) error {
case block.Height == state.InitialHeight:
genesisTime := state.LastBlockTime
if !block.Time.Equal(genesisTime) {
return fmt.Errorf("block time %v is not equal to genesis time %v",
if block.Time.Before(genesisTime) {
return fmt.Errorf("block time %v is before genesis time %v",
block.Time,
genesisTime,
)