diff --git a/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py b/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py index 2446cfe5f4..e83bf4cffd 100644 --- a/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py +++ b/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py @@ -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)