Skip to content

test_authorization_with_sstore()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_authorization_with_sstore@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_authorization_with_sstore --fork Amsterdam

Test SetCode authorization combined with a recipient SSTORE.

The authority (an existing EOA) gains a fresh delegation, charged the top-frame AUTH_BASE; the called recipient then performs an SSTORE whose regular and state costs are charged during execution. The header gas_used is the max of the regular block and the (AUTH_BASE + SSTORE) state block.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
@pytest.mark.valid_from("EIP8037")
def test_authorization_with_sstore(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test SetCode authorization combined with a recipient SSTORE.

    The authority (an existing EOA) gains a fresh delegation, charged the
    top-frame ``AUTH_BASE``; the called recipient then performs an SSTORE
    whose regular and state costs are charged during execution. The header
    ``gas_used`` is the max of the regular block and the (``AUTH_BASE`` +
    SSTORE) state block.
    """
    storage = Storage()
    code = Op.SSTORE(storage.store_next(1), 1)
    contract = pre.deploy_contract(code=code)
    execution_regular = code.regular_cost(fork)
    execution_state = code.state_cost(fork)

    signer = pre.fund_eoa()
    authorization_list = [
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=signer,
            creates_account=False,
            writes_delegation=True,
        ),
    ]

    intrinsic_regular, top_frame_regular, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    _, header_gas_used = _receipt_and_header(
        intrinsic_regular,
        top_frame_regular,
        top_frame_state,
        execution_regular=execution_regular,
        execution_state=execution_state,
    )

    tx = Transaction(
        to=contract,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
    )

    post = {
        contract: Account(storage=storage),
        signer: Account(code=Spec7702.delegation_designation(contract)),
    }
    state_test(
        pre=pre,
        post=post,
        tx=tx,
        blockchain_test_header_verify=Header(gas_used=header_gas_used),
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.