Skip to content

test_inner_create_succeeds_outer_reverts_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_inner_create_succeeds_outer_reverts_no_log@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_inner_create_succeeds_outer_reverts_no_log --fork Amsterdam

Test that a CREATE/CREATE2 transfer log is rolled back on outer revert.

The factory CREATE/CREATE2s a child with value (the deployment succeeds and a factory -> created log is emitted in the child frame), then the factory itself REVERTs. Per EIP-7708 the rollback semantics mirror those of CALL: the child log is discarded together with the rest of the factory's frame, so the transaction receipt records no logs.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
@pytest.mark.with_all_create_opcodes
def test_inner_create_succeeds_outer_reverts_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    fork: Fork,
    create_opcode: Op,
) -> None:
    """
    Test that a CREATE/CREATE2 transfer log is rolled back on outer revert.

    The factory CREATE/CREATE2s a child with value (the deployment succeeds
    and a `factory -> created` log is emitted in the child frame), then the
    factory itself REVERTs. Per EIP-7708 the rollback semantics mirror those
    of CALL: the child log is discarded together with the rest of the
    factory's frame, so the transaction receipt records no logs.
    """
    create_value = 1
    initcode = Op.RETURN(0, 0)
    initcode_len = len(initcode)

    factory_code = (
        Op.MSTORE(0, Op.PUSH32(bytes(initcode).rjust(32, b"\x00")))
        + Op.MSTORE(
            32,
            create_opcode(
                value=create_value,
                offset=32 - initcode_len,
                size=initcode_len,
            ),
        )
        + Op.REVERT(32, 32)
    )
    factory = pre.deploy_contract(factory_code, balance=create_value)

    entry_storage = Storage()
    expected_create_address = compute_create_address(
        address=factory,
        nonce=1,
        salt=0,
        initcode=initcode,
        opcode=create_opcode,
    )
    entry_code = Op.CALL(
        address=factory, ret_offset=0, ret_size=32
    ) + Op.SSTORE(
        entry_storage.store_next(expected_create_address), Op.MLOAD(0)
    )
    entry = pre.deploy_contract(entry_code)

    tx = Transaction(
        sender=sender,
        to=entry,
        value=0,
        expected_receipt=TransactionReceipt(logs=[]),
    )

    state_test(
        env=env,
        pre=pre,
        post={entry: Account(storage=entry_storage)},
        tx=tx,
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.