Skip to content

test_bal_system_dequeue_consolidations_eip7251()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7251.py::test_bal_system_dequeue_consolidations_eip7251@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7251.py::test_bal_system_dequeue_consolidations_eip7251 --fork Amsterdam

Test making a consolidation request to the beacon chain.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7251.py
 47
 48
 49
 50
 51
 52
 53
 54
 55
 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
@pytest.mark.parametrize(
    "blocks_consolidation_requests",
    [
        pytest.param(
            [
                ConsolidationRequestTransaction(
                    requests=[
                        ConsolidationRequest(
                            source_pubkey=0x01,
                            target_pubkey=0x02,
                            fee=Spec.get_fee(0),
                        )
                    ],
                )
            ],
            id="single_block_single_consolidation_request_from_eoa",
        ),
        pytest.param(
            [
                ConsolidationRequestTransaction(
                    requests=[
                        ConsolidationRequest(
                            source_pubkey=i * 2 + 1,
                            target_pubkey=i * 2 + 2,
                            fee=Spec.get_fee(0),
                        )
                    ],
                )
                for i in range(MAX_CONSOLIDATION_REQUESTS_PER_BLOCK)
            ],
            id="single_block_max_consolidation_per_block",
        ),
        pytest.param(
            [
                ConsolidationRequestTransaction(
                    requests=[
                        ConsolidationRequest(
                            source_pubkey=i * 2 + 1,
                            target_pubkey=i * 2 + 2,
                            fee=Spec.get_fee(0),
                        )
                    ],
                )
                for i in range(MAX_CONSOLIDATION_REQUESTS_PER_BLOCK + 1)
            ],
            id="single_block_max_consolidation_per_block_plus1",
        ),
    ],
)
def test_bal_system_dequeue_consolidations_eip7251(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    blocks_consolidation_requests: List[ConsolidationRequestTransaction],
) -> None:
    """Test making a consolidation request to the beacon chain."""
    txs = []

    for request in blocks_consolidation_requests:
        prepared = request.update_pre(pre=pre)
        txs += prepared.transactions()

    num = len(txs)

    count_slot_changes = []
    head_slot_changes = []
    tail_slot_changes = []

    for idx, _ in enumerate(txs):
        count_slot_changes.append(
            BalStorageChange(block_access_index=idx + 1, post_value=idx + 1)
        )

        tail_slot_changes.append(
            BalStorageChange(block_access_index=idx + 1, post_value=idx + 1)
        )

    # Count slot is always reset to zero after request processing
    count_slot_changes.append(
        BalStorageChange(block_access_index=num + 1, post_value=0)
    )

    if num > MAX_CONSOLIDATION_REQUESTS_PER_BLOCK:
        head_slot_changes.append(
            BalStorageChange(
                block_access_index=num + 1,
                post_value=MAX_CONSOLIDATION_REQUESTS_PER_BLOCK,
            )
        )
    else:
        tail_slot_changes.append(
            BalStorageChange(block_access_index=num + 1, post_value=0)
        )

    storage_changes = []
    if any(count_slot_changes):
        storage_changes.append(
            BalStorageSlot(
                slot=CONSOLIDATION_REQUEST_COUNT_STORAGE_SLOT,
                slot_changes=count_slot_changes,
            )
        )

    if any(head_slot_changes):
        storage_changes.append(
            BalStorageSlot(
                slot=CONSOLIDATION_REQUEST_QUEUE_HEAD_STORAGE_SLOT,
                slot_changes=head_slot_changes,
            )
        )

    if any(tail_slot_changes):
        storage_changes.append(
            BalStorageSlot(
                slot=CONSOLIDATION_REQUEST_QUEUE_TAIL_STORAGE_SLOT,
                slot_changes=tail_slot_changes,
            )
        )

    block = Block(
        txs=txs,
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS: (
                    BalAccountExpectation(storage_changes=storage_changes)
                )
            }
        ),
    )

    blockchain_test(
        genesis_environment=Environment(),
        pre=pre,
        post={},
        blocks=[block],
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 1 fork.