Skip to content

test_set_code_using_invalid_signatures()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_using_invalid_signatures@verkle@v0.0.6.

Generate fixtures for these test cases for Prague with:

Prague only:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_using_invalid_signatures --fork=Prague --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Prague:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_using_invalid_signatures --until=Prague

Test sending a transaction to set the code of an account using synthetic signatures, the transaction is valid but the authorization should not go through.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
@pytest.mark.parametrize(
    "v,r,s",
    [
        pytest.param(1, 0, 1, id="v_1,r_0,s_1"),
        pytest.param(1, 1, 0, id="v_1,r_1,s_0"),
        pytest.param(
            0,
            SECP256K1N,
            1,
            id="v_0,r_SECP256K1N,s_1",
        ),
        pytest.param(
            0,
            SECP256K1N - 1,
            1,
            id="v_0,r_SECP256K1N-1,s_1",
        ),
        pytest.param(
            0,
            1,
            SECP256K1N_OVER_2,
            id="v_0,r_1,s_SECP256K1N_OVER_2",
        ),
        pytest.param(
            0,
            1,
            SECP256K1N_OVER_2 - 1,
            id="v_0,r_1,s_SECP256K1N_OVER_2_minus_one",
        ),
        pytest.param(
            1,
            2**256 - 1,
            1,
            id="v_1,r_2**256-1,s_1",
        ),
    ],
)
def test_set_code_using_invalid_signatures(
    state_test: StateTestFiller,
    pre: Alloc,
    v: int,
    r: int,
    s: int,
):
    """
    Test sending a transaction to set the code of an account using synthetic signatures,
    the transaction is valid but the authorization should not go through.
    """
    success_slot = 1

    callee_code = Op.SSTORE(success_slot, 1) + Op.STOP
    callee_address = pre.deploy_contract(callee_code)

    authorization_tuple = AuthorizationTuple(
        address=0,
        nonce=0,
        chain_id=1,
        v=v,
        r=r,
        s=s,
    )

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

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            callee_address: Account(
                storage={success_slot: 1},
            ),
        },
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID v r s
v_1,r_0,s_1 1 0 1
v_1,r_1,s_0 1 1 0
v_0,r_SECP256K1N,s_1 0 115792089237316195423570985008687907852837564279074904382605163141518161494337 1
v_0,r_SECP256K1N-1,s_1 0 115792089237316195423570985008687907852837564279074904382605163141518161494336 1
v_0,r_1,s_SECP256K1N_OVER_2 0 1 57896044618658097711785492504343953926418782139537452191302581570759080747168
v_0,r_1,s_SECP256K1N_OVER_2_minus_one 0 1 57896044618658097711785492504343953926418782139537452191302581570759080747167
v_1,r_2**256-1,s_1 1 115792089237316195423570985008687907853269984665640564039457584007913129639935 1
v_1,r_0,s_1 1 0 1
v_1,r_1,s_0 1 1 0
v_0,r_SECP256K1N,s_1 0 115792089237316195423570985008687907852837564279074904382605163141518161494337 1
v_0,r_SECP256K1N-1,s_1 0 115792089237316195423570985008687907852837564279074904382605163141518161494336 1
v_0,r_1,s_SECP256K1N_OVER_2 0 1 57896044618658097711785492504343953926418782139537452191302581570759080747168
v_0,r_1,s_SECP256K1N_OVER_2_minus_one 0 1 57896044618658097711785492504343953926418782139537452191302581570759080747167
v_1,r_2**256-1,s_1 1 115792089237316195423570985008687907853269984665640564039457584007913129639935 1