Skip to content

Commit

Permalink
new(tests): EOFCREATE frame reverts with EOF container
Browse files Browse the repository at this point in the history
  • Loading branch information
pdobacz committed Jun 19, 2024
1 parent 3226979 commit bc8f43c
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,60 @@ def test_address_collision(
sender=sender,
)
state_test(env=env, pre=pre, post=post, tx=tx)


def test_eofcreate_revert_eof_returndata(
state_test: StateTestFiller,
pre: Alloc,
):
"""
Verifies the return data is not being deployed, even if happens to be valid EOF
"""
env = Environment()
code_reverts_with_calldata = Container(
name="Initcode Subcontainer reverting with its calldata",
sections=[
Section.Code(
code=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE) + Op.REVERT(0, Op.CALLDATASIZE),
max_stack_height=3,
),
],
)

sender = pre.fund_eoa()
contract_address = pre.deploy_contract(
code=Container(
sections=[
Section.Code(
code=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
+ Op.SSTORE(0, Op.EOFCREATE[0](0, 0, 0, Op.CALLDATASIZE))
+ Op.SSTORE(1, Op.RETURNDATASIZE)
+ Op.STOP,
max_stack_height=4,
),
Section.Container(container=code_reverts_with_calldata),
],
)
)

post = {
contract_address: Account(
# slot 0 - eofcreate result 0 / revert
# slot 1 - returndatasize from eofcreate
storage={
0: 0,
1: 20,
},
),
}

tx = Transaction(
to=contract_address,
gas_limit=1_000_000,
sender=sender,
# Simplest possible valid EOF container, which is going to be
# revert-returned from initcode and must not end up being deployed.
data=smallest_runtime_subcontainer,
)

state_test(env=env, pre=pre, post=post, tx=tx)

0 comments on commit bc8f43c

Please sign in to comment.