Skip to content

Commit 12a87c3

Browse files
committed
feat(tests): make execute blob tests client agnostic.
1 parent 8c3cbd7 commit 12a87c3

File tree

2 files changed

+50
-29
lines changed

2 files changed

+50
-29
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Users can select any of the artifacts depending on their testing needs for their
4141

4242
#### `execute`
4343

44+
- 🔀 Update hive execute blob tests to be client agnostic with respect to max blobs per transaction ([#1720](https://github.com/ethereum/execution-spec-tests/pull/1720)).
45+
4446
- ✨ Add `blob_transaction_test` execute test spec, which allows tests that send blob transactions to a running client and verifying its `engine_getBlobsVX` endpoint behavior ([#1644](https://github.com/ethereum/execution-spec-tests/pull/1644)).
4547

4648
### 📋 Misc

tests/osaka/eip7594_peerdas/test_get_blobs.py

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
"""
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).
44
55
""" # noqa: E501
66

77
from typing import List, Optional
88

99
import pytest
10+
from hive.client import ClientType
1011

11-
from ethereum_test_forks import Fork
12+
from ethereum_test_forks import Fork, Osaka
1213
from ethereum_test_tools import (
1314
Address,
1415
Alloc,
1516
Blob,
1617
BlobsTestFiller,
1718
NetworkWrappedTransaction,
1819
Transaction,
19-
TransactionException,
2020
)
2121

2222
from ...cancun.eip4844_blobs.common import INF_POINT
@@ -137,33 +137,27 @@ def tx_max_fee_per_blob_gas( # noqa: D103
137137
return blob_gas_price
138138

139139

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-
151140
@pytest.fixture
152141
def tx_wrapper_version() -> int | None:
153142
"""Return wrapper version used for the transactions sent during test."""
154143
return 1
155144

156145

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+
157152
@pytest.fixture(autouse=True)
158-
def txs( # noqa: D103
153+
def txs(
159154
pre: Alloc,
160155
destination_account: Optional[Address],
161156
tx_gas: int,
162157
tx_value: int,
163158
tx_calldata: bytes,
164159
tx_max_fee_per_blob_gas: int,
165160
txs_versioned_hashes: List[List[bytes]],
166-
tx_error: Optional[TransactionException],
167161
txs_blobs: List[List[Blob]],
168162
tx_wrapper_version: int | None,
169163
) -> List[NetworkWrappedTransaction | Transaction]:
@@ -182,7 +176,6 @@ def txs( # noqa: D103
182176
max_fee_per_blob_gas=tx_max_fee_per_blob_gas,
183177
access_list=[],
184178
blob_versioned_hashes=tx_versioned_hashes,
185-
error=tx_error,
186179
)
187180
network_wrapped_tx = NetworkWrappedTransaction(
188181
tx=tx,
@@ -193,15 +186,26 @@ def txs( # noqa: D103
193186
return txs
194187

195188

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+
196198
def generate_full_blob_tests(
197199
fork: Fork,
200+
client_type: Optional[ClientType] = None,
198201
) -> List:
199202
"""
200203
Return a list of tests for invalid blob transactions due to insufficient max fee per blob gas
201204
parametrized for each different fork.
202205
"""
203206
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)
205209
return [
206210
pytest.param(
207211
[ # Txs
@@ -223,7 +227,7 @@ def generate_full_blob_tests(
223227
kzg_commitment=INF_POINT,
224228
kzg_cell_proofs=[INF_POINT] * CELLS_PER_EXT_BLOB,
225229
)
226-
for _ in range(max_blobs)
230+
for _ in range(max_blobs_per_tx)
227231
]
228232
],
229233
id="max_blobs_transaction",
@@ -237,18 +241,36 @@ def generate_full_blob_tests(
237241
kzg_cell_proofs=[INF_POINT] * CELLS_PER_EXT_BLOB,
238242
)
239243
]
240-
for _ in range(max_blobs)
244+
for _ in range(max_blobs_per_block)
241245
],
242246
id="single_blob_max_txs",
243247
),
244248
]
245249

246250

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,
250273
)
251-
@pytest.mark.exception_test
252274
@pytest.mark.valid_from("Cancun")
253275
def test_get_blobs(
254276
blobs_test: BlobsTestFiller,
@@ -259,7 +281,4 @@ def test_get_blobs(
259281
Test valid blob combinations where one or more txs in the block
260282
serialized version contain a full blob (network version) tx.
261283
"""
262-
blobs_test(
263-
pre=pre,
264-
txs=txs,
265-
)
284+
blobs_test(pre=pre, txs=txs)

0 commit comments

Comments
 (0)