Skip to content

test_tstore_clear_after_deployment_tx()

Documentation for tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py::test_tstore_clear_after_deployment_tx@83970623.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py::test_tstore_clear_after_deployment_tx --fork Prague

First creates a contract, which TSTOREs a value 1 in slot 1. After creating the contract, a new tx will call this contract, storing TLOAD(1) into slot 1. The transient storage should be cleared after creating the contract (at tx-level), so the storage should stay empty.

Source code in tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@pytest.mark.valid_from("Cancun")
@pytest.mark.with_all_evm_code_types
def test_tstore_clear_after_deployment_tx(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    evm_code_type: EVMCodeType,
):
    """
    First creates a contract, which TSTOREs a value 1 in slot 1.
    After creating the contract, a new tx will call this contract, storing TLOAD(1) into slot 1.
    The transient storage should be cleared after creating the contract (at tx-level), so
    the storage should stay empty.
    """
    env = Environment()

    init_code = Op.TSTORE(1, 1)
    deploy_code = Op.SSTORE(1, Op.TLOAD(1))

    code: Optional[Container | Initcode] = None
    if evm_code_type == EVMCodeType.EOF_V1:
        code = Container.Init(
            deploy_container=Container.Code(deploy_code + Op.STOP), initcode_prefix=init_code
        )
    else:
        code = Initcode(deploy_code=deploy_code, initcode_prefix=init_code)

    sender = pre.fund_eoa()

    deployment_tx = Transaction(
        gas_limit=100000,
        data=code,
        to=None,
        sender=sender,
    )

    address = deployment_tx.created_contract

    invoke_contract_tx = Transaction(gas_limit=100000, to=address, sender=sender)

    txs = [deployment_tx, invoke_contract_tx]

    post = {
        address: Account(storage={0x01: 0x00}),
    }

    blockchain_test(genesis_environment=env, pre=pre, post=post, blocks=[Block(txs=txs)])

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) evm_code_type
...fork_Cancun-evm_code_type_LEGACY-blockchain_test LEGACY
...fork_Prague-evm_code_type_LEGACY-blockchain_test LEGACY
...fork_Osaka-evm_code_type_LEGACY-blockchain_test LEGACY
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test EOF_V1