Skip to content

test_set_code_address_and_authority_warm_state_call_types()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_address_and_authority_warm_state_call_types@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

Test set to code address and authority warm status after a call to authority address, or vice-versa, using all available call opcodes without using GAS opcode (unavailable in EOF).

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
@pytest.mark.with_all_call_opcodes()
@pytest.mark.parametrize(
    "set_code_address_first",
    [
        pytest.param(True, id="call_set_code_address_first_then_authority"),
        pytest.param(False, id="call_authority_first_then_set_code_address"),
    ],
)
def test_set_code_address_and_authority_warm_state_call_types(
    state_test: StateTestFiller,
    pre: Alloc,
    call_opcode: Op,
    set_code_address_first: bool,
) -> None:
    """
    Test set to code address and authority warm status after a call to
    authority address, or vice-versa, using all available call opcodes without
    using `GAS` opcode (unavailable in EOF).
    """
    auth_signer = pre.fund_eoa(auth_account_start_balance)

    slot = count(1)
    slot_call_return_code = next(slot)
    slot_call_success = next(slot)

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

    call_set_code_to_address = Op.SSTORE(
        slot_call_return_code, call_opcode(address=set_code_to_address)
    )
    call_authority_address = Op.SSTORE(slot_call_return_code, call_opcode(address=auth_signer))

    callee_code = Bytecode()
    if set_code_address_first:
        callee_code += call_set_code_to_address + call_authority_address
    else:
        callee_code += call_authority_address + call_set_code_to_address
    callee_code += Op.SSTORE(slot_call_success, 1) + Op.STOP

    callee_address = pre.deploy_contract(callee_code)
    callee_storage = Storage()
    callee_storage[slot_call_return_code] = call_return_code(opcode=call_opcode, success=True)
    callee_storage[slot_call_success] = 1

    tx = Transaction(
        gas_limit=1_000_000,
        to=callee_address,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=0,
                signer=auth_signer,
            ),
        ],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            callee_address: Account(storage=callee_storage),
            auth_signer: Account(
                nonce=1,
                code=Spec.delegation_designation(set_code_to_address),
                balance=auth_account_start_balance,
            ),
        },
    )

Parametrized Test Cases

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

Test ID (Abbreviated) call_opcode evm_code_type set_code_address_first
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority STATICCALL LEGACY True
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address STATICCALL LEGACY False
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority STATICCALL LEGACY True
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address STATICCALL LEGACY False
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority DELEGATECALL LEGACY True
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address DELEGATECALL LEGACY False
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority DELEGATECALL LEGACY True
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address DELEGATECALL LEGACY False
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority CALL LEGACY True
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address CALL LEGACY False
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority CALL LEGACY True
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address CALL LEGACY False
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority CALLCODE LEGACY True
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address CALLCODE LEGACY False
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority CALLCODE LEGACY True
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address CALLCODE LEGACY False
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority STATICCALL LEGACY True
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address STATICCALL LEGACY False
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority STATICCALL LEGACY True
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address STATICCALL LEGACY False
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority DELEGATECALL LEGACY True
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address DELEGATECALL LEGACY False
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority DELEGATECALL LEGACY True
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address DELEGATECALL LEGACY False
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority CALL LEGACY True
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address CALL LEGACY False
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority CALL LEGACY True
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address CALL LEGACY False
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-call_set_code_address_first_then_authority CALLCODE LEGACY True
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-call_authority_first_then_set_code_address CALLCODE LEGACY False
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-call_set_code_address_first_then_authority CALLCODE LEGACY True
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-call_authority_first_then_set_code_address CALLCODE LEGACY False