Skip to content

test_access_list_warm_savings_stay_execution()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_reservoir.py::test_access_list_warm_savings_stay_execution@8acae1b0.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_reservoir.py::test_access_list_warm_savings_stay_execution --fork Amsterdam

Verify access-list warm savings stay in execution gas.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_reservoir.py
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
@pytest.mark.valid_from("EIP8037")
def test_access_list_warm_savings_stay_execution(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """Verify access-list warm savings stay in execution gas."""
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    contract = pre.deploy_contract(
        code=Op.SSTORE(0, Op.SLOAD(0)),
        storage={0: 1},
    )

    access_list = [AccessList(address=contract, storage_keys=[0])]

    intrinsic_calc = fork.transaction_intrinsic_cost_calculator()
    intrinsic_gas = intrinsic_calc(access_list=access_list)

    contract_code = Op.SSTORE.with_metadata(
        key_warm=True,
        original_value=1,
        current_value=1,
        new_value=1,
    )(0, Op.SLOAD.with_metadata(key_warm=True)(0))
    evm_gas = contract_code.gas_cost(fork)

    expected_gas_used = intrinsic_gas + evm_gas

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

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                header_verify=Header(gas_used=expected_gas_used),
            ),
        ],
        post={contract: Account(storage={0: 1})},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.