Skip to content

Commit 058baa6

Browse files
authored
feat(tests): add test for large args offset with size zero on CALL opcode (#2057)
* add test for call large args offset and memory size zero * make test for more call opcodes
1 parent 1b7092c commit 058baa6

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/frontier/opcodes/test_call.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,55 @@ def test_call_memory_expands_on_early_revert(
147147
)
148148
},
149149
)
150+
151+
152+
# TODO: There's an issue with gas definitions on forks previous to Berlin, remove this when fixed.
153+
# https://github.com/ethereum/execution-spec-tests/pull/1952#discussion_r2237634275
154+
@pytest.mark.with_all_call_opcodes
155+
@pytest.mark.valid_from("Berlin")
156+
def test_call_large_args_offset_size_zero(
157+
state_test: StateTestFiller,
158+
pre: Alloc,
159+
fork: Fork,
160+
call_opcode: Op,
161+
):
162+
"""
163+
Test xCALL with an extremely large args_offset and args_size set to zero.
164+
Since the size is zero, the large offset should not cause a revert.
165+
"""
166+
sender = pre.fund_eoa()
167+
168+
gsc = fork.gas_costs()
169+
very_large_offset = 2**100
170+
171+
call_measure = CodeGasMeasure(
172+
code=call_opcode(gas=0, args_offset=very_large_offset, args_size=0),
173+
overhead_cost=gsc.G_VERY_LOW * len(call_opcode.kwargs), # Cost of pushing xCALL args
174+
extra_stack_items=1, # Because xCALL pushes 1 item to the stack
175+
sstore_key=0,
176+
)
177+
178+
contract = pre.deploy_contract(call_measure)
179+
180+
tx = Transaction(
181+
gas_limit=500_000,
182+
to=contract,
183+
value=0,
184+
sender=sender,
185+
)
186+
187+
# this call cost is just the address_access_cost
188+
call_cost = gsc.G_COLD_ACCOUNT_ACCESS
189+
190+
state_test(
191+
env=Environment(),
192+
pre=pre,
193+
tx=tx,
194+
post={
195+
contract: Account(
196+
storage={
197+
0: call_cost,
198+
},
199+
)
200+
},
201+
)

0 commit comments

Comments
 (0)