Skip to content

Commit 8f516ce

Browse files
authored
feat(forks|tests): add tx wrapper version on per fork basis. (#1892)
1 parent d53769f commit 8f516ce

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

src/ethereum_test_forks/base_fork.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ def max_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> int:
330330
"""Return the max blobs per block at a given fork."""
331331
pass
332332

333+
@classmethod
334+
@abstractmethod
335+
def full_blob_tx_wrapper_version(cls, block_number: int = 0, timestamp: int = 0) -> int | None:
336+
"""Return the version of the full blob transaction wrapper at a given fork."""
337+
pass
338+
333339
@classmethod
334340
@prefer_transition_to_method
335341
@abstractmethod

src/ethereum_test_forks/forks/forks.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ def max_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> int:
250250
"""Return the max number of blobs per block at a given fork."""
251251
raise NotImplementedError(f"Max blobs per block is not supported in {cls.name()}")
252252

253+
@classmethod
254+
def full_blob_tx_wrapper_version(cls, block_number: int = 0, timestamp: int = 0) -> int | None:
255+
"""Return the version of the full blob transaction wrapper."""
256+
raise NotImplementedError(
257+
f"Full blob transaction wrapper version is not supported in {cls.name()}"
258+
)
259+
253260
@classmethod
254261
def blob_schedule(cls, block_number: int = 0, timestamp: int = 0) -> BlobSchedule | None:
255262
"""At genesis, no blob schedule is used."""
@@ -1014,6 +1021,11 @@ def max_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> int:
10141021
"""Blobs are enabled starting from Cancun, with a static max of 6 blobs."""
10151022
return 6
10161023

1024+
@classmethod
1025+
def full_blob_tx_wrapper_version(cls, block_number: int = 0, timestamp: int = 0) -> int | None:
1026+
"""Pre-Osaka forks don't use tx wrapper versions for full blob transactions."""
1027+
return None
1028+
10171029
@classmethod
10181030
def blob_schedule(cls, block_number: int = 0, timestamp: int = 0) -> BlobSchedule | None:
10191031
"""
@@ -1375,6 +1387,11 @@ def engine_get_blobs_version(cls, block_number: int = 0, timestamp: int = 0) ->
13751387
"""At Osaka, the engine get blobs version is 2."""
13761388
return 2
13771389

1390+
@classmethod
1391+
def full_blob_tx_wrapper_version(cls, block_number=0, timestamp=0) -> int | None:
1392+
"""At Osaka, the full blob transaction wrapper version is defined."""
1393+
return 1
1394+
13781395
@classmethod
13791396
def transaction_gas_limit_cap(cls, block_number: int = 0, timestamp: int = 0) -> int | None:
13801397
"""At Osaka, transaction gas limit is capped at 30 million."""

tests/cancun/eip4844_blobs/test_blob_txs_full.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def txs( # noqa: D103
157157
tx_error: Optional[TransactionException],
158158
txs_blobs: List[List[Blob]],
159159
txs_wrapped_blobs: List[bool],
160+
fork: Fork,
160161
) -> List[Transaction]:
161162
"""Prepare the list of transactions that are sent during the test."""
162163
if len(txs_blobs) != len(txs_versioned_hashes) or len(txs_blobs) != len(txs_wrapped_blobs):
@@ -182,7 +183,11 @@ def txs( # noqa: D103
182183
wrapped_blob_transaction=tx_wrapped_blobs,
183184
)
184185
if tx_wrapped_blobs:
185-
network_wrapped_tx = NetworkWrappedTransaction(tx=tx, blob_objects=tx_blobs)
186+
network_wrapped_tx = NetworkWrappedTransaction(
187+
tx=tx,
188+
blob_objects=tx_blobs,
189+
wrapper_version=fork.full_blob_tx_wrapper_version(),
190+
)
186191
tx.rlp_override = network_wrapped_tx.rlp()
187192
txs.append(tx)
188193
return txs

tests/osaka/eip7594_peerdas/test_get_blobs.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,6 @@ def tx_error() -> Optional[TransactionException]:
155155
return None
156156

157157

158-
@pytest.fixture
159-
def tx_wrapper_version() -> int | None:
160-
"""Return wrapper version used for the transactions sent during test."""
161-
return 1
162-
163-
164158
@pytest.fixture(autouse=True)
165159
def txs( # noqa: D103
166160
pre: Alloc,
@@ -172,7 +166,7 @@ def txs( # noqa: D103
172166
txs_versioned_hashes: List[List[bytes]],
173167
tx_error: Optional[TransactionException],
174168
txs_blobs: List[List[Blob]],
175-
tx_wrapper_version: int | None,
169+
fork: Fork,
176170
) -> List[NetworkWrappedTransaction | Transaction]:
177171
"""Prepare the list of transactions that are sent during the test."""
178172
if len(txs_blobs) != len(txs_versioned_hashes):
@@ -193,8 +187,8 @@ def txs( # noqa: D103
193187
)
194188
network_wrapped_tx = NetworkWrappedTransaction(
195189
tx=tx,
196-
wrapper_version=tx_wrapper_version,
197190
blob_objects=tx_blobs,
191+
wrapper_version=fork.full_blob_tx_wrapper_version(),
198192
)
199193
txs.append(network_wrapped_tx)
200194
return txs

0 commit comments

Comments
 (0)