Skip to content

Commit d756068

Browse files
committed
fix(tests): Broken tests due to gas cost change
1 parent ece0213 commit d756068

File tree

3 files changed

+57
-7
lines changed

3 files changed

+57
-7
lines changed

tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from ethereum_test_forks import Fork
3939
from ethereum_test_tools import (
4040
EOA,
41+
AccessList,
4142
Account,
4243
Address,
4344
Alloc,
@@ -559,9 +560,15 @@ def test_tx_entry_point(
559560
start_balance = 10**18
560561
sender = pre.fund_eoa(amount=start_balance)
561562

563+
# Starting from EIP-7623, we need to use an access list to raise the intrinsic gas cost to be
564+
# above the floor data cost.
565+
access_list = [AccessList(address=Address(i), storage_keys=[]) for i in range(1, 10)]
566+
562567
# Gas is appended the intrinsic gas cost of the transaction
563568
tx_intrinsic_gas_cost_calculator = fork.transaction_intrinsic_cost_calculator()
564-
intrinsic_gas_cost = tx_intrinsic_gas_cost_calculator(calldata=precompile_input)
569+
intrinsic_gas_cost = tx_intrinsic_gas_cost_calculator(
570+
calldata=precompile_input, access_list=access_list
571+
)
565572

566573
# Consumed gas will only be the precompile gas if the proof is correct and
567574
# the call gas is sufficient.
@@ -570,13 +577,17 @@ def test_tx_entry_point(
570577
Spec.POINT_EVALUATION_PRECOMPILE_GAS
571578
if call_gas >= Spec.POINT_EVALUATION_PRECOMPILE_GAS and proof_correct
572579
else call_gas
573-
) + intrinsic_gas_cost
574-
580+
) + tx_intrinsic_gas_cost_calculator(
581+
calldata=precompile_input,
582+
access_list=access_list,
583+
return_cost_deducted_prior_execution=True,
584+
)
575585
fee_per_gas = 7
576586

577587
tx = Transaction(
578588
sender=sender,
579589
data=precompile_input,
590+
access_list=access_list,
580591
to=Address(Spec.POINT_EVALUATION_PRECOMPILE_ADDRESS),
581592
gas_limit=call_gas + intrinsic_gas_cost,
582593
gas_price=fee_per_gas,

tests/cancun/eip5656_mcopy/test_mcopy_memory_expansion.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
66
""" # noqa: E501
77
import itertools
8-
from typing import Mapping
8+
from typing import List, Mapping
99

1010
import pytest
1111

1212
from ethereum_test_forks import Fork
13-
from ethereum_test_tools import Account, Address, Alloc, Bytecode, Environment
13+
from ethereum_test_tools import AccessList, Account, Address, Alloc, Bytecode, Environment
1414
from ethereum_test_tools import Opcodes as Op
1515
from ethereum_test_tools import StateTestFiller, Transaction
1616

@@ -51,16 +51,27 @@ def callee_bytecode(dest: int, src: int, length: int) -> Bytecode:
5151
return bytecode
5252

5353

54+
@pytest.fixture
55+
def tx_access_list() -> List[AccessList]:
56+
"""
57+
Access list for the transaction.
58+
"""
59+
return [AccessList(address=Address(i), storage_keys=[]) for i in range(1, 10)]
60+
61+
5462
@pytest.fixture
5563
def call_exact_cost(
5664
fork: Fork,
5765
initial_memory: bytes,
5866
dest: int,
5967
length: int,
68+
tx_access_list: List[AccessList],
6069
) -> int:
6170
"""
6271
Returns the exact cost of the subcall, based on the initial memory and the length of the copy.
6372
"""
73+
# Starting from EIP-7623, we need to use an access list to raise the intrinsic gas cost to be
74+
# above the floor data cost.
6475
cost_memory_bytes = fork.memory_expansion_gas_calculator()
6576
gas_costs = fork.gas_costs()
6677
tx_intrinsic_gas_cost_calculator = fork.transaction_intrinsic_cost_calculator()
@@ -81,7 +92,7 @@ def call_exact_cost(
8192

8293
sstore_cost = 22100
8394
return (
84-
tx_intrinsic_gas_cost_calculator(calldata=initial_memory)
95+
tx_intrinsic_gas_cost_calculator(calldata=initial_memory, access_list=tx_access_list)
8596
+ mcopy_cost
8697
+ calldatacopy_cost
8798
+ pushes_cost
@@ -133,10 +144,12 @@ def tx( # noqa: D103
133144
initial_memory: bytes,
134145
tx_max_fee_per_gas: int,
135146
tx_gas_limit: int,
147+
tx_access_list: List[AccessList],
136148
) -> Transaction:
137149
return Transaction(
138150
sender=sender,
139151
to=caller_address,
152+
access_list=tx_access_list,
140153
data=initial_memory,
141154
gas_limit=tx_gas_limit,
142155
max_fee_per_gas=tx_max_fee_per_gas,

tests/shanghai/eip3860_initcode/test_initcode.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
- [ethereum/tests/pull/1012](https://github.com/ethereum/tests/pull/990)
88
"""
99

10+
from typing import List
11+
1012
import pytest
1113

1214
from ethereum_test_forks import Fork
1315
from ethereum_test_tools import (
1416
EOA,
17+
AccessList,
1518
Account,
1619
Address,
1720
Alloc,
@@ -208,14 +211,35 @@ class TestContractCreationGasUsage:
208211
"""
209212

210213
@pytest.fixture
211-
def exact_intrinsic_gas(self, fork: Fork, initcode: Initcode) -> int:
214+
def tx_access_list(self) -> List[AccessList]:
215+
"""
216+
Starting from EIP-7623, we need to use an access list to raise the intrinsic gas cost to
217+
be above the floor data cost.
218+
"""
219+
return [AccessList(address=Address(i), storage_keys=[]) for i in range(1, 478)]
220+
221+
@pytest.fixture
222+
def exact_intrinsic_gas(
223+
self, fork: Fork, initcode: Initcode, tx_access_list: List[AccessList]
224+
) -> int:
212225
"""
213226
Calculates the intrinsic tx gas cost.
214227
"""
215228
tx_intrinsic_gas_cost_calculator = fork.transaction_intrinsic_cost_calculator()
229+
assert tx_intrinsic_gas_cost_calculator(
230+
calldata=initcode,
231+
contract_creation=True,
232+
access_list=tx_access_list,
233+
) == tx_intrinsic_gas_cost_calculator(
234+
calldata=initcode,
235+
contract_creation=True,
236+
access_list=tx_access_list,
237+
return_cost_deducted_prior_execution=True,
238+
)
216239
return tx_intrinsic_gas_cost_calculator(
217240
calldata=initcode,
218241
contract_creation=True,
242+
access_list=tx_access_list,
219243
)
220244

221245
@pytest.fixture
@@ -241,6 +265,7 @@ def tx(
241265
sender: EOA,
242266
initcode: Initcode,
243267
gas_test_case: str,
268+
tx_access_list: List[AccessList],
244269
tx_error: TransactionException | None,
245270
exact_intrinsic_gas: int,
246271
exact_execution_gas: int,
@@ -264,6 +289,7 @@ def tx(
264289
return Transaction(
265290
nonce=0,
266291
to=None,
292+
access_list=tx_access_list,
267293
data=initcode,
268294
gas_limit=gas_limit,
269295
gas_price=10,

0 commit comments

Comments
 (0)