1
1
"""
2
- abstract: Tests get blobs engine endpoint for [EIP-4844: Shard Blob Transactions ](https://eips.ethereum.org/EIPS/eip-4844 )
3
- Test get blobs engine endpoint for [EIP-4844: Shard Blob Transactions ](https://eips.ethereum.org/EIPS/eip-4844 ).
2
+ abstract: Tests get blobs engine endpoint for [EIP-7594: PeerDAS - Peer Data Availability Sampling ](https://eips.ethereum.org/EIPS/eip-7594 )
3
+ Test get blobs engine endpoint for [EIP-7594: PeerDAS - Peer Data Availability Sampling ](https://eips.ethereum.org/EIPS/eip-7594 ).
4
4
5
5
""" # noqa: E501
6
6
7
7
from typing import List , Optional
8
8
9
9
import pytest
10
+ from hive .client import ClientType
10
11
11
- from ethereum_test_forks import Fork
12
+ from ethereum_test_forks import Fork , Osaka
12
13
from ethereum_test_tools import (
13
14
Address ,
14
15
Alloc ,
15
16
Blob ,
16
17
BlobsTestFiller ,
17
18
NetworkWrappedTransaction ,
18
19
Transaction ,
19
- TransactionException ,
20
20
)
21
21
22
22
from ...cancun .eip4844_blobs .common import INF_POINT
@@ -137,33 +137,27 @@ def tx_max_fee_per_blob_gas( # noqa: D103
137
137
return blob_gas_price
138
138
139
139
140
- @pytest .fixture
141
- def tx_error () -> Optional [TransactionException ]:
142
- """
143
- Even though the final block we are producing in each of these tests is invalid, and some of the
144
- transactions will be invalid due to the format in the final block, none of the transactions
145
- should be rejected by the transition tool because they are being sent to it with the correct
146
- format.
147
- """
148
- return None
149
-
150
-
151
140
@pytest .fixture
152
141
def tx_wrapper_version () -> int | None :
153
142
"""Return wrapper version used for the transactions sent during test."""
154
143
return 1
155
144
156
145
146
+ @pytest .fixture
147
+ def txs_blobs (id_matcher ) -> List [List [Blob ]]:
148
+ """Extract blobs from the resolved test case."""
149
+ return id_matcher .values [0 ]
150
+
151
+
157
152
@pytest .fixture (autouse = True )
158
- def txs ( # noqa: D103
153
+ def txs (
159
154
pre : Alloc ,
160
155
destination_account : Optional [Address ],
161
156
tx_gas : int ,
162
157
tx_value : int ,
163
158
tx_calldata : bytes ,
164
159
tx_max_fee_per_blob_gas : int ,
165
160
txs_versioned_hashes : List [List [bytes ]],
166
- tx_error : Optional [TransactionException ],
167
161
txs_blobs : List [List [Blob ]],
168
162
tx_wrapper_version : int | None ,
169
163
) -> List [NetworkWrappedTransaction | Transaction ]:
@@ -182,7 +176,6 @@ def txs( # noqa: D103
182
176
max_fee_per_blob_gas = tx_max_fee_per_blob_gas ,
183
177
access_list = [],
184
178
blob_versioned_hashes = tx_versioned_hashes ,
185
- error = tx_error ,
186
179
)
187
180
network_wrapped_tx = NetworkWrappedTransaction (
188
181
tx = tx ,
@@ -193,15 +186,26 @@ def txs( # noqa: D103
193
186
return txs
194
187
195
188
189
+ def get_max_blobs_per_tx (fork : Fork , client_type : Optional [ClientType ] = None ) -> int :
190
+ """Get max blobs per tx considering both fork and client."""
191
+ # https://github.com/ethereum/go-ethereum/issues/31792
192
+ # https://github.com/ethereum/go-ethereum/pull/31837
193
+ if client_type and "go-ethereum" in client_type .name and fork >= Osaka :
194
+ return 7
195
+ return fork .max_blobs_per_block ()
196
+
197
+
196
198
def generate_full_blob_tests (
197
199
fork : Fork ,
200
+ client_type : Optional [ClientType ] = None ,
198
201
) -> List :
199
202
"""
200
203
Return a list of tests for invalid blob transactions due to insufficient max fee per blob gas
201
204
parametrized for each different fork.
202
205
"""
203
206
blob_size = Spec4844 .FIELD_ELEMENTS_PER_BLOB * SpecHelpers .BYTES_PER_FIELD_ELEMENT
204
- max_blobs = fork .max_blobs_per_block ()
207
+ max_blobs_per_block = fork .max_blobs_per_block ()
208
+ max_blobs_per_tx = get_max_blobs_per_tx (fork , client_type )
205
209
return [
206
210
pytest .param (
207
211
[ # Txs
@@ -223,7 +227,7 @@ def generate_full_blob_tests(
223
227
kzg_commitment = INF_POINT ,
224
228
kzg_cell_proofs = [INF_POINT ] * CELLS_PER_EXT_BLOB ,
225
229
)
226
- for _ in range (max_blobs )
230
+ for _ in range (max_blobs_per_tx )
227
231
]
228
232
],
229
233
id = "max_blobs_transaction" ,
@@ -237,18 +241,36 @@ def generate_full_blob_tests(
237
241
kzg_cell_proofs = [INF_POINT ] * CELLS_PER_EXT_BLOB ,
238
242
)
239
243
]
240
- for _ in range (max_blobs )
244
+ for _ in range (max_blobs_per_block )
241
245
],
242
246
id = "single_blob_max_txs" ,
243
247
),
244
248
]
245
249
246
250
247
- @pytest .mark .parametrize_by_fork (
248
- "txs_blobs" ,
249
- generate_full_blob_tests ,
251
+ @pytest .fixture
252
+ def id_matcher (request , fork : Fork , client_type : ClientType ):
253
+ """
254
+ Match test case ID to actual test case for client aware test execution.
255
+ This runs at test execution time when we have access to both the fork and client type.
256
+ """
257
+ requested_id = request .param
258
+ all_test_cases = generate_full_blob_tests (fork , client_type )
259
+ for test_case in all_test_cases :
260
+ if test_case .id == requested_id :
261
+ return test_case
262
+ raise ValueError (f"Test case { requested_id } not found" )
263
+
264
+
265
+ @pytest .mark .parametrize (
266
+ "id_matcher" ,
267
+ [
268
+ "single_blob_transaction" ,
269
+ "max_blobs_transaction" ,
270
+ "single_blob_max_txs" ,
271
+ ],
272
+ indirect = True ,
250
273
)
251
- @pytest .mark .exception_test
252
274
@pytest .mark .valid_from ("Cancun" )
253
275
def test_get_blobs (
254
276
blobs_test : BlobsTestFiller ,
@@ -259,7 +281,4 @@ def test_get_blobs(
259
281
Test valid blob combinations where one or more txs in the block
260
282
serialized version contain a full blob (network version) tx.
261
283
"""
262
- blobs_test (
263
- pre = pre ,
264
- txs = txs ,
265
- )
284
+ blobs_test (pre = pre , txs = txs )
0 commit comments