Skip to content

Commit a1f90dd

Browse files
committed
fix(fw): fix verkle transition tests (naive).
1 parent 18b3d88 commit a1f90dd

File tree

7 files changed

+43
-20
lines changed

7 files changed

+43
-20
lines changed

src/ethereum_test_forks/base_fork.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ def fork_at(cls, block_number: int = 0, timestamp: int = 0) -> Type["BaseFork"]:
292292
"""
293293
return cls
294294

295+
@classmethod
296+
def transition_at(cls) -> int:
297+
"""
298+
Return the timestamp at which the fork will start transitioning to the next fork.
299+
Useful only for transition forks.
300+
"""
301+
return 0
302+
295303
@classmethod
296304
@abstractmethod
297305
def transition_tool_name(cls, block_number: int = 0, timestamp: int = 0) -> str:

src/ethereum_test_forks/forks/forks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,12 @@ class EIP6800Transition(
674674
Shanghai to Verkle transition at Timestamp 32.
675675
"""
676676

677-
pass
677+
@classmethod
678+
def transition_at(cls) -> int:
679+
"""
680+
The timestamp at which the fork transition occurs.
681+
"""
682+
return 32
678683

679684

680685
class CancunEIP7692(

src/ethereum_test_tools/common/conversions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Common conversion methods.
33
"""
4+
45
from re import sub
56
from typing import Any, List, Optional, SupportsBytes, TypeAlias
67

src/ethereum_test_tools/common/types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ def __setitem__(
222222
value: StorageKeyValueTypeConvertible | StorageKeyValueType,
223223
): # noqa: SC200
224224
"""Sets an item in the storage"""
225-
self.root[
226-
StorageKeyValueTypeAdapter.validate_python(key)
227-
] = StorageKeyValueTypeAdapter.validate_python(value)
225+
self.root[StorageKeyValueTypeAdapter.validate_python(key)] = (
226+
StorageKeyValueTypeAdapter.validate_python(value)
227+
)
228228

229229
def __delitem__(self, key: StorageKeyValueTypeConvertible | StorageKeyValueType):
230230
"""Deletes an item from the storage"""
@@ -1711,12 +1711,12 @@ class Result(CamelModel):
17111711
)
17121712

17131713

1714-
class VerkleTree(RootModel[Dict[StorageKeyValueType, StorageKeyValueType]]):
1714+
class VerkleTree(RootModel[Dict[str, str]]):
17151715
"""
17161716
Definition of a verkle tree return from the geth t8n.
17171717
"""
17181718

1719-
root: Dict[StorageKeyValueType, StorageKeyValueType] = Field(default_factory=dict)
1719+
root: Dict[str, str] = Field(default_factory=dict)
17201720

17211721

17221722
class TransitionToolOutput(CamelModel):

src/ethereum_test_tools/spec/blockchain/blockchain_test.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,15 @@ def make_fixture(
369369

370370
# Hack for filling naive verkle transition tests
371371
if fork is EIP6800Transition:
372-
# Add a dummy Shanghai block before the test blocks
373-
self.blocks.insert(0, Block(timestamp=HexNumber(12)))
372+
# Add a dummy block before the fork transition
373+
self.blocks.insert(0, Block(timestamp=HexNumber(fork.transition_at() - 1)))
374374
# Set timestamp for the next block to verkle transition time
375-
self.blocks[1].timestamp = HexNumber(32)
375+
self.blocks[1].timestamp = HexNumber(fork.transition_at())
376+
# Increment all other block numbers
377+
for i, block in enumerate(self.blocks[1:]):
378+
block.number = HexNumber(i + 2)
379+
# Add a dummy block at the end of the test blocks
380+
self.blocks.append(Block())
376381

377382
for block in self.blocks:
378383
if block.rlp is None:
@@ -453,7 +458,7 @@ def make_fixture(
453458
blocks=fixture_blocks,
454459
last_block_hash=head,
455460
pre=pre,
456-
post_state=alloc if vkt is None else vkt,
461+
# TODO: post_state=alloc
457462
)
458463

459464
def make_hive_fixture(
@@ -475,10 +480,15 @@ def make_hive_fixture(
475480

476481
# Hack for filling naive verkle transition tests
477482
if fork is EIP6800Transition:
478-
# Add a dummy Shanghai block before the test blocks
479-
self.blocks.insert(0, Block(timestamp=HexNumber(12)))
483+
# Add a dummy block before the fork transition
484+
self.blocks.insert(0, Block(timestamp=HexNumber(fork.transition_at() - 1)))
480485
# Set timestamp for the next block to verkle transition time
481-
self.blocks[1].timestamp = HexNumber(32)
486+
self.blocks[1].timestamp = HexNumber(fork.transition_at())
487+
# Increment all other block numbers
488+
for i, block in enumerate(self.blocks[1:]):
489+
block.number = HexNumber(i + 2)
490+
# Add a dummy block at the end of the test blocks
491+
self.blocks.append(Block())
482492

483493
for block in self.blocks:
484494
new_env, header, txs, new_alloc, requests, new_vkt = self.generate_block_data(
@@ -550,7 +560,7 @@ def make_hive_fixture(
550560
payloads=fixture_payloads,
551561
fcu_version=fcu_version,
552562
pre=pre,
553-
post_state=alloc if vkt is None else vkt,
563+
# TODO: post_state=alloc
554564
sync_payload=sync_payload,
555565
)
556566

src/ethereum_test_tools/spec/blockchain/types.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
Transaction,
5353
TransactionFixtureConverter,
5454
TransactionGeneric,
55-
VerkleTree,
5655
Withdrawal,
5756
WithdrawalGeneric,
5857
WithdrawalRequest,
@@ -203,9 +202,9 @@ class FixtureHeader(CamelModel):
203202
extra_data: Bytes
204203
prev_randao: Hash = Field(Hash(0), alias="mixHash")
205204
nonce: HeaderNonce = Field(HeaderNonce(0), validate_default=True)
206-
base_fee_per_gas: (
207-
Annotated[ZeroPaddedHexNumber, HeaderForkRequirement("base_fee")] | None
208-
) = Field(None)
205+
base_fee_per_gas: Annotated[ZeroPaddedHexNumber, HeaderForkRequirement("base_fee")] | None = (
206+
Field(None)
207+
)
209208
withdrawals_root: Annotated[Hash, HeaderForkRequirement("withdrawals")] | None = Field(None)
210209
blob_gas_used: (
211210
Annotated[ZeroPaddedHexNumber, HeaderForkRequirement("blob_gas_used")] | None
@@ -647,7 +646,7 @@ class FixtureCommon(BaseFixture):
647646
fork: str = Field(..., alias="network")
648647
genesis: FixtureHeader = Field(..., alias="genesisBlockHeader")
649648
pre: Alloc
650-
post_state: Optional[Alloc | VerkleTree] = Field(None)
649+
post_state: Optional[Alloc] = Field(None)
651650

652651
def get_fork(self) -> str:
653652
"""

src/pytest_plugins/consume/hive_ruleset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
"HIVE_SHANGHAI_TIMESTAMP": 0,
307307
"HIVE_CANCUN_TIMESTAMP": 15000,
308308
},
309-
"ShanghaiToPragueAt32": { # TODO: Make this verkle specific
309+
"ShanghaiToPragueAtTime32": { # TODO: Make this verkle specific
310310
"HIVE_FORK_HOMESTEAD": 0,
311311
"HIVE_FORK_TANGERINE": 0,
312312
"HIVE_FORK_SPURIOUS": 0,

0 commit comments

Comments
 (0)