Skip to content

test_bal_noop_write_filtering()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py::test_bal_noop_write_filtering@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py::test_bal_noop_write_filtering --fork Amsterdam

Test that NOOP writes (writing same value or 0 to empty) are filtered.

This verifies that: 1. Writing 0 to an uninitialized slot doesn't appear in BAL 2. Writing the same value to a slot doesn't appear in BAL 3. Only actual changes are tracked

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
def test_bal_noop_write_filtering(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Test that NOOP writes (writing same value or 0 to empty) are filtered.

    This verifies that:
    1. Writing 0 to an uninitialized slot doesn't appear in BAL
    2. Writing the same value to a slot doesn't appear in BAL
    3. Only actual changes are tracked
    """
    test_code = Bytecode(
        # Write 0 to uninitialized slot 1 (noop)
        Op.SSTORE(1, 0)
        # Write 42 to slot 2
        + Op.SSTORE(2, 42)
        # Write 100 to slot 3 (will be same as pre-state, should be filtered)
        + Op.SSTORE(3, 100)
        # Write 200 to slot 4 (different from pre-state 150, should appear)
        + Op.SSTORE(4, 200)
    )

    sender = pre.fund_eoa()
    test_address = pre.deploy_contract(
        code=test_code,
        storage={3: 100, 4: 150},
    )

    tx = Transaction(
        sender=sender,
        to=test_address,
        gas_limit=100_000,
    )

    # Expected BAL should only show actual changes
    expected_block_access_list = BlockAccessListExpectation(
        account_expectations={
            test_address: BalAccountExpectation(
                storage_changes=[
                    BalStorageSlot(
                        slot=2,
                        slot_changes=[
                            BalStorageChange(
                                block_access_index=1, post_value=42
                            ),
                        ],
                    ),
                    BalStorageSlot(
                        slot=4,
                        slot_changes=[
                            BalStorageChange(
                                block_access_index=1, post_value=200
                            ),
                        ],
                    ),
                ],
            ),
        }
    )

    block = Block(
        txs=[tx],
        expected_block_access_list=expected_block_access_list,
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            test_address: Account(storage={2: 42, 3: 100, 4: 200}),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.