Skip to content

test_signature_s_out_of_range()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_signature_s_out_of_range@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_signature_s_out_of_range --fork Amsterdam

Test sending a transaction with an authorization tuple where the signature s value is out of range by modifying its value to be SECP256K1N - S and flipping the v value.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
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
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
def test_signature_s_out_of_range(
    state_test: StateTestFiller,
    pre: Alloc,
    chain_config: ChainConfig,
    fork: Fork,
) -> None:
    """
    Test sending a transaction with an authorization tuple where the signature
    s value is out of range by modifying its value to be `SECP256K1N - S` and
    flipping the v value.
    """
    auth_signer = pre.fund_eoa(0)

    set_code = Op.STOP
    set_code_to_address = pre.deploy_contract(set_code)

    authorization_tuple = AuthorizationTuple(
        address=set_code_to_address,
        nonce=0,
        chain_id=chain_config.chain_id,
        signer=auth_signer,
    )

    authorization_tuple.s = HexNumber(SECP256K1N - authorization_tuple.s)
    authorization_tuple.v = HexNumber(1 - authorization_tuple.v)

    assert authorization_tuple.s > SECP256K1N_OVER_2

    success_slot = 1
    entry_code = Op.SSTORE(success_slot, 1) + Op.STOP
    entry_address = pre.deploy_contract(entry_code)

    tx = Transaction(
        gas_limit=100_000,
        to=entry_address,
        value=0,
        authorization_list=[authorization_tuple],
        sender=pre.fund_eoa(),
    )

    expected_block_access_list = None
    if fork.is_eip_enabled(7928):
        # High-s rejected pre-load -> authority not in BAL (EIP-7928).
        expected_block_access_list = BlockAccessListExpectation(
            account_expectations={
                tx.sender: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1)
                    ],
                ),
                entry_address: BalAccountExpectation(
                    storage_changes=[
                        BalStorageSlot(
                            slot=success_slot,
                            slot_changes=[
                                BalStorageChange(
                                    block_access_index=1, post_value=1
                                )
                            ],
                        )
                    ],
                ),
                auth_signer: None,
                set_code_to_address: None,
            }
        )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account.NONEXISTENT,
            entry_address: Account(
                storage={success_slot: 1},
            ),
        },
        expected_block_access_list=expected_block_access_list,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 3 forks.