mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 02:31:46 +00:00
state: require block.Time of the fist block to be genesis time (#2594)
* require block.Time of the fist block to be genesis time Refs #2587: ``` We only start validating block.Time when Height > 1, because there is no commit to compute the median timestamp from for the first block. This means a faulty proposer could make the first block with whatever time they want. Instead, we should require the timestamp of block 1 to match the genesis time. I discovered this while refactoring the ValidateBlock tests to be table-driven while working on tests for #2560. ``` * do not accept blocks with negative height * update changelog and spec * nanos precision for test genesis time * Fix failing test (#2607)
This commit is contained in:
committed by
Ethan Buchman
parent
3744e8271d
commit
e1538bf67e
@ -60,6 +60,7 @@ func TestBlockValidateBasic(t *testing.T) {
|
||||
}{
|
||||
{"Make Block", func(blk *Block) {}, false},
|
||||
{"Make Block w/ proposer Addr", func(blk *Block) { blk.ProposerAddress = valSet.GetProposer().Address }, false},
|
||||
{"Negative Height", func(blk *Block) { blk.Height = -1 }, true},
|
||||
{"Increase NumTxs", func(blk *Block) { blk.NumTxs++ }, true},
|
||||
{"Remove 1/2 the commits", func(blk *Block) {
|
||||
blk.LastCommit.Precommits = commit.Precommits[:commit.Size()/2]
|
||||
@ -81,7 +82,7 @@ func TestBlockValidateBasic(t *testing.T) {
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
block := MakeBlock(h, txs, commit, evList)
|
||||
tc.malleateBlock(block)
|
||||
assert.Equal(t, tc.expErr, block.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
assert.Equal(t, tc.expErr, block.ValidateBasic() != nil, "ValidateBasic had an unexpected result")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user