Skip to content

Commit e2aeb75

Browse files
committed
tests: update eip7742 tests.
1 parent 2bb282e commit e2aeb75

File tree

4 files changed

+210
-177
lines changed

4 files changed

+210
-177
lines changed

tests/prague/eip7742_uncouple_blob_count/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ReferenceSpec:
2929
version: str
3030

3131

32-
ref_spec_7742 = ReferenceSpec("EIPS/eip-7742.md", "idonotknowwhatthisis")
32+
ref_spec_7742 = ReferenceSpec("EIPS/eip-7742.md", "54820d0d83b2369ac957bec6ee7deaeba1c1e4bb")
3333

3434

3535
@dataclass(frozen=True)

tests/prague/eip7742_uncouple_blob_count/test_invalid_cancun_blob_txs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_invalid_cancun_block_blob_count(
7171
post={},
7272
blocks=[block],
7373
genesis_environment=env,
74+
header_verify=block.header_verify,
7475
)
7576

7677

@@ -80,10 +81,10 @@ def test_invalid_cancun_block_blob_count(
8081
[0],
8182
[Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 1],
8283
],
83-
ids=["too_few_blobs", "too_many_blobs"],
84+
ids=["zero_blobs", "too_many_blobs"],
8485
)
85-
@pytest.mark.valid_until("Cancun")
86-
def test_invalid_tx_blob_count(
86+
@pytest.mark.valid_from("Prague")
87+
def test_invalid_cancun_tx_blob_count(
8788
state_test: StateTestFiller,
8889
state_env: Environment,
8990
pre: Alloc,

tests/prague/eip7742_uncouple_blob_count/test_uncoupled_blob_txs.py

Lines changed: 1 addition & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
Tests uncoupled blob txs for [EIP-7742: Uncouple blob count between CL and EL](https://eips.ethereum.org/EIPS/eip-7742)
44
""" # noqa: E501
55

6-
from typing import List, Optional
7-
86
import pytest
97

10-
from ethereum_test_tools import (
11-
Alloc,
12-
Block,
13-
BlockchainTestFiller,
14-
Environment,
15-
Hash,
16-
StateTestFiller,
17-
Transaction,
18-
add_kzg_version,
19-
)
8+
from ethereum_test_tools import Alloc, Environment, StateTestFiller, Transaction
209

2110
from .spec import Spec, ref_spec_7742
2211

@@ -92,164 +81,3 @@ def test_large_number_of_blobs_in_tx(
9281
tx=txs[0],
9382
env=state_env,
9483
)
95-
96-
97-
def multiple_blocks_with_blobs(
98-
txs: List[Transaction],
99-
blob_counts_per_block: List[int],
100-
tx_counts_per_block: Optional[List[int]] = None,
101-
) -> List[Block]:
102-
"""
103-
Creates multiple blocks with blob transactions. If `tx_counts_per_block` is not provided,
104-
it defaults to 1 transaction per block, resulting in multiple blocks with a single blob
105-
transaction.
106-
107-
Otherwise, the number of transactions in each block is specified by `tx_counts_per_block`.
108-
This means we will have multiple blocks with multiple blob transactions, where the number of
109-
blobs in each transaction is determined by the total blob count for the block.
110-
"""
111-
if tx_counts_per_block is None:
112-
tx_counts_per_block = [1] * len(blob_counts_per_block)
113-
114-
if len(blob_counts_per_block) != len(tx_counts_per_block):
115-
raise ValueError(
116-
"The lengths of `blob_counts_per_block` and `tx_counts_per_block` must match."
117-
)
118-
119-
blocks = []
120-
for block_index, (total_blob_count, tx_count) in enumerate(
121-
zip(blob_counts_per_block, tx_counts_per_block)
122-
):
123-
txs_in_block = []
124-
base_blobs_per_tx = total_blob_count // tx_count
125-
remaining_blobs = total_blob_count % tx_count
126-
127-
for tx_index in range(tx_count):
128-
tx = txs[0].copy()
129-
# Number of blobs for this transaction
130-
tx_blob_count = base_blobs_per_tx + (1 if tx_index < remaining_blobs else 0)
131-
# Create a list of blob hashes for this transaction
132-
blob_hashes = add_kzg_version(
133-
[Hash(block_index * 10000 + tx_index * 100 + i) for i in range(tx_blob_count)],
134-
Spec.BLOB_COMMITMENT_VERSION_KZG,
135-
)
136-
tx.blob_versioned_hashes = [Hash(b_hash) for b_hash in blob_hashes]
137-
txs_in_block.append(tx)
138-
139-
block = Block(txs=txs_in_block)
140-
blocks.append(block)
141-
142-
return blocks
143-
144-
145-
@pytest.mark.parametrize(
146-
"total_blob_counts, tx_counts_per_block, account_balance_modifier",
147-
[
148-
# 10 blobs over 2 txs, 20 blobs over 4 txs
149-
(
150-
[10, 20],
151-
[2, 4],
152-
10**18,
153-
),
154-
# 30 blobs over 3 txs, 60 blobs over 6 txs, 90 blobs over 9 txs
155-
(
156-
[30, 60, 90],
157-
[3, 6, 9],
158-
10**18,
159-
),
160-
# 50 blobs over 5 txs, 100 blobs over 10 txs, 150 blobs over 15 txs, 200 blobs over 20 txs
161-
(
162-
[50, 100, 150, 200],
163-
[5, 10, 15, 20],
164-
10**18,
165-
),
166-
],
167-
)
168-
@pytest.mark.valid_from("Prague")
169-
def test_multiple_blocks_varied_blobs(
170-
blockchain_test: BlockchainTestFiller,
171-
pre: Alloc,
172-
env: Environment,
173-
txs: List[Transaction],
174-
total_blob_counts: List[int],
175-
tx_counts_per_block: List[int],
176-
):
177-
"""
178-
Test multiple blocks with varied transactions and blob counts per block.
179-
"""
180-
blockchain_test(
181-
pre=pre,
182-
post={},
183-
blocks=multiple_blocks_with_blobs(txs, total_blob_counts, tx_counts_per_block),
184-
genesis_environment=env,
185-
)
186-
187-
188-
@pytest.mark.parametrize(
189-
"blob_counts_per_block, tx_counts_per_block, account_balance_modifier",
190-
[
191-
# Incremental 1: 0 to 64 blobs, 1 tx per block, 64 blocks
192-
(
193-
[i for i in range(65)],
194-
[1] * 65,
195-
10**18,
196-
),
197-
# Incremental 2: 0 to 256 blobs, 10 txs per block, 26 blocks
198-
(
199-
[i * 10 for i in range(26)],
200-
[10] * 26,
201-
10**18,
202-
),
203-
# Decremental 1: 64 to 0 blobs, 1 tx per block, 64 blocks
204-
(
205-
[i for i in reversed(range(65))],
206-
[1] * 65,
207-
10**18,
208-
),
209-
# Decremental 2: 256 to 0 blobs, 10 txs per block, 26 blocks
210-
(
211-
[i * 10 for i in reversed(range(26))],
212-
[10] * 26,
213-
10**18,
214-
),
215-
# Incremental then decremental 1: 0 to 64 to 0 blobs, 1 tx per block, 130 blocks
216-
(
217-
[i for i in range(65)] + [i for i in reversed(range(65))],
218-
[1] * 130,
219-
10**18,
220-
),
221-
# Decremental then incremental 1: 64 to 0 to 64 blobs, 1 tx per block, 130 blocks
222-
(
223-
[i for i in reversed(range(65))] + [i for i in range(65)],
224-
[1] * 130,
225-
10**18,
226-
),
227-
],
228-
ids=[
229-
"incremental_1_tx",
230-
"incremental_10_txs",
231-
"decremental_1_tx",
232-
"decremental_10_txs",
233-
"incremental_then_decremental",
234-
"decremental_then_incremental",
235-
],
236-
)
237-
@pytest.mark.valid_from("Prague")
238-
def test_multi_blocks_incremental_decremental(
239-
blockchain_test: BlockchainTestFiller,
240-
pre: Alloc,
241-
env: Environment,
242-
txs: List[Transaction],
243-
blob_counts_per_block: List[int],
244-
tx_counts_per_block: List[int],
245-
):
246-
"""
247-
Test multiple blocks with incremental, decremental, and ascending-then-descending
248-
blob counts per block.
249-
"""
250-
blockchain_test(
251-
pre=pre,
252-
post={},
253-
blocks=multiple_blocks_with_blobs(txs, blob_counts_per_block, tx_counts_per_block),
254-
genesis_environment=env,
255-
)

0 commit comments

Comments
 (0)