Patch for concurrent iterator & others (onto v1.11.6) #386

Closed
roysc wants to merge 1565 commits from v1.11.6-statediff-v5 into master
Showing only changes of commit 7217ef4c9c - Show all commits

View File

@ -45,6 +45,7 @@ var (
errTooManyUncles = errors.New("too many uncles") errTooManyUncles = errors.New("too many uncles")
errInvalidNonce = errors.New("invalid nonce") errInvalidNonce = errors.New("invalid nonce")
errInvalidUncleHash = errors.New("invalid uncle hash") errInvalidUncleHash = errors.New("invalid uncle hash")
errInvalidTimestamp = errors.New("invalid timestamp")
) )
// Beacon is a consensus engine that combines the eth1 consensus and proof-of-stake // 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
// - nonce is expected to be 0 // - nonce is expected to be 0
// - unclehash is expected to be Hash(emptyHeader) // - unclehash is expected to be Hash(emptyHeader)
// to be the desired constants // to be the desired constants
// (b) the timestamp is not verified anymore // (b) we don't verify if a block is in the future anymore
// (c) the extradata is limited to 32 bytes // (c) the extradata is limited to 32 bytes
func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header) error { func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header) error {
// Ensure that the header's extra-data section is of a reasonable size // 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
if header.UncleHash != types.EmptyUncleHash { if header.UncleHash != types.EmptyUncleHash {
return errInvalidUncleHash return errInvalidUncleHash
} }
// Verify the timestamp
if header.Time <= parent.Time {
return errInvalidTimestamp
}
// Verify the block's difficulty to ensure it's the default constant // Verify the block's difficulty to ensure it's the default constant
if beaconDifficulty.Cmp(header.Difficulty) != 0 { if beaconDifficulty.Cmp(header.Difficulty) != 0 {
return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, beaconDifficulty) return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, beaconDifficulty)