Skip to content

Commit 7062037

Browse files
shemnonmarioevz
andauthored
new(tests): EOF - EIP-7069: Test EXTCALL creation gas charge (ethereum#1025)
* Test EXTCALL creation gas charge Test the creation gas charge of a contract when the contract was called and remained "empty." Signed-off-by: Danno Ferrin <[email protected]> * add "prelude code" Signed-off-by: Danno Ferrin <[email protected]> * Apply suggestions from code review --------- Signed-off-by: Danno Ferrin <[email protected]> Co-authored-by: Mario Vega <[email protected]>
1 parent 8b5b3c1 commit 7062037

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

osaka/eip7692_eof_v1/eip7069_extcall/test_gas.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77

8+
from ethereum_test_base_types import Address
89
from ethereum_test_forks import Fork
910
from ethereum_test_tools import Alloc, Environment, StateTestFiller
1011
from ethereum_test_tools.eof.v1 import Container
@@ -185,3 +186,35 @@ def test_transfer_gas_is_cleared(
185186
+ push_gas,
186187
out_of_gas_testing=False,
187188
)
189+
190+
191+
@pytest.mark.parametrize("opcode", [Op.EXTCALL, Op.EXTDELEGATECALL, Op.EXTSTATICCALL])
192+
def test_late_account_create(
193+
state_test: StateTestFiller,
194+
pre: Alloc,
195+
state_env: Environment,
196+
opcode: Op,
197+
):
198+
"""
199+
Test EXTCALL to a non-existent account after another EXT*CALL has called it and not
200+
created it.
201+
"""
202+
empty_address = Address(0xDECAFC0DE)
203+
204+
gas_test(
205+
state_test,
206+
state_env,
207+
pre,
208+
prelude_code=Op.BALANCE(address=empty_address),
209+
setup_code=opcode(address=empty_address)
210+
+ Op.PUSH1(1)
211+
+ Op.PUSH0
212+
+ Op.PUSH0
213+
+ Op.PUSH20(empty_address),
214+
subject_code=Op.EXTCALL,
215+
subject_balance=5,
216+
tear_down_code=Op.STOP,
217+
cold_gas=WARM_ACCOUNT_ACCESS_GAS + CALL_WITH_VALUE_GAS + ACCOUNT_CREATION_GAS,
218+
warm_gas=WARM_ACCOUNT_ACCESS_GAS + CALL_WITH_VALUE_GAS,
219+
out_of_gas_testing=False,
220+
)

osaka/eip7692_eof_v1/gas_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def gas_test(
3737
subject_balance: int = 0,
3838
oog_difference: int = 1,
3939
out_of_gas_testing: bool = True,
40+
*,
41+
prelude_code: Bytecode | None = None,
4042
):
4143
"""
4244
Create State Test to check the gas cost of a sequence of EOF code.
@@ -72,6 +74,8 @@ def gas_test(
7274
code=(
7375
# warm subject and baseline without executing
7476
(Op.BALANCE(address_subject) + Op.POP + Op.BALANCE(address_baseline) + Op.POP)
77+
# run any "prelude" code that may have universal side effects
78+
+ prelude_code
7579
# Baseline gas run
7680
+ (
7781
Op.GAS

0 commit comments

Comments
 (0)