Skip to content

test_set_code_to_tstore_available_at_correct_address()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_tstore_available_at_correct_address@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_to_tstore_available_at_correct_address --fork Osaka

Test TLOADing from slot 2 and then SSTORE this in slot 1, then TSTORE 3 in slot 2. This is done both from the EOA which is delegated to account A, and then A is called. The storage should stay empty on both the EOA and the delegated account.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
@pytest.mark.with_all_call_opcodes(
    selector=lambda call_opcode: call_opcode
    not in [Op.DELEGATECALL, Op.CALLCODE, Op.STATICCALL, Op.EXTDELEGATECALL, Op.EXTSTATICCALL]
)
@pytest.mark.parametrize("call_eoa_first", [True, False])
def test_set_code_to_tstore_available_at_correct_address(
    state_test: StateTestFiller,
    pre: Alloc,
    call_opcode: Op,
    call_eoa_first: bool,
) -> None:
    """
    Test TLOADing from slot 2 and then SSTORE this in slot 1, then TSTORE 3 in
    slot 2. This is done both from the EOA which is delegated to account A, and
    then A is called. The storage should stay empty on both the EOA and the
    delegated account.
    """
    auth_signer = pre.fund_eoa(auth_account_start_balance)

    storage_slot = 1
    tload_slot = 2
    tstore_value = 3

    tstore_check_code = Op.SSTORE(storage_slot, Op.TLOAD(tload_slot)) + Op.TSTORE(
        tload_slot, tstore_value
    )

    set_code_to_address = pre.deploy_contract(tstore_check_code)

    def make_call(call_type: Op, call_eoa: bool) -> Bytecode:
        call_target = auth_signer if call_eoa else set_code_to_address
        return call_type(address=call_target)

    chain_code = make_call(call_type=call_opcode, call_eoa=call_eoa_first) + make_call(
        call_type=call_opcode, call_eoa=not call_eoa_first
    )

    target_call_chain_address = pre.deploy_contract(chain_code)

    tx = Transaction(
        gas_limit=100_000,
        to=target_call_chain_address,
        value=0,
        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={
            auth_signer: Account(
                storage={storage_slot: 0},
            ),
            set_code_to_address: Account(
                storage={storage_slot: 0},
            ),
        },
    )

Parametrized Test Cases

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

Test ID (Abbreviated) call_opcode evm_code_type call_eoa_first
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_eoa_first_True CALL LEGACY True
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_eoa_first_False CALL LEGACY False
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_eoa_first_True CALL LEGACY True
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_eoa_first_False CALL LEGACY False
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_eoa_first_True CALL LEGACY True
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-call_eoa_first_False CALL LEGACY False
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_eoa_first_True CALL LEGACY True
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-call_eoa_first_False CALL LEGACY False