Skip to content

test_bal_2935_simple()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip2935.py::test_bal_2935_simple@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip2935.py::test_bal_2935_simple --fork Amsterdam

Ensure BAL captures history storage writes during system call.

Block with 2 normal user transactions: Alice sends 10 wei to Charlie, Bob sends 10 wei to Charlie. At block start (pre-execution), SYSTEM_ADDRESS calls HISTORY_STORAGE_ADDRESS to store parent block hash.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip2935.py
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
def test_bal_2935_simple(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    fork: Fork,
) -> None:
    """
    Ensure BAL captures history storage writes during system call.

    Block with 2 normal user transactions: Alice sends 10 wei to Charlie,
    Bob sends 10 wei to Charlie. At block start (pre-execution),
    SYSTEM_ADDRESS calls HISTORY_STORAGE_ADDRESS to store parent block hash.
    """
    alice = pre.fund_eoa()
    bob = pre.fund_eoa()
    charlie = pre.fund_eoa(amount=0)

    transfer_value = 10

    tx1 = Transaction(
        sender=alice,
        to=charlie,
        value=transfer_value,
        gas_limit=fork.transaction_gas_limit_cap(),
    )

    tx2 = Transaction(
        sender=bob,
        to=charlie,
        value=transfer_value,
        gas_limit=fork.transaction_gas_limit_cap(),
    )

    account_expectations = block_hash_system_call_expectations(0)

    account_expectations[alice] = BalAccountExpectation(
        nonce_changes=[BalNonceChange(block_access_index=1, post_nonce=1)],
    )
    account_expectations[bob] = BalAccountExpectation(
        nonce_changes=[BalNonceChange(block_access_index=2, post_nonce=1)],
    )
    account_expectations[charlie] = BalAccountExpectation(
        balance_changes=[
            BalBalanceChange(
                block_access_index=1, post_balance=transfer_value
            ),
            BalBalanceChange(
                block_access_index=2, post_balance=transfer_value * 2
            ),
        ],
    )
    block = Block(
        txs=[tx1, tx2],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations=account_expectations
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            alice: Account(nonce=1),
            bob: Account(nonce=1),
            charlie: Account(balance=transfer_value * 2),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.