Skip to content

test_auxdata_size_failures()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_auxdata_size_failures@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_auxdata_size_failures --fork Osaka

Exercises a number of auxdata size violations, and one maxcode success.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
@pytest.mark.parametrize(
    "auxdata_size",
    [
        pytest.param(MAX_BYTECODE_SIZE - len(smallest_runtime_subcontainer), id="maxcode"),
        pytest.param(MAX_BYTECODE_SIZE - len(smallest_runtime_subcontainer) + 1, id="overmaxcode"),
        pytest.param(0x10000 - 60, id="almost64k"),
        pytest.param(0x10000 - 1, id="64k-1"),
        pytest.param(0x10000, id="64k"),
        pytest.param(0x10000 + 1, id="over64k"),
    ],
)
def test_auxdata_size_failures(state_test: StateTestFiller, pre: Alloc, auxdata_size: int):
    """Exercises a number of auxdata size violations, and one maxcode success."""
    env = Environment()
    auxdata_bytes = b"a" * auxdata_size

    initcode_subcontainer = Container(
        name="Initcode Subcontainer",
        sections=[
            Section.Code(
                code=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
                + Op.RETURNCONTRACT[0](0, Op.CALLDATASIZE),
            ),
            Section.Container(container=smallest_runtime_subcontainer),
        ],
    )

    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    code=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
                    + Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, Op.CALLDATASIZE))
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.STOP,
                ),
                Section.Container(container=initcode_subcontainer),
            ]
        )
    )

    deployed_container_size = len(smallest_runtime_subcontainer) + auxdata_size

    # Storage in 0 will have address in first test, 0 in all other cases indicating failure
    # Storage 1 in 1 is a canary to see if EOFCREATE opcode halted
    post = {
        contract_address: Account(
            storage={
                slot_create_address: compute_eofcreate_address(
                    contract_address, 0, initcode_subcontainer
                )
                if deployed_container_size <= MAX_BYTECODE_SIZE
                else 0,
                slot_code_worked: value_code_worked,
            }
        )
    }

    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        gas_price=10,
        protected=False,
        sender=sender,
        data=auxdata_bytes,
    )

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

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) auxdata_size
...fork_Osaka-state_test-maxcode 24556
...fork_Osaka-state_test-overmaxcode 24557
...fork_Osaka-state_test-almost64k 65476
...fork_Osaka-state_test-64k-1 65535
...fork_Osaka-state_test-64k 65536
...fork_Osaka-state_test-over64k 65537
...fork_Osaka-blockchain_test_from_state_test-maxcode 24556
...fork_Osaka-blockchain_test_from_state_test-overmaxcode 24557
...fork_Osaka-blockchain_test_from_state_test-almost64k 65476
...fork_Osaka-blockchain_test_from_state_test-64k-1 65535
...fork_Osaka-blockchain_test_from_state_test-64k 65536
...fork_Osaka-blockchain_test_from_state_test-over64k 65537