Skip to content

test_nonce_overflow_after_first_authorization()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_nonce_overflow_after_first_authorization@83970623.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_nonce_overflow_after_first_authorization --fork Prague

Test sending a transaction with two authorization where the first one bumps the nonce to 2**64-1 and the second would result in overflow.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
@pytest.mark.execute(pytest.mark.skip(reason="Impossible account nonce"))
def test_nonce_overflow_after_first_authorization(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """
    Test sending a transaction with two authorization where the first one bumps the nonce
    to 2**64-1 and the second would result in overflow.
    """
    nonce = 2**64 - 2
    auth_signer = pre.fund_eoa(auth_account_start_balance, nonce=nonce)

    success_slot = 1
    return_slot = 2

    set_code_1 = Op.RETURN(0, 1)
    set_code_to_address_1 = pre.deploy_contract(set_code_1)
    set_code_2 = Op.RETURN(0, 2)
    set_code_to_address_2 = pre.deploy_contract(set_code_2)

    authorization_list = [
        AuthorizationTuple(
            address=set_code_to_address_1,
            nonce=nonce,
            signer=auth_signer,
        ),
        AuthorizationTuple(
            address=set_code_to_address_2,
            nonce=nonce + 1,
            signer=auth_signer,
        ),
    ]

    entry_code = (
        Op.SSTORE(success_slot, 1)
        + Op.CALL(address=auth_signer)
        + Op.SSTORE(return_slot, Op.RETURNDATASIZE)
    )
    entry_address = pre.deploy_contract(entry_code)

    tx = Transaction(
        gas_limit=200_000,
        to=entry_address,
        value=0,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account(
                nonce=nonce + 1,
                code=Spec.delegation_designation(set_code_to_address_1),
            ),
            entry_address: Account(
                storage={
                    success_slot: 1,
                    return_slot: 1,
                },
            ),
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Prague-blockchain_test
...fork_Prague-state_test
...fork_Osaka-blockchain_test
...fork_Osaka-state_test