Skip to content

test_returndatacopy_oob()

Documentation for tests/prague/eip7692_eof_v1/eip7069_extcall/test_returndataload.py::test_returndatacopy_oob@verkle@v0.0.6.

Generate fixtures for these test cases for Pragueeip7692 with:

Pragueeip7692 only:

fill -v tests/prague/eip7692_eof_v1/eip7069_extcall/test_returndataload.py::test_returndatacopy_oob --fork=PragueEIP7692 --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Pragueeip7692:

fill -v tests/prague/eip7692_eof_v1/eip7069_extcall/test_returndataload.py::test_returndatacopy_oob --until=PragueEIP7692

Extends the RETURNDATACOPY test for correct out-of-bounds behavior, by checking if the caller frame's context being EOF or legacy doesn't impact the execution logic of the RETURNDATACOPY instance under test.

Source code in tests/prague/eip7692_eof_v1/eip7069_extcall/test_returndataload.py
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
@pytest.mark.parametrize(
    "opcode",
    [
        Op.CALL,
        Op.EXTCALL,
    ],
)
def test_returndatacopy_oob(
    state_test: StateTestFiller,
    pre: Alloc,
    opcode: Op,
):
    """
    Extends the RETURNDATACOPY test for correct out-of-bounds behavior, by checking if the
    caller frame's context being EOF or legacy doesn't impact the execution logic of the
    RETURNDATACOPY instance under test.
    """
    env = Environment()

    sender = pre.fund_eoa()

    # Both callee codes below make an OOB (out-of-bounds) RETURNDATACOPY of one byte,
    # which they then attempt to return (Legacy should exceptionally halt on RETURNDATACOPY).
    address_callee_eof = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    code=Op.RETURNDATACOPY(0, 0, 1) + Op.RETURN(0, 1),
                    max_stack_height=3,
                )
            ]
        )
    )
    address_callee_legacy = pre.deploy_contract(Op.RETURNDATACOPY(0, 0, 1) + Op.RETURN(0, 1))

    # Caller code is selected to either be Legacy or EOF using params.
    code_entry_point = (
        Op.SSTORE(slot_eof_target_call_status, opcode(address=address_callee_eof))
        + Op.SSTORE(slot_eof_target_returndatasize, Op.RETURNDATASIZE)
        + Op.SSTORE(slot_eof_target_returndata, Op.RETURNDATACOPY(0, 0, 1) + Op.MLOAD(0))
        + Op.SSTORE(
            slot_legacy_target_call_status,
            opcode(address=address_callee_legacy),
        )
        + Op.SSTORE(slot_legacy_target_returndatasize, Op.RETURNDATASIZE)
        + Op.STOP
    )

    storage_entry_point = Storage(
        {
            slot_eof_target_call_status: value_exceptional_abort_canary,
            slot_eof_target_returndata: value_exceptional_abort_canary,
            slot_eof_target_returndatasize: value_exceptional_abort_canary,
            slot_legacy_target_call_status: value_exceptional_abort_canary,
            slot_legacy_target_returndatasize: value_exceptional_abort_canary,
        }
    )

    address_entry_point = (
        pre.deploy_contract(code=code_entry_point, storage=storage_entry_point)
        if opcode == Op.CALL
        else pre.deploy_contract(
            Container(
                sections=[
                    Section.Code(
                        code=code_entry_point,
                        max_stack_height=4,
                        storage=storage_entry_point,
                    )
                ]
            )
        )
    )

    tx = Transaction(to=address_entry_point, gas_limit=2_000_000, sender=sender)

    post = {
        address_entry_point: Account(
            storage={
                slot_eof_target_call_status: LEGACY_CALL_SUCCESS,
                slot_eof_target_returndata: "0x00",
                slot_eof_target_returndatasize: "0x01",
                slot_legacy_target_call_status: LEGACY_CALL_FAILURE,
                slot_legacy_target_returndatasize: "0x00",
            }
            if opcode == Op.CALL
            else {
                slot_eof_target_call_status: EXTCALL_SUCCESS,
                slot_eof_target_returndata: "0x00",
                slot_eof_target_returndatasize: "0x01",
                slot_legacy_target_call_status: EXTCALL_FAILURE,
                slot_legacy_target_returndatasize: "0x00",
            }
        )
    }

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

Parametrized Test Cases

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

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID opcode
opcode_CALL CALL
opcode_EXTCALL EXTCALL
opcode_CALL CALL
opcode_EXTCALL EXTCALL