eip-1559: revert to old gaslimit checks (#3566)

* eip-1559: revert to old gaslimit checks

* eip-1559: remove unused variable

* eip-1559: fix comment
This commit is contained in:
Martin Holst Swende 2021-05-12 00:24:42 +02:00 committed by GitHub
parent 13e96ca288
commit 5aa223d7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,23 +157,24 @@ ELASTICITY_MULTIPLIER = 2
class World(ABC):
def validate_block(self, block: Block) -> None:
parent_gas_target = self.parent(block).gas_limit // ELASTICITY_MULTIPLIER
parent_gas_limit = self.parent(block).gas_limit
# on the fork block, don't account for the ELASTICITY_MULTIPLIER to avoid
# unduly halving the gas target.
if INITIAL_FORK_BLOCK_NUMBER == block.number:
parent_gas_target = self.parent(block).gas_limit
parent_gas_limit = self.parent(block).gas_limit * ELASTICITY_MULTIPLIER
parent_base_fee_per_gas = self.parent(block).base_fee_per_gas
parent_gas_used = self.parent(block).gas_used
gas_target = block.gas_limit // ELASTICITY_MULTIPLIER
transactions = self.transactions(block)
# check if the block used too much gas
assert block.gas_used <= block.gas_limit, 'invalid block: too much gas used'
# check if the block changed the gas target too much
assert gas_target <= parent_gas_target + parent_gas_target // 1024, 'invalid block: gas target increased too much'
assert gas_target >= parent_gas_target - parent_gas_target // 1024, 'invalid block: gas target decreased too much'
# check if the block changed the gas limit too much
assert block.gas_limit < parent_gas_limit + parent_gas_limit // 1024, 'invalid block: gas limit increased too much'
assert block.gas_limit > parent_gas_limit - parent_gas_limit // 1024, 'invalid block: gas limit decreased too much'
# check if the base fee is correct
if INITIAL_FORK_BLOCK_NUMBER == block.number: