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@21fb11c8.

Generate fixtures for these test cases for Prague 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 Prague

Test set to code address and authority warm status after a call to authority address, or viceversa, 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
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
@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,
):
    """
    Test set to code address and authority warm status after a call to
    authority address, or viceversa, 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_EXTCALL-evm_code_type_EOF_V1-state_test-call_set_code_address_first_then_authority EXTCALL EOF_V1 True
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-state_test-call_authority_first_then_set_code_address EXTCALL EOF_V1 False
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-blockchain_test_from_state_test-call_set_code_address_first_then_authority EXTCALL EOF_V1 True
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-blockchain_test_from_state_test-call_authority_first_then_set_code_address EXTCALL EOF_V1 False
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-state_test-call_set_code_address_first_then_authority EXTSTATICCALL EOF_V1 True
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-state_test-call_authority_first_then_set_code_address EXTSTATICCALL EOF_V1 False
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-blockchain_test_from_state_test-call_set_code_address_first_then_authority EXTSTATICCALL EOF_V1 True
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-blockchain_test_from_state_test-call_authority_first_then_set_code_address EXTSTATICCALL EOF_V1 False
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-state_test-call_set_code_address_first_then_authority EXTDELEGATECALL EOF_V1 True
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-state_test-call_authority_first_then_set_code_address EXTDELEGATECALL EOF_V1 False
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-blockchain_test_from_state_test-call_set_code_address_first_then_authority EXTDELEGATECALL EOF_V1 True
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-blockchain_test_from_state_test-call_authority_first_then_set_code_address EXTDELEGATECALL EOF_V1 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