Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/writing_tests/fork_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ fork.name() # Returns the name of the fork
fork.transition_tool_name(block_number=0, timestamp=0) # Returns name for transition tools
fork.solc_name() # Returns name for the solc compiler
fork.solc_min_version() # Returns minimum solc version supporting this fork
fork.blockchain_test_network_name() # Returns network name for blockchain tests
fork.is_deployed() # Returns whether the fork is deployed to mainnet
```

Expand Down
3 changes: 0 additions & 3 deletions src/ethereum_clis/clis/besu.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def evaluate(
chain_id: int,
reward: int,
blob_schedule: BlobSchedule | None = None,
eips: Optional[List[int]] = None,
debug_output_path: str = "",
state_test: bool = False,
slow_request: bool = False,
Expand All @@ -119,8 +118,6 @@ def evaluate(
block_number=env.number,
timestamp=env.timestamp,
)
if eips is not None:
fork_name = "+".join([fork_name] + [str(eip) for eip in eips])

input_json = TransitionToolInput(
alloc=alloc,
Expand Down
3 changes: 0 additions & 3 deletions src/ethereum_clis/transition_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ def evaluate(
chain_id: int,
reward: int,
blob_schedule: BlobSchedule | None,
eips: Optional[List[int]] = None,
debug_output_path: str = "",
state_test: bool = False,
slow_request: bool = False,
Expand All @@ -515,8 +514,6 @@ def evaluate(
block_number=env.number,
timestamp=env.timestamp,
)
if eips is not None:
fork_name = "+".join([fork_name] + [str(eip) for eip in eips])
if env.number == 0:
reward = -1
t8n_data = self.TransitionToolData(
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum_test_fixtures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def fill_info(
if _info_metadata:
self.info.update(_info_metadata)

def get_fork(self) -> str | None:
def get_fork(self) -> Fork | None:
"""Return fork of the fixture as a string."""
raise NotImplementedError

Expand Down
6 changes: 3 additions & 3 deletions src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def without_rlp(self) -> FixtureBlockBase:
class FixtureConfig(CamelModel):
"""Chain configuration for a fixture."""

fork: str = Field(..., alias="network")
fork: Fork = Field(..., alias="network")
chain_id: ZeroPaddedHexNumber = Field(ZeroPaddedHexNumber(1), alias="chainid")
blob_schedule: FixtureBlobSchedule | None = None

Expand All @@ -402,7 +402,7 @@ class InvalidFixtureBlock(CamelModel):
class BlockchainFixtureCommon(BaseFixture):
"""Base blockchain test fixture model."""

fork: str = Field(..., alias="network")
fork: Fork = Field(..., alias="network")
genesis: FixtureHeader = Field(..., alias="genesisBlockHeader")
pre: Alloc
post_state: Alloc | None = Field(None)
Expand Down Expand Up @@ -435,7 +435,7 @@ def config_defaults_for_backwards_compatibility(cls, data: Any) -> Any:
data["config"]["chainid"] = "0x01"
return data

def get_fork(self) -> str | None:
def get_fork(self) -> Fork | None:
"""Return fork of the fixture as a string."""
return self.fork

Expand Down
5 changes: 3 additions & 2 deletions src/ethereum_test_fixtures/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pydantic import BaseModel, RootModel

from ethereum_test_base_types import HexNumber
from ethereum_test_forks import Fork

from .base import BaseFixture, FixtureFormat
from .file import Fixtures
Expand Down Expand Up @@ -44,7 +45,7 @@ class TestCaseBase(BaseModel):

id: str
fixture_hash: HexNumber | None
fork: str | None
fork: Fork | None
format: FixtureFormat
__test__ = False # stop pytest from collecting this class as a test

Expand Down Expand Up @@ -80,7 +81,7 @@ class IndexFile(BaseModel):
root_hash: HexNumber | None
created_at: datetime.datetime
test_count: int
forks: Optional[List[str]] = []
forks: Optional[List[Fork]] = []
fixture_formats: Optional[List[str]] = []
test_cases: List[TestCaseIndexFile]

Expand Down
5 changes: 3 additions & 2 deletions src/ethereum_test_fixtures/eof.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ethereum_test_base_types import Bytes, CamelModel, Number
from ethereum_test_exceptions.exceptions import EOFExceptionInstanceOrList
from ethereum_test_forks import Fork
from ethereum_test_types.eof.v1 import ContainerKind

from .base import BaseFixture
Expand Down Expand Up @@ -34,7 +35,7 @@ class Vector(CamelModel):

code: Bytes
container_kind: ContainerKind = ContainerKind.RUNTIME
results: Mapping[str, Result]
results: Mapping[Fork, Result]


class EOFFixture(BaseFixture):
Expand All @@ -45,6 +46,6 @@ class EOFFixture(BaseFixture):

vectors: Mapping[Number, Vector]

def get_fork(self) -> str | None:
def get_fork(self) -> Fork | None:
"""Return fork of the fixture as a string."""
return None
5 changes: 3 additions & 2 deletions src/ethereum_test_fixtures/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ZeroPaddedHexNumber,
)
from ethereum_test_exceptions import TransactionExceptionInstanceOrList
from ethereum_test_forks import Fork
from ethereum_test_types.block_types import EnvironmentGeneric
from ethereum_test_types.transaction_types import (
Transaction,
Expand Down Expand Up @@ -97,10 +98,10 @@ class StateFixture(BaseFixture):
env: FixtureEnvironment
pre: Alloc
transaction: FixtureTransaction
post: Mapping[str, List[FixtureForkPost]]
post: Mapping[Fork, List[FixtureForkPost]]
config: FixtureConfig

def get_fork(self) -> str | None:
def get_fork(self) -> Fork | None:
"""Return fork of the fixture as a string."""
forks = list(self.post.keys())
assert len(forks) == 1, "Expected state test fixture with single fork"
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum_test_fixtures/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_json_dict():
"""Test that the json_dict property does not include the info field."""
fixture = TransactionFixture(
txbytes="0x1234",
result={"fork": FixtureResult(intrinsic_gas=0)},
result={"Paris": FixtureResult(intrinsic_gas=0)},
)
assert "_info" not in fixture.json_dict, "json_dict should exclude the 'info' field"

Expand All @@ -38,7 +38,7 @@ def test_json_dict():
pytest.param(
TransactionFixture(
transaction="0x1234",
result={"fork": FixtureResult(intrinsic_gas=0)},
result={"Paris": FixtureResult(intrinsic_gas=0)},
),
id="TransactionFixture",
),
Expand Down
8 changes: 4 additions & 4 deletions src/ethereum_test_fixtures/tests/test_eof.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
code=Bytes(b"\x00"),
container_kind=ContainerKind.INITCODE,
results={
"result1": Result(
"Paris": Result(
exception=None,
valid=True,
),
Expand All @@ -35,7 +35,7 @@
"code": "0x00",
"containerKind": "INITCODE",
"results": {
"result1": {
"Paris": {
"result": True,
},
},
Expand All @@ -52,7 +52,7 @@
code=Bytes(b"\x00"),
container_kind=ContainerKind.RUNTIME,
results={
"result1": Result(
"Paris": Result(
exception=EOFException.INVALID_MAGIC,
valid=False,
),
Expand All @@ -66,7 +66,7 @@
"code": "0x00",
"containerKind": "RUNTIME",
"results": {
"result1": {
"Paris": {
"exception": "EOFException.INVALID_MAGIC",
"result": False,
},
Expand Down
5 changes: 3 additions & 2 deletions src/ethereum_test_fixtures/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ethereum_test_base_types import Address, Bytes, CamelModel, Hash, ZeroPaddedHexNumber
from ethereum_test_exceptions import TransactionExceptionInstanceOrList
from ethereum_test_forks import Fork

from .base import BaseFixture

Expand All @@ -25,10 +26,10 @@ class TransactionFixture(BaseFixture):
format_name: ClassVar[str] = "transaction_test"
description: ClassVar[str] = "Tests that generate a transaction test fixture."

result: Mapping[str, FixtureResult]
result: Mapping[Fork, FixtureResult]
transaction: Bytes = Field(..., alias="txbytes")

def get_fork(self) -> str | None:
def get_fork(self) -> Fork | None:
"""Return the fork of the fixture as a string."""
forks = list(self.result.keys())
assert len(forks) == 1, "Expected transaction test fixture with single fork"
Expand Down
7 changes: 6 additions & 1 deletion src/ethereum_test_forks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Ethereum test fork definitions."""

from .base_fork import Fork, ForkAttribute
from .base_fork import ForkAttribute
from .forks.forks import (
ArrowGlacier,
Berlin,
Expand All @@ -24,12 +24,15 @@
BerlinToLondonAt5,
CancunToPragueAtTime15k,
ParisToShanghaiAtTime15k,
PragueToOsakaAtTime15k,
ShanghaiToCancunAtTime15k,
)
from .gas_costs import GasCosts
from .helpers import (
Fork,
ForkRangeDescriptor,
InvalidForkError,
TransitionFork,
forks_from,
forks_from_until,
get_closest_fork_with_solc_support,
Expand All @@ -53,6 +56,7 @@

__all__ = [
"Fork",
"TransitionFork",
"ForkAttribute",
"ArrowGlacier",
"Berlin",
Expand All @@ -76,6 +80,7 @@
"Cancun",
"CancunToPragueAtTime15k",
"Prague",
"PragueToOsakaAtTime15k",
"Osaka",
"get_transition_forks",
"forks_from",
Expand Down
14 changes: 0 additions & 14 deletions src/ethereum_test_forks/base_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,18 @@ class BaseFork(ABC, metaclass=BaseForkMeta):
"""

_transition_tool_name: ClassVar[Optional[str]] = None
_blockchain_test_network_name: ClassVar[Optional[str]] = None
_solc_name: ClassVar[Optional[str]] = None
_ignore: ClassVar[bool] = False

def __init_subclass__(
cls,
*,
transition_tool_name: Optional[str] = None,
blockchain_test_network_name: Optional[str] = None,
solc_name: Optional[str] = None,
ignore: bool = False,
) -> None:
"""Initialize new fork with values that don't carry over to subclass forks."""
cls._transition_tool_name = transition_tool_name
cls._blockchain_test_network_name = blockchain_test_network_name
cls._solc_name = solc_name
cls._ignore = ignore

Expand Down Expand Up @@ -533,13 +530,6 @@ def solc_min_version(cls) -> Version:
"""Return minimum version of solc that supports this fork."""
pass

@classmethod
def blockchain_test_network_name(cls) -> str:
"""Return network configuration name to be used in BlockchainTests for this fork."""
if cls._blockchain_test_network_name is not None:
return cls._blockchain_test_network_name
return cls.name()

@classmethod
def is_deployed(cls) -> bool:
"""
Expand All @@ -563,7 +553,3 @@ def parent(cls) -> Type["BaseFork"] | None:
if base_class == BaseFork:
return None
return base_class


# Fork Type
Fork = Type[BaseFork]
1 change: 0 additions & 1 deletion src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ class GrayGlacier(ArrowGlacier, solc_name="london", ignore=True):
class Paris(
London,
transition_tool_name="Merge",
blockchain_test_network_name="Paris",
):
"""Paris (Merge) fork."""

Expand Down
11 changes: 9 additions & 2 deletions src/ethereum_test_forks/forks/transition.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""List of all transition fork definitions."""

from ..transition_base_fork import transition_fork
from .forks import Berlin, Cancun, London, Paris, Prague, Shanghai
from .forks import Berlin, Cancun, London, Osaka, Paris, Prague, Shanghai


# Transition Forks
Expand All @@ -13,7 +13,7 @@ class BerlinToLondonAt5(Berlin):


@transition_fork(to_fork=Shanghai, at_timestamp=15_000)
class ParisToShanghaiAtTime15k(Paris, blockchain_test_network_name="ParisToShanghaiAtTime15k"):
class ParisToShanghaiAtTime15k(Paris):
"""Paris to Shanghai transition at Timestamp 15k."""

pass
Expand All @@ -31,3 +31,10 @@ class CancunToPragueAtTime15k(Cancun):
"""Cancun to Prague transition at Timestamp 15k."""

pass


@transition_fork(to_fork=Osaka, at_timestamp=15_000)
class PragueToOsakaAtTime15k(Prague):
"""Prague to Osaka transition at Timestamp 15k."""

pass
Loading
Loading