Skip to content

test_mixed_new_and_existing_auths()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_mixed_new_and_existing_auths@87aba1a3.

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_mixed_new_and_existing_auths --fork Amsterdam

Test mixed new and existing account authorizations at the top frame.

One authority is an existing EOA (charged only AUTH_BASE); the other does not exist pre-tx (charged NEW_ACCOUNT + ACCOUNT_WRITE for the leaf plus AUTH_BASE for the net-new indicator). The total top-frame charge is the sum of the two, with no refund.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
@pytest.mark.valid_from("EIP8037")
def test_mixed_new_and_existing_auths(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test mixed new and existing account authorizations at the top frame.

    One authority is an existing EOA (charged only ``AUTH_BASE``); the
    other does not exist pre-tx (charged ``NEW_ACCOUNT`` + ``ACCOUNT_WRITE``
    for the leaf plus ``AUTH_BASE`` for the net-new indicator). The total
    top-frame charge is the sum of the two, with no refund.
    """
    contract = pre.deploy_contract(code=Op.STOP)

    existing_signer = pre.fund_eoa()
    new_signer = pre.fund_eoa(amount=0)

    authorization_list = [
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=existing_signer,
            creates_account=False,
            writes_delegation=True,
        ),
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=new_signer,
            creates_account=True,
            writes_delegation=True,
        ),
    ]

    intrinsic_regular, top_frame_regular, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    cumulative_gas_used, header_gas_used = _receipt_and_header(
        intrinsic_regular, top_frame_regular, top_frame_state
    )

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

    post = {
        existing_signer: Account(
            code=Spec7702.delegation_designation(contract),
        ),
        new_signer: Account(
            nonce=1,
            balance=0,
            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.