mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
Use proposer timestamp instead of genesis time for height 1 block time (#7541)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user