Skip to content

Commit

Permalink
Fix london transition difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWilsn committed Oct 2, 2024
1 parent 9b95554 commit 8d617fb
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/ethereum/london/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
GAS_LIMIT_ADJUSTMENT_FACTOR = Uint(1024)
GAS_LIMIT_MINIMUM = Uint(5000)
MINIMUM_DIFFICULTY = Uint(131072)
INITIAL_BASE_FEE = 1000000000
INITIAL_BASE_FEE = Uint(1000000000)
MAX_OMMER_DEPTH = Uint(6)
BOMB_DELAY_BLOCKS = 9700000
EMPTY_OMMER_HASH = keccak256(rlp.encode([]))
Expand Down Expand Up @@ -204,7 +204,6 @@ def calculate_base_fee_per_gas(
parent_gas_limit: Uint,
parent_gas_used: Uint,
parent_base_fee_per_gas: Uint,
is_fork_block: bool,
) -> Uint:
"""
Calculates the base fee per gas for the block.
Expand All @@ -219,16 +218,12 @@ def calculate_base_fee_per_gas(
Gas used in the parent block.
parent_base_fee_per_gas :
Base fee per gas of the parent block.
is_fork_block :
Whether the block is the fork block.
Returns
-------
base_fee_per_gas : `Uint`
Base fee per gas for the block.
"""
if is_fork_block:
return Uint(INITIAL_BASE_FEE)
parent_gas_target = parent_gas_limit // ELASTICITY_MULTIPLIER
if not check_gas_limit(block_gas_limit, parent_gas_limit):
raise InvalidBlock
Expand Down Expand Up @@ -287,14 +282,17 @@ def validate_header(header: Header, parent_header: Header) -> None:
if header.gas_used > header.gas_limit:
raise InvalidBlock

is_fork_block = header.number == FORK_CRITERIA.block_number
expected_base_fee_per_gas = calculate_base_fee_per_gas(
header.gas_limit,
parent_header.gas_limit,
parent_header.gas_used,
parent_header.base_fee_per_gas,
is_fork_block,
)
expected_base_fee_per_gas = INITIAL_BASE_FEE
if header.number != FORK_CRITERIA.block_number:
# For every block except the first, calculate the base fee per gas
# based on the parent block.
expected_base_fee_per_gas = calculate_base_fee_per_gas(
header.gas_limit,
parent_header.gas_limit,
parent_header.gas_used,
parent_header.base_fee_per_gas,
)

if expected_base_fee_per_gas != header.base_fee_per_gas:
raise InvalidBlock

Expand Down

0 comments on commit 8d617fb

Please sign in to comment.