Skip to content

Test Mcopy Contexts

Documentation for tests/cancun/eip5656_mcopy/test_mcopy_contexts.py.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip5656_mcopy/test_mcopy_contexts.py --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version
For all forks up to and including Cancun:
fill -v tests/cancun/eip5656_mcopy/test_mcopy_contexts.py --until=Cancun --evm-bin=/path/to/evm-tool-dev-version

abstract: Tests EIP-5656: MCOPY - Memory copying instruction

Test memory copy under different call contexts [EIP-5656: MCOPY - Memory copying instruction](https://eips.ethereum.org/EIPS/eip-5656)

test_no_memory_corruption_on_upper_call_stack_levels(state_test, pre, post, tx)

Perform a subcall with any of the following opcodes, which uses MCOPY during its execution, and verify that the caller's memory is unaffected: - CALL - CALLCODE - DELEGATECALL - STATICCALL - CREATE - CREATE2

Source code in tests/cancun/eip5656_mcopy/test_mcopy_contexts.py
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@pytest.mark.parametrize(
    "opcode",
    [
        Op.CALL,
        Op.DELEGATECALL,
        Op.STATICCALL,
        Op.CALLCODE,
        Op.CREATE,
        Op.CREATE2,
    ],
)
@pytest.mark.valid_from("Cancun")
def test_no_memory_corruption_on_upper_call_stack_levels(
    state_test: StateTestFiller,
    pre: Mapping[str, Account],
    post: Mapping[str, Account],
    tx: Transaction,
):
    """
    Perform a subcall with any of the following opcodes, which uses MCOPY during its execution,
    and verify that the caller's memory is unaffected:
      - `CALL`
      - `CALLCODE`
      - `DELEGATECALL`
      - `STATICCALL`
      - `CREATE`
      - `CREATE2`
    """
    state_test(
        env=Environment(),
        pre=pre,
        post=post,
        txs=[tx],
    )