45
45
errTooManyUncles = errors .New ("too many uncles" )
46
46
errInvalidNonce = errors .New ("invalid nonce" )
47
47
errInvalidUncleHash = errors .New ("invalid uncle hash" )
48
+ errInvalidTimestamp = errors .New ("invalid timestamp" )
48
49
)
49
50
50
51
// Beacon is a consensus engine that combines the eth1 consensus and proof-of-stake
@@ -213,7 +214,7 @@ func (beacon *Beacon) VerifyUncles(chain consensus.ChainReader, block *types.Blo
213
214
// - nonce is expected to be 0
214
215
// - unclehash is expected to be Hash(emptyHeader)
215
216
// to be the desired constants
216
- // (b) the timestamp is not verified anymore
217
+ // (b) we don't verify if a block is in the future anymore
217
218
// (c) the extradata is limited to 32 bytes
218
219
func (beacon * Beacon ) verifyHeader (chain consensus.ChainHeaderReader , header , parent * types.Header ) error {
219
220
// Ensure that the header's extra-data section is of a reasonable size
@@ -227,6 +228,10 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
227
228
if header .UncleHash != types .EmptyUncleHash {
228
229
return errInvalidUncleHash
229
230
}
231
+ // Verify the timestamp
232
+ if header .Time <= parent .Time {
233
+ return errInvalidTimestamp
234
+ }
230
235
// Verify the block's difficulty to ensure it's the default constant
231
236
if beaconDifficulty .Cmp (header .Difficulty ) != 0 {
232
237
return fmt .Errorf ("invalid difficulty: have %v, want %v" , header .Difficulty , beaconDifficulty )
0 commit comments