Skip to content

test_eofcreate_memory_context()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_memory_context@3719e927.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_memory_context --fork Osaka

Verifies an EOFCREATE frame enjoys a separate EVM memory from its caller frame.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
def test_eofcreate_memory_context(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Verifies an EOFCREATE frame enjoys a separate EVM memory from its caller frame."""
    env = Environment()
    destination_storage = Storage()
    contract_storage = Storage()
    initcontainer = Container(
        sections=[
            Section.Code(
                Op.SSTORE(destination_storage.store_next(value_code_worked), value_code_worked)
                + Op.SSTORE(destination_storage.store_next(0), Op.MSIZE())
                + Op.SSTORE(destination_storage.store_next(0), Op.MLOAD(0))
                + Op.MSTORE(0, 2)
                + Op.MSTORE(32, 2)
                + Op.RETURNCODE[0](0, 0)
            ),
            Section.Container(smallest_runtime_subcontainer),
        ]
    )
    contract_address = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    Op.SSTORE(contract_storage.store_next(value_code_worked), value_code_worked)
                    + Op.MSTORE(0, 1)
                    + Op.EOFCREATE[0](0, 0, 0, 0)
                    + Op.SSTORE(contract_storage.store_next(32), Op.MSIZE())
                    + Op.SSTORE(contract_storage.store_next(1), Op.MLOAD(0))
                    + Op.SSTORE(contract_storage.store_next(0), Op.MLOAD(32))
                    + Op.STOP,
                ),
                Section.Container(initcontainer),
            ],
        ),
    )
    destination_contract_address = compute_eofcreate_address(contract_address, 0)
    post = {
        contract_address: Account(storage=contract_storage),
        destination_contract_address: Account(storage=destination_storage),
    }
    tx = Transaction(
        to=contract_address,
        gas_limit=200_000,
        sender=pre.fund_eoa(),
    )
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test