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@e9958ed2.

Generate fixtures for these test cases for Osaka with:

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

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
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
@pytest.mark.execute(pytest.mark.skip(reason="Impossible account nonce"))
def test_nonce_overflow_after_first_authorization(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    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-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test