Skip to content

test_set_code_to_tstore_reentry()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_to_tstore_reentry@e9958ed2.

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_reentry --fork Osaka

Test the executing a simple TSTORE in a set-code transaction, which also performs a re-entry to TLOAD the value.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
@pytest.mark.parametrize(
    "return_opcode",
    [
        Op.RETURN,
        Op.REVERT,
    ],
)
@pytest.mark.with_all_call_opcodes
def test_set_code_to_tstore_reentry(
    state_test: StateTestFiller,
    pre: Alloc,
    call_opcode: Op,
    return_opcode: Op,
    evm_code_type: EVMCodeType,
) -> None:
    """
    Test the executing a simple TSTORE in a set-code transaction, which also
    performs a re-entry to TLOAD the value.
    """
    auth_signer = pre.fund_eoa(auth_account_start_balance)

    tload_value = 0x1234
    set_code = Conditional(
        condition=Op.ISZERO(Op.TLOAD(1)),
        if_true=Op.TSTORE(1, tload_value)
        + call_opcode(address=Op.ADDRESS)
        + Op.RETURNDATACOPY(0, 0, 32)
        + Op.SSTORE(2, Op.MLOAD(0)),
        if_false=Op.MSTORE(0, Op.TLOAD(1)) + return_opcode(size=32),
        evm_code_type=evm_code_type,
    )
    set_code_to_address = pre.deploy_contract(set_code)

    tx = Transaction(
        gas_limit=100_000,
        to=auth_signer,
        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(
                nonce=1,
                code=Spec.delegation_designation(set_code_to_address),
                storage={2: tload_value},
            ),
        },
    )

Parametrized Test Cases

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

Test ID (Abbreviated) call_opcode evm_code_type return_opcode
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-return_opcode_RETURN STATICCALL LEGACY RETURN
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-return_opcode_REVERT STATICCALL LEGACY REVERT
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN STATICCALL LEGACY RETURN
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT STATICCALL LEGACY REVERT
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-return_opcode_RETURN DELEGATECALL LEGACY RETURN
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-return_opcode_REVERT DELEGATECALL LEGACY REVERT
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN DELEGATECALL LEGACY RETURN
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT DELEGATECALL LEGACY REVERT
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-return_opcode_RETURN CALL LEGACY RETURN
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-return_opcode_REVERT CALL LEGACY REVERT
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN CALL LEGACY RETURN
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT CALL LEGACY REVERT
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-return_opcode_RETURN CALLCODE LEGACY RETURN
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-return_opcode_REVERT CALLCODE LEGACY REVERT
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN CALLCODE LEGACY RETURN
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT CALLCODE LEGACY REVERT
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-return_opcode_RETURN STATICCALL LEGACY RETURN
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-return_opcode_REVERT STATICCALL LEGACY REVERT
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN STATICCALL LEGACY RETURN
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT STATICCALL LEGACY REVERT
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-return_opcode_RETURN DELEGATECALL LEGACY RETURN
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-return_opcode_REVERT DELEGATECALL LEGACY REVERT
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN DELEGATECALL LEGACY RETURN
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT DELEGATECALL LEGACY REVERT
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-return_opcode_RETURN CALL LEGACY RETURN
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-return_opcode_REVERT CALL LEGACY REVERT
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN CALL LEGACY RETURN
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT CALL LEGACY REVERT
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-return_opcode_RETURN CALLCODE LEGACY RETURN
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-return_opcode_REVERT CALLCODE LEGACY REVERT
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_RETURN CALLCODE LEGACY RETURN
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test-return_opcode_REVERT CALLCODE LEGACY REVERT