Skip to content
This repository has been archived by the owner on Apr 11, 2021. It is now read-only.

dev: Revert ethash changes #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Copy link
Contributor

@gakonst gakonst Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the TestChainTxReorgs because header.GasLimit < params.MinGasLimit (the MinGasLimit = 4m, whereas the gas limit used in the provided header is 3.4m). The blockchain_test.go and ethash/consensus.go are the same as c49a4165d074c2d08c362cfe1dac835b6a3e1251, so I am not sure why this happens.

The TestGenerateBlockAndImportEthash test also fails at the timestamp check in consensus.go:257, because both the header.Time and parent.Time are 0. Similarly, I would have expected that there is some time given until the next block is passed.

Despite the fact that these test cases may not be part of the "normal" codepaths, it seems like we should understand why these fail

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
Expand Down