|
18 | 18 | StateTestFiller, |
19 | 19 | Transaction, |
20 | 20 | ) |
21 | | -from execution_testing.forks import Fork |
| 21 | +from execution_testing.forks import Amsterdam, Fork |
22 | 22 | from execution_testing.specs.static_state.expect_section import ( |
23 | 23 | resolve_expect_post, |
24 | 24 | ) |
@@ -143,7 +143,16 @@ def test_transaction_costs( |
143 | 143 | ) |
144 | 144 | pre[sender] = Account(balance=0x5FA9C18) |
145 | 145 |
|
146 | | - expect_entries_: list[dict] = [ |
| 146 | + expect_entries: list[dict] = [ |
| 147 | + # EIP-7981 changes access list costs in Amsterdam+. Balance is a |
| 148 | + # placeholder; the expected value is computed dynamically below. |
| 149 | + # Ordered first so Amsterdam+ forks match here instead of the |
| 150 | + # entries below. |
| 151 | + { |
| 152 | + "indexes": {"data": -1, "gas": -1, "value": -1}, |
| 153 | + "network": [">=Amsterdam"], |
| 154 | + "result": {sender: Account(balance=0)}, |
| 155 | + }, |
147 | 156 | { |
148 | 157 | "indexes": {"data": [0, 1], "gas": -1, "value": -1}, |
149 | 158 | "network": ["Cancun"], |
@@ -181,7 +190,7 @@ def test_transaction_costs( |
181 | 190 | }, |
182 | 191 | ] |
183 | 192 |
|
184 | | - post, _exc = resolve_expect_post(expect_entries_, d, g, v, fork) |
| 193 | + post, _exc = resolve_expect_post(expect_entries, d, g, v, fork) |
185 | 194 |
|
186 | 195 | tx_data = [ |
187 | 196 | Bytes("00"), |
@@ -455,4 +464,25 @@ def test_transaction_costs( |
455 | 464 | error=_exc, |
456 | 465 | ) |
457 | 466 |
|
| 467 | + # EIP-7981 (access list repricing) activates in Amsterdam. Compute the |
| 468 | + # expected balance dynamically from the fork's intrinsic cost calculator |
| 469 | + # rather than hardcoding values that change as EIP-7981 evolves. Past |
| 470 | + # forks keep their original hardcoded values above. |
| 471 | + if _exc is None and fork >= Amsterdam: |
| 472 | + sender_pre = pre[sender] |
| 473 | + assert sender_pre is not None |
| 474 | + gas_price = int(tx.gas_price or tx.max_fee_per_gas or 0) |
| 475 | + intrinsic_gas = fork.transaction_intrinsic_cost_calculator()( |
| 476 | + calldata=tx.data, |
| 477 | + contract_creation=tx.to is None, |
| 478 | + access_list=tx.access_list, |
| 479 | + ) |
| 480 | + post[sender] = Account( |
| 481 | + balance=( |
| 482 | + int(sender_pre.balance) |
| 483 | + - int(tx.value) |
| 484 | + - intrinsic_gas * gas_price |
| 485 | + ), |
| 486 | + ) |
| 487 | + |
458 | 488 | state_test(env=env, pre=pre, post=post, tx=tx) |
0 commit comments