@@ -511,3 +511,62 @@ def test_address_collision(
511511 sender = sender ,
512512 )
513513 state_test (env = env , pre = pre , post = post , tx = tx )
514+
515+
516+ def test_eofcreate_revert_eof_returndata (
517+ state_test : StateTestFiller ,
518+ pre : Alloc ,
519+ ):
520+ """
521+ Verifies the return data is not being deployed, even if happens to be valid EOF
522+ """
523+ env = Environment ()
524+ code_reverts_with_calldata = Container (
525+ name = "Initcode Subcontainer reverting with its calldata" ,
526+ sections = [
527+ Section .Code (
528+ code = Op .CALLDATACOPY (0 , 0 , Op .CALLDATASIZE ) + Op .REVERT (0 , Op .CALLDATASIZE ),
529+ ),
530+ ],
531+ )
532+
533+ sender = pre .fund_eoa ()
534+ salt = 0
535+ contract_address = pre .deploy_contract (
536+ code = Container (
537+ sections = [
538+ Section .Code (
539+ code = Op .CALLDATACOPY (0 , 0 , Op .CALLDATASIZE )
540+ + Op .SSTORE (slot_create_address , Op .EOFCREATE [0 ](0 , salt , 0 , Op .CALLDATASIZE ))
541+ + Op .SSTORE (slot_returndata_size , Op .RETURNDATASIZE )
542+ + Op .STOP ,
543+ ),
544+ Section .Container (container = code_reverts_with_calldata ),
545+ ],
546+ ),
547+ storage = {slot_create_address : value_canary_to_be_overwritten },
548+ )
549+ eof_create_address = compute_eofcreate_address (
550+ contract_address , salt , code_reverts_with_calldata
551+ )
552+
553+ post = {
554+ contract_address : Account (
555+ storage = {
556+ slot_create_address : 0 ,
557+ slot_returndata_size : len (smallest_runtime_subcontainer ),
558+ },
559+ ),
560+ eof_create_address : Account .NONEXISTENT ,
561+ }
562+
563+ tx = Transaction (
564+ to = contract_address ,
565+ gas_limit = 1_000_000 ,
566+ sender = sender ,
567+ # Simplest possible valid EOF container, which is going to be
568+ # revert-returned from initcode and must not end up being deployed.
569+ data = smallest_runtime_subcontainer ,
570+ )
571+
572+ state_test (env = env , pre = pre , post = post , tx = tx )
0 commit comments