Skip to content

test_eip_2935()

Documentation for tests/prague/eip2935_historical_block_hashes_from_state/test_eip_mainnet.py::test_eip_2935@e9958ed2.

Generate fixtures for these test cases for Osaka with:

fill -v tests/prague/eip2935_historical_block_hashes_from_state/test_eip_mainnet.py::test_eip_2935 --fork Osaka

Test a simple block hash request from EIP-2935 system contract.

Source code in tests/prague/eip2935_historical_block_hashes_from_state/test_eip_mainnet.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def test_eip_2935(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """Test a simple block hash request from EIP-2935 system contract."""
    check_block_number = Op.SUB(Op.NUMBER, 1)  # Parent block number
    check_contract_code = (
        Op.MSTORE(0, check_block_number)
        + Op.POP(
            Op.CALL(
                address=Spec.HISTORY_STORAGE_ADDRESS,
                args_offset=0,
                args_size=32,
                ret_offset=32,
                ret_size=32,
            )
        )
        + Op.SSTORE(0, Op.EQ(Op.MLOAD(32), Op.BLOCKHASH(check_block_number)))
    )
    check_contract_address = pre.deploy_contract(check_contract_code)
    tx = Transaction(
        to=check_contract_address,
        gas_limit=50_000,
        sender=pre.fund_eoa(),
    )
    block = Block(txs=[tx])
    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            check_contract_address: Account(storage={0: 1}),
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated)
...fork_Prague-blockchain_test