Skip to content

Commit ef11a98

Browse files
authored
fix(tests): BALs - set genesis environment to calculate base fee appropriately (#2262)
* fix(tests): set genesis environment to calculate base fee appropriately * add header_verify check for block base_fee - comment on #2262 * chore: add changelog entry
1 parent 322fd26 commit ef11a98

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Test fixtures for use by clients are available for each release on the [Github r
3232
- 🔀 Refactor EIP-7928 (BAL) absence checks into a friendlier class-based DevEx ([#2175](https://github.com/ethereum/execution-spec-tests/pull/2175)).
3333
- 🐞 Tighten up validation for empty lists on Block-Level Access List tests ([#2118](https://github.com/ethereum/execution-spec-tests/pull/2118)).
3434
- ✨ Added the `MemoryVariable` EVM abstraction to generate more readable bytecode when there's heavy use of variables that are stored in memory ([#1609](https://github.com/ethereum/execution-spec-tests/pull/1609)).
35+
- 🐞 Fix an issue with `test_bal_block_rewards` where the block base fee was wrongfully overridden ([#2262](https://github.com/ethereum/execution-spec-tests/pull/2262)).
3536

3637
### 🧪 Test Cases
3738

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from ethereum_test_base_types import AccessList, Address, Hash
8+
from ethereum_test_specs.blockchain import Header
89
from ethereum_test_tools import (
910
Account,
1011
Alloc,
@@ -14,6 +15,7 @@
1415
Transaction,
1516
compute_create_address,
1617
)
18+
from ethereum_test_types import Environment
1719
from ethereum_test_types.block_access_list import (
1820
BalAccountExpectation,
1921
BalBalanceChange,
@@ -595,14 +597,13 @@ def test_bal_block_rewards(
595597
charlie = pre.fund_eoa(amount=0) # fee recipient
596598

597599
intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
598-
intrinsic_gas_cost = intrinsic_gas_calculator(
600+
intrinsic_gas = intrinsic_gas_calculator(
599601
calldata=b"",
600602
contract_creation=False,
601603
access_list=[],
602604
)
603-
tx_gas_limit = intrinsic_gas_cost + 1000 # add a small buffer
605+
tx_gas_limit = intrinsic_gas + 1000 # add a small buffer
604606
gas_price = 0xA
605-
base_fee_per_gas = 0x2 # Set base fee for EIP-1559
606607

607608
tx = Transaction(
608609
sender=alice,
@@ -614,16 +615,23 @@ def test_bal_block_rewards(
614615

615616
# EIP-1559 fee calculation:
616617
# - Total gas cost
617-
total_gas_cost = intrinsic_gas_cost * gas_price
618+
total_gas_cost = intrinsic_gas * gas_price
618619
# - Tip portion
619-
tip_to_charlie = intrinsic_gas_cost * (gas_price - base_fee_per_gas)
620+
621+
genesis_env = Environment(base_fee_per_gas=0x7)
622+
base_fee_per_gas = fork.base_fee_per_gas_calculator()(
623+
parent_base_fee_per_gas=genesis_env.base_fee_per_gas,
624+
parent_gas_used=0,
625+
parent_gas_limit=genesis_env.gas_limit,
626+
)
627+
tip_to_charlie = (gas_price - base_fee_per_gas) * intrinsic_gas
620628

621629
alice_final_balance = alice_initial_balance - 100 - total_gas_cost
622630

623631
block = Block(
624632
txs=[tx],
625633
fee_recipient=charlie, # Set Charlie as the fee recipient
626-
base_fee_per_gas=base_fee_per_gas, # Set base fee for EIP-1559
634+
header_verify=Header(base_fee_per_gas=base_fee_per_gas),
627635
expected_block_access_list=BlockAccessListExpectation(
628636
account_expectations={
629637
alice: BalAccountExpectation(
@@ -646,6 +654,7 @@ def test_bal_block_rewards(
646654
pre=pre,
647655
blocks=[block],
648656
post={},
657+
genesis_environment=genesis_env,
649658
)
650659

651660

0 commit comments

Comments
 (0)