From 72fce935ee463ba7571126960ca69d1f96e61f51 Mon Sep 17 00:00:00 2001 From: Kelvin Fichter Date: Tue, 9 Mar 2021 14:35:24 -0800 Subject: [PATCH] Revert ethhash changes --- consensus/ethash/consensus.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index dba3a451f..8ae99b199 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -254,7 +254,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent * return consensus.ErrFutureBlock } } - if header.Time < parent.Time { + if header.Time <= parent.Time { return errOlderBlockTime } // Verify the block's difficulty based on its timestamp and parent's difficulty @@ -273,19 +273,16 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent * return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit) } - // TODO: UNCOMMENT THIS CHECK WHEN WE UNDERSTAND OUR GAS LIMIT REQUIREMENTS - // Verify that the gas limit remains within allowed bounds - //diff := int64(parent.GasLimit) - int64(header.GasLimit) - //if diff < 0 { - // diff *= -1 - //} - - //limit := parent.GasLimit / params.GasLimitBoundDivisor - //if uint64(diff) >= limit || header.GasLimit < params.MinGasLimit { - // return fmt.Errorf("invalid gas limit: have %d, want %d += %d", header.GasLimit, parent.GasLimit, limit) - //} + diff := int64(parent.GasLimit) - int64(header.GasLimit) + if diff < 0 { + diff *= -1 + } + limit := parent.GasLimit / params.GasLimitBoundDivisor + if uint64(diff) >= limit || header.GasLimit < params.MinGasLimit { + return fmt.Errorf("invalid gas limit: have %d, want %d += %d", header.GasLimit, parent.GasLimit, limit) + } // Verify that the block number is parent's +1 if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(big.NewInt(1)) != 0 { return consensus.ErrInvalidNumber