Skip to content

test_calldata()

Documentation for tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py::test_calldata@v4.4.0.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py::test_calldata --fork Osaka

Verifies CALLDATA passing through TXCREATE.

Source code in tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
@pytest.mark.with_all_evm_code_types
def test_calldata(state_test: StateTestFiller, pre: Alloc):
    """Verifies CALLDATA passing through TXCREATE."""
    env = Environment()

    initcode_subcontainer = Container(
        name="Initcode Subcontainer",
        sections=[
            Section.Code(
                code=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
                + Op.SSTORE(slot_calldata, Op.MLOAD(0))
                + Op.RETURNCODE[0](0, Op.CALLDATASIZE),
            ),
            Section.Container(container=smallest_runtime_subcontainer),
        ],
    )
    initcode_hash = initcode_subcontainer.hash

    calldata_size = 32
    calldata = b"\x45" * calldata_size
    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=Op.MSTORE(0, Op.PUSH32(calldata))
        + Op.SSTORE(
            slot_create_address,
            Op.TXCREATE(tx_initcode_hash=initcode_hash, input_size=calldata_size),
        )
        + Op.STOP,
    )

    # deployed contract is smallest plus data
    deployed_contract = Container(
        name="deployed contract",
        sections=[
            *smallest_runtime_subcontainer.sections,
            Section.Data(data=calldata),
        ],
    )
    # factory contract Storage in 0 should have the created address,
    # created contract storage in 0 should have the calldata
    created_address = compute_eofcreate_address(contract_address, 0)
    post = {
        contract_address: Account(storage={slot_create_address: created_address}),
        created_address: Account(code=deployed_contract, storage={slot_calldata: calldata}),
    }

    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        sender=sender,
        initcodes=[initcode_subcontainer],
    )

    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

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

Test ID (Abbreviated) evm_code_type
...fork_Osaka-evm_code_type_LEGACY-state_test LEGACY
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test LEGACY
...fork_Osaka-evm_code_type_EOF_V1-state_test EOF_V1
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test EOF_V1