Skip to content

Commit

Permalink
eip-1559: revert to old gaslimit checks (ethereum#3566)
Browse files Browse the repository at this point in the history
* eip-1559: revert to old gaslimit checks

* eip-1559: remove unused variable

* eip-1559: fix comment
  • Loading branch information
holiman authored May 11, 2021
1 parent 13e96ca commit 5aa223d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions EIPS/eip-1559.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_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:
Expand Down

0 comments on commit 5aa223d

Please sign in to comment.