Skip to content

test_nested_calls_reservoir_passing()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_nested_calls_reservoir_passing@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_nested_calls_reservoir_passing --fork Amsterdam

Test reservoir passes through nested calls.

The reservoir is passed from A to B to C. C performs an SSTORE using the reservoir gas. After all calls return, A verifies success.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
@pytest.mark.valid_from("EIP8037")
def test_nested_calls_reservoir_passing(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test reservoir passes through nested calls.

    The reservoir is passed from A to B to C. C performs an SSTORE
    using the reservoir gas. After all calls return, A verifies
    success.
    """
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    c_storage = Storage()
    c = pre.deploy_contract(
        code=Op.SSTORE(c_storage.store_next(1), 1),
    )

    b = pre.deploy_contract(
        code=Op.CALL(gas=200_000, address=c),
    )

    a_storage = Storage()
    a = pre.deploy_contract(
        code=(
            Op.SSTORE(
                a_storage.store_next(1),
                Op.CALL(gas=300_000, address=b),
            )
        ),
    )

    tx = Transaction(
        to=a,
        state_gas_reservoir=sstore_state_gas,
        sender=pre.fund_eoa(),
    )

    post = {
        a: Account(storage=a_storage),
        c: Account(storage=c_storage),
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.