Skip to content

Commit f994c4e

Browse files
committed
removed lots of unneeded functions, removed coverage fixer test, renamed SOLC_PADDING_VERSION to SOLC_EXPECTED_MIN_VERSION
1 parent 0d613e1 commit f994c4e

File tree

10 files changed

+14
-153
lines changed

10 files changed

+14
-153
lines changed

src/ethereum_test_forks/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@
3535
TransitionFork,
3636
forks_from,
3737
forks_from_until,
38-
get_closest_fork_with_solc_support,
38+
get_closest_fork,
3939
get_deployed_forks,
4040
get_development_forks,
4141
get_fork_by_name,
4242
get_forks,
4343
get_forks_with_no_descendants,
4444
get_forks_with_no_parents,
45-
get_forks_with_solc_support,
46-
get_forks_without_solc_support,
4745
get_from_until_fork_set,
4846
get_last_descendants,
4947
get_relative_fork_markers,
@@ -85,16 +83,14 @@
8583
"get_transition_forks",
8684
"forks_from",
8785
"forks_from_until",
88-
"get_closest_fork_with_solc_support",
86+
"get_closest_fork",
8987
"get_deployed_forks",
9088
"get_development_forks",
9189
"get_transition_fork_predecessor",
9290
"get_transition_fork_successor",
9391
"get_fork_by_name",
9492
"get_forks_with_no_descendants",
9593
"get_forks_with_no_parents",
96-
"get_forks_with_solc_support",
97-
"get_forks_without_solc_support",
9894
"get_relative_fork_markers",
9995
"get_forks",
10096
"get_from_until_fork_set",

src/ethereum_test_forks/base_fork.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
Union,
1717
)
1818

19-
from semver import Version
20-
2119
from ethereum_test_base_types import AccessList, Address, BlobSchedule
2220
from ethereum_test_base_types.conversions import BytesConvertible
2321
from ethereum_test_vm import EVMCodeType, Opcodes
@@ -576,12 +574,6 @@ def solc_name(cls) -> str:
576574
"""Return fork name as it's meant to be passed to the solc compiler."""
577575
pass
578576

579-
@classmethod
580-
@abstractmethod
581-
def solc_min_version(cls) -> Version:
582-
"""Return minimum version of solc that supports this fork."""
583-
pass
584-
585577
@classmethod
586578
def is_deployed(cls) -> bool:
587579
"""

src/ethereum_test_forks/forks/forks.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from pathlib import Path
77
from typing import List, Literal, Mapping, Optional, Sized, Tuple
88

9-
from semver import Version
10-
119
from ethereum_test_base_types import AccessList, Address, BlobSchedule, Bytes, ForkBlobSchedule
1210
from ethereum_test_base_types.conversions import BytesConvertible
1311
from ethereum_test_vm import EVMCodeType, Opcodes
@@ -46,11 +44,6 @@ def solc_name(cls) -> str:
4644
return cls._solc_name
4745
return cls.name().lower()
4846

49-
@classmethod
50-
def solc_min_version(cls) -> Version:
51-
"""Return minimum version of solc that supports this fork."""
52-
return Version.parse("0.8.20")
53-
5447
@classmethod
5548
def header_base_fee_required(cls, block_number: int = 0, timestamp: int = 0) -> bool:
5649
"""At genesis, header must not contain base fee."""
@@ -929,11 +922,6 @@ def get_blob_constant(cls, name: str) -> int | Literal["big"]:
929922
)
930923
return retrieved_constant
931924

932-
@classmethod
933-
def solc_min_version(cls) -> Version:
934-
"""Return minimum version of solc that supports this fork."""
935-
return Version.parse("0.8.24")
936-
937925
@classmethod
938926
def header_excess_blob_gas_required(cls, block_number: int = 0, timestamp: int = 0) -> bool:
939927
"""Excess blob gas is required starting from Cancun."""
@@ -1131,11 +1119,6 @@ def is_deployed(cls) -> bool:
11311119
"""
11321120
return False
11331121

1134-
@classmethod
1135-
def solc_min_version(cls) -> Version:
1136-
"""Return minimum version of solc that supports this fork."""
1137-
return Version.parse("1.0.0") # set a high version; currently unknown
1138-
11391122
@classmethod
11401123
def precompiles(cls, block_number: int = 0, timestamp: int = 0) -> List[Address]:
11411124
"""
@@ -1421,11 +1404,6 @@ def valid_opcodes(
14211404
Opcodes.CLZ,
14221405
] + super(Prague, cls).valid_opcodes()
14231406

1424-
@classmethod
1425-
def solc_min_version(cls) -> Version:
1426-
"""Return minimum version of solc that supports this fork."""
1427-
return Version.parse("1.0.0") # set a high version; currently unknown
1428-
14291407
@classmethod
14301408
def precompiles(cls, block_number: int = 0, timestamp: int = 0) -> List[Address]:
14311409
"""
@@ -1514,8 +1492,3 @@ def is_deployed(cls) -> bool:
15141492
development.
15151493
"""
15161494
return False
1517-
1518-
@classmethod
1519-
def solc_min_version(cls) -> Version:
1520-
"""Return minimum version of solc that supports this fork."""
1521-
return Version.parse("1.0.0") # set a high version; currently unknown

src/ethereum_test_forks/helpers.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,30 +77,11 @@ def get_parent_fork(fork: Type[BaseFork]) -> Type[BaseFork]:
7777
return parent_fork
7878

7979

80-
def get_forks_with_solc_support(solc_version: Version) -> List[Type[BaseFork]]:
81-
"""Return list of all fork classes that are supported by solc."""
82-
return [fork for fork in get_forks() if solc_version >= fork.solc_min_version()]
83-
84-
85-
def get_forks_without_solc_support(solc_version: Version) -> List[Type[BaseFork]]:
86-
"""Return list of all fork classes that aren't supported by solc."""
87-
return [fork for fork in get_forks() if solc_version < fork.solc_min_version()]
88-
89-
90-
def get_closest_fork_with_solc_support(
91-
fork: Type[BaseFork], solc_version: Version
92-
) -> Optional[Type[BaseFork]]:
93-
"""
94-
Return closest fork, potentially the provided fork itself, that has
95-
solc support.
96-
"""
80+
def get_closest_fork(fork: Type[BaseFork], solc_version: Version) -> Optional[Type[BaseFork]]:
81+
"""Return None if BaseFork is passed, otherwise return the fork itself."""
9782
if fork is BaseFork:
9883
return None
99-
return (
100-
fork
101-
if solc_version >= fork.solc_min_version()
102-
else get_closest_fork_with_solc_support(get_parent_fork(fork), solc_version)
103-
)
84+
return fork
10485

10586

10687
def get_transition_forks() -> Set[Type[BaseFork]]:

src/ethereum_test_forks/tests/test_forks.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import pytest
66
from pydantic import BaseModel
7-
from semver import Version
87

98
from ethereum_test_base_types import BlobSchedule
109

@@ -31,10 +30,8 @@
3130
Fork,
3231
forks_from,
3332
forks_from_until,
34-
get_closest_fork_with_solc_support,
3533
get_deployed_forks,
3634
get_forks,
37-
get_forks_with_solc_support,
3835
transition_fork_from_to,
3936
transition_fork_to,
4037
)
@@ -298,18 +295,6 @@ def test_tx_types(): # noqa: D103
298295
Cancun.tx_types() == list(range(4)) # noqa: B015
299296

300297

301-
def test_solc_versioning(): # noqa: D103
302-
assert len(get_forks_with_solc_support(Version.parse("0.8.20"))) == 13
303-
assert len(get_forks_with_solc_support(Version.parse("0.8.24"))) > 13
304-
305-
306-
def test_closest_fork_supported_by_solc(): # noqa: D103
307-
assert get_closest_fork_with_solc_support(Paris, Version.parse("0.8.20")) == Paris
308-
assert get_closest_fork_with_solc_support(Cancun, Version.parse("0.8.20")) == Shanghai
309-
assert get_closest_fork_with_solc_support(Cancun, Version.parse("0.8.24")) == Cancun
310-
assert get_closest_fork_with_solc_support(Prague, Version.parse("0.8.24")) == Cancun
311-
312-
313298
@pytest.mark.parametrize(
314299
"fork",
315300
[

src/ethereum_test_tools/tests/conftest.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/ethereum_test_tools/tests/test_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
from ethereum_test_types import Alloc, Environment, Transaction
2121
from ethereum_test_vm import Opcodes as Op
2222
from ethereum_test_vm import UndefinedOpcodes
23+
from pytest_plugins.solc.solc import SOLC_EXPECTED_MIN_VERSION
2324

2425
from ..code import CalldataCase, Case, Conditional, Initcode, Switch
25-
from .conftest import SOLC_PADDING_VERSION
2626

2727

2828
@pytest.fixture(params=get_deployed_forks())
@@ -36,15 +36,15 @@ def expected_bytes(request: pytest.FixtureRequest, solc_version: Version, fork:
3636
"""Return the expected bytes for the test."""
3737
expected_bytes = request.param
3838
if isinstance(expected_bytes, Template):
39-
if solc_version < SOLC_PADDING_VERSION or fork <= Homestead:
39+
if solc_version < SOLC_EXPECTED_MIN_VERSION or fork <= Homestead:
4040
solc_padding = ""
4141
else:
4242
solc_padding = "00"
4343
return bytes.fromhex(expected_bytes.substitute(solc_padding=solc_padding))
4444
if isinstance(expected_bytes, bytes):
4545
if fork >= Shanghai:
4646
expected_bytes = b"\x5f" + expected_bytes[2:]
47-
if solc_version < SOLC_PADDING_VERSION or fork <= Homestead:
47+
if solc_version < SOLC_EXPECTED_MIN_VERSION or fork <= Homestead:
4848
return expected_bytes
4949
else:
5050
return expected_bytes + b"\x00"

src/pytest_plugins/filler/static_filler.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
from _pytest.python import Module
1818

1919
from ethereum_test_fixtures import BaseFixture, LabeledFixtureFormat
20-
from ethereum_test_forks import (
21-
Fork,
22-
get_closest_fork_with_solc_support,
23-
get_forks_with_solc_support,
24-
)
20+
from ethereum_test_forks import Fork, get_closest_fork
2521
from ethereum_test_specs import BaseStaticTest, BaseTest
2622
from ethereum_test_tools.code.yul import Yul
2723

@@ -356,9 +352,8 @@ class so that upon instantiation within the test case, it provides the
356352
break
357353
else:
358354
pytest.fail(f"{request.node.name}: Fork {marker.args[0]} not found in forks list.")
359-
assert solc_target_fork in get_forks_with_solc_support(request.config.solc_version)
360355
else:
361-
solc_target_fork = get_closest_fork_with_solc_support(fork, request.config.solc_version)
356+
solc_target_fork = get_closest_fork(fork, request.config.solc_version)
362357
assert solc_target_fork is not None, "No fork supports provided solc version."
363358
if solc_target_fork != fork and request.config.getoption("verbose") >= 1:
364359
warnings.warn(

src/pytest_plugins/solc/solc.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pytest_metadata.plugin import metadata_key # type: ignore
88
from semver import Version
99

10-
from ethereum_test_forks import Frontier
10+
SOLC_EXPECTED_MIN_VERSION: Version = Version.parse("0.8.24")
1111

1212

1313
def pytest_addoption(parser: pytest.Parser):
@@ -53,7 +53,6 @@ def pytest_configure(config: pytest.Config):
5353
stderr=subprocess.STDOUT,
5454
text=True,
5555
check=True,
56-
timeout=10,
5756
)
5857
except subprocess.CalledProcessError as e:
5958
pytest.exit(
@@ -86,7 +85,7 @@ def pytest_configure(config: pytest.Config):
8685

8786
# Extract version number
8887
try:
89-
# Format is typically "Version: 0.8.24+commit.e11b9ed9.Linux.g++"
88+
# --version format is typically something like "0.8.24+commit.e11b9ed9.Linux.g++"
9089
version_str = version_line.split()[1].split("+")[0]
9190
solc_version_semver = Version.parse(version_str)
9291
except (IndexError, ValueError) as e:
@@ -104,10 +103,10 @@ def pytest_configure(config: pytest.Config):
104103
config.stash[metadata_key]["Tools"]["solc"] = str(solc_version_semver)
105104

106105
# Check minimum version requirement
107-
if solc_version_semver < Frontier.solc_min_version():
106+
if solc_version_semver < SOLC_EXPECTED_MIN_VERSION:
108107
pytest.exit(
109108
f"Unsupported solc version: {solc_version_semver}. Minimum required version is "
110-
f"{Frontier.solc_min_version()}",
109+
f"{SOLC_EXPECTED_MIN_VERSION}",
111110
returncode=pytest.ExitCode.USAGE_ERROR,
112111
)
113112

tests/cancun/eip6780_selfdestruct/test_selfdestruct_revert.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -511,44 +511,3 @@ def test_selfdestruct_not_created_in_same_tx_with_revert(
511511
)
512512

513513
state_test(env=env, pre=pre, post=post, tx=tx)
514-
515-
516-
@pytest.mark.valid_from("Cancun")
517-
def test_coverage_script_fix(
518-
state_test: StateTestFiller,
519-
env: Environment,
520-
pre: Alloc,
521-
):
522-
"""Fixes coverage script by making use of SWAP3 and JUMP."""
523-
env = Environment()
524-
sender = pre.fund_eoa()
525-
526-
account_code = (
527-
Op.PUSH1(0x08)
528-
+ Op.PUSH0
529-
+ Op.PUSH0
530-
+ Op.PUSH0
531-
+ Op.SWAP3
532-
+ Op.JUMP # jump to JUMPDEST when 0x08 is on top of stack
533-
+ Op.INVALID
534-
+ Op.JUMPDEST
535-
+ Op.STOP
536-
)
537-
538-
account = pre.deploy_contract(account_code)
539-
540-
tx = Transaction(
541-
ty=0x0,
542-
nonce=0,
543-
sender=sender,
544-
to=account,
545-
gas_limit=20_000_000,
546-
gas_price=10,
547-
value=0,
548-
data="",
549-
)
550-
551-
post = {}
552-
post[account] = Account(storage={})
553-
554-
state_test(env=env, pre=pre, post=post, tx=tx)

0 commit comments

Comments
 (0)