Skip to content

Commit d85af84

Browse files
feat(tests): ckzg functions for peerdas tests (#1614)
* added kzg functions for peerdas tests * fix: use proofs only instead of full cells * tests passing except for third one, too much gas (nethermind) or too many blobs (7vs9, geth) * implemented feedback * function that loads trusted setup now has to return trusted setup otherwise it cant be used as input to function that requires trusted setup to be passed * removed debug print * added filelock for r/w blobs * removed logging changes from this PR * removed changes to conversions.py * fixes * fix * fixes --------- Co-authored-by: Mario Vega <[email protected]>
1 parent 74ba47c commit d85af84

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

cancun/eip4844_blobs/test_blob_txs_full.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import pytest
1010

11+
from ethereum_test_base_types.base_types import Hash
1112
from ethereum_test_forks import Fork
1213
from ethereum_test_tools import (
1314
Address,
@@ -23,8 +24,7 @@
2324
TransactionException,
2425
)
2526

26-
from .common import INF_POINT
27-
from .spec import Spec, SpecHelpers, ref_spec_4844
27+
from .spec import Spec, ref_spec_4844
2828

2929
REFERENCE_SPEC_GIT_PATH = ref_spec_4844.git_path
3030
REFERENCE_SPEC_VERSION = ref_spec_4844.version
@@ -91,9 +91,12 @@ def tx_max_priority_fee_per_gas() -> int:
9191

9292

9393
@pytest.fixture
94-
def txs_versioned_hashes(txs_blobs: List[List[Blob]]) -> List[List[bytes]]:
94+
def txs_versioned_hashes(txs_blobs: List[List[Blob]]) -> List[List[Hash]]:
9595
"""List of blob versioned hashes derived from the blobs."""
96-
return [[blob.versioned_hash() for blob in blob_tx] for blob_tx in txs_blobs]
96+
version_hashes: List[List[Hash]] = [
97+
[blob.versioned_hash for blob in blob_tx] for blob_tx in txs_blobs
98+
]
99+
return version_hashes
97100

98101

99102
@pytest.fixture(autouse=True)
@@ -150,7 +153,7 @@ def txs( # noqa: D103
150153
tx_max_fee_per_gas: int,
151154
tx_max_fee_per_blob_gas: int,
152155
tx_max_priority_fee_per_gas: int,
153-
txs_versioned_hashes: List[List[bytes]],
156+
txs_versioned_hashes: List[List[Hash]],
154157
tx_error: Optional[TransactionException],
155158
txs_blobs: List[List[Blob]],
156159
txs_wrapped_blobs: List[bool],
@@ -179,7 +182,7 @@ def txs( # noqa: D103
179182
wrapped_blob_transaction=tx_wrapped_blobs,
180183
)
181184
if tx_wrapped_blobs:
182-
network_wrapped_tx = NetworkWrappedTransaction(tx=tx, blobs=tx_blobs)
185+
network_wrapped_tx = NetworkWrappedTransaction(tx=tx, blob_objects=tx_blobs)
183186
tx.rlp_override = network_wrapped_tx.rlp()
184187
txs.append(tx)
185188
return txs
@@ -237,17 +240,12 @@ def generate_full_blob_tests(
237240
Return a list of tests for invalid blob transactions due to insufficient max fee per blob gas
238241
parametrized for each different fork.
239242
"""
240-
blob_size = Spec.FIELD_ELEMENTS_PER_BLOB * SpecHelpers.BYTES_PER_FIELD_ELEMENT
241243
max_blobs = fork.max_blobs_per_block()
242244
return [
243245
pytest.param(
244246
[ # Txs
245247
[ # Blobs per transaction
246-
Blob(
247-
data=bytes(blob_size),
248-
kzg_commitment=INF_POINT,
249-
kzg_proof=INF_POINT,
250-
),
248+
Blob.from_fork(fork),
251249
]
252250
],
253251
[True],
@@ -256,27 +254,19 @@ def generate_full_blob_tests(
256254
pytest.param(
257255
[ # Txs
258256
[ # Blobs per transaction
259-
Blob(
260-
data=bytes(blob_size),
261-
kzg_commitment=INF_POINT,
262-
kzg_proof=INF_POINT,
263-
)
257+
Blob.from_fork(fork, s),
264258
]
265-
for _ in range(max_blobs)
259+
for s in range(max_blobs)
266260
],
267261
[True] + ([False] * (max_blobs - 1)),
268262
id="one_full_blob_max_txs",
269263
),
270264
pytest.param(
271265
[ # Txs
272266
[ # Blobs per transaction
273-
Blob(
274-
data=bytes(blob_size),
275-
kzg_commitment=INF_POINT,
276-
kzg_proof=INF_POINT,
277-
)
267+
Blob.from_fork(fork, s),
278268
]
279-
for _ in range(max_blobs)
269+
for s in range(max_blobs)
280270
],
281271
([False] * (max_blobs - 1)) + [True],
282272
id="one_full_blob_at_the_end_max_txs",

osaka/eip7594_peerdas/spec.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Defines EIP-7594 specification constants and functions."""
2+
3+
from dataclasses import dataclass
4+
5+
6+
@dataclass(frozen=True)
7+
class ReferenceSpec:
8+
"""Defines the reference spec version and git path."""
9+
10+
git_path: str
11+
version: str
12+
13+
14+
ref_spec_7594 = ReferenceSpec("EIPS/eip-7594.md", "45d03a84a8ad0160ed3fb03af52c49bd39e802ba")
15+
16+
17+
@dataclass(frozen=True)
18+
class Spec:
19+
"""
20+
Parameters from the EIP-7594 specifications as defined at
21+
https://eips.ethereum.org/EIPS/eip-7594.
22+
"""
23+
24+
pass

osaka/eip7594_peerdas/test_get_blobs.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
Transaction,
1919
TransactionException,
2020
)
21+
from pytest_plugins.logging import get_logger
2122

22-
from ...cancun.eip4844_blobs.common import INF_POINT
23-
from ...cancun.eip4844_blobs.spec import Spec as Spec4844
24-
from ...cancun.eip4844_blobs.spec import SpecHelpers, ref_spec_4844
23+
from .spec import ref_spec_7594
2524

26-
CELLS_PER_EXT_BLOB = 128
25+
REFERENCE_SPEC_GIT_PATH = ref_spec_7594.git_path
26+
REFERENCE_SPEC_VERSION = ref_spec_7594.version
2727

28-
REFERENCE_SPEC_GIT_PATH = ref_spec_4844.git_path
29-
REFERENCE_SPEC_VERSION = ref_spec_4844.version
28+
logger = get_logger(__name__)
3029

3130

3231
@pytest.fixture
@@ -124,7 +123,7 @@ def blob_gas_price(
124123
@pytest.fixture
125124
def txs_versioned_hashes(txs_blobs: List[List[Blob]]) -> List[List[bytes]]:
126125
"""List of blob versioned hashes derived from the blobs."""
127-
return [[blob.versioned_hash() for blob in blob_tx] for blob_tx in txs_blobs]
126+
return [[blob.versioned_hash for blob in blob_tx] for blob_tx in txs_blobs]
128127

129128

130129
@pytest.fixture
@@ -181,7 +180,7 @@ def txs( # noqa: D103
181180
txs: List[NetworkWrappedTransaction | Transaction] = []
182181
for tx_blobs, tx_versioned_hashes in zip(txs_blobs, txs_versioned_hashes, strict=False):
183182
tx = Transaction(
184-
ty=Spec4844.BLOB_TX_TYPE,
183+
# type=3,
185184
sender=pre.fund_eoa(),
186185
to=destination_account,
187186
value=tx_value,
@@ -194,8 +193,8 @@ def txs( # noqa: D103
194193
)
195194
network_wrapped_tx = NetworkWrappedTransaction(
196195
tx=tx,
197-
blobs=tx_blobs,
198196
wrapper_version=tx_wrapper_version,
197+
blob_objects=tx_blobs,
199198
)
200199
txs.append(network_wrapped_tx)
201200
return txs
@@ -208,44 +207,32 @@ def generate_full_blob_tests(
208207
Return a list of tests for invalid blob transactions due to insufficient max fee per blob gas
209208
parametrized for each different fork.
210209
"""
211-
blob_size = Spec4844.FIELD_ELEMENTS_PER_BLOB * SpecHelpers.BYTES_PER_FIELD_ELEMENT
212210
max_blobs = fork.max_blobs_per_block()
211+
logger.debug(f"MAX_BLOBS value for fork {fork}: {max_blobs}")
212+
213213
return [
214214
pytest.param(
215215
[ # Txs
216216
[ # Blobs per transaction
217-
Blob(
218-
data=bytes(blob_size),
219-
kzg_commitment=INF_POINT,
220-
kzg_cell_proofs=[INF_POINT] * CELLS_PER_EXT_BLOB,
221-
),
217+
Blob.from_fork(fork),
222218
]
223219
],
224220
id="single_blob_transaction",
225221
),
226222
pytest.param(
227223
[ # Txs
228224
[ # Blobs per transaction
229-
Blob(
230-
data=bytes(blob_size),
231-
kzg_commitment=INF_POINT,
232-
kzg_cell_proofs=[INF_POINT] * CELLS_PER_EXT_BLOB,
233-
)
234-
for _ in range(max_blobs)
225+
Blob.from_fork(fork, s) for s in range(max_blobs)
235226
]
236227
],
237228
id="max_blobs_transaction",
238229
),
239230
pytest.param(
240231
[ # Txs
241232
[ # Blobs per transaction
242-
Blob(
243-
data=bytes(blob_size),
244-
kzg_commitment=INF_POINT,
245-
kzg_cell_proofs=[INF_POINT] * CELLS_PER_EXT_BLOB,
246-
)
233+
Blob.from_fork(fork, s),
247234
]
248-
for _ in range(max_blobs)
235+
for s in range(max_blobs)
249236
],
250237
id="single_blob_max_txs",
251238
),

0 commit comments

Comments
 (0)