Skip to content

test_create2_child_spill_not_double_charged()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create2_child_spill_not_double_charged@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create2_child_spill_not_double_charged --fork Amsterdam

Test CREATE2 child state gas paid from gas_left is not recharged.

The factory executes below the Amsterdam tx gas cap, so the CREATE2 child pays new-account and storage state gas by spilling from gas_left. The factory must not charge the same state growth again at frame end.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@pytest.mark.valid_from("EIP8037")
def test_create2_child_spill_not_double_charged(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test CREATE2 child state gas paid from `gas_left` is not recharged.

    The factory executes below the Amsterdam tx gas cap, so the CREATE2 child
    pays new-account and storage state gas by spilling from `gas_left`. The
    factory must not charge the same state growth again at frame end.
    """
    init_code = sum(Op.SSTORE(i, i + 1) for i in range(6)) + Op.STOP
    mstore_value, initcode_size = init_code_at_high_bytes(init_code)

    factory = pre.deploy_contract(
        code=(
            Op.MSTORE(0, mstore_value)
            + Op.POP(
                Op.CREATE2(
                    value=0,
                    offset=0,
                    size=initcode_size,
                    salt=0,
                )
            )
        )
    )
    created = compute_create2_address(
        address=factory,
        salt=0,
        initcode=bytes(init_code),
    )

    tx = Transaction(
        to=factory,
        gas_limit=1_000_000,
        sender=pre.fund_eoa(),
    )

    post = {
        created: Account(nonce=1, storage={i: i + 1 for i in range(6)}),
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.