Skip to content

Commit 273d7a8

Browse files
marioevzCopilotdanceratopz
authored
feat(specs,filler,ci): Merge static tests into stable/develop, make --generate-all-formats compatible with static tests (#2006)
* feat(ci): Embed static tests into stable and develop * fix(cli): Remove the `--fill-static-tests` limitation from two-phase filling * fix(specs,fixtures): Allow fixture formats to skip a test from being filled based on its markers * feat(fixtures): Add FixtureFillingPhase * refactor(fill): Fixture format selection in normal and static tests * fix: tox * docs: changelog * Update src/pytest_plugins/filler/filler.py Co-authored-by: Copilot <[email protected]> * refactor(fill): extract phase management into testable components (#2010) * feat(filler): add PhaseManager and FormatSelector classes with unit tests Extract phase determination and format selection logic into clean, testable classes. This prepares for simplifying the complex conditional logic in the filler plugins. - Add PhaseManager class with from_config() factory method. - Add FormatSelector class with strategy-based format selection. - Add comprehensive unit tests for both classes. - Test all flag combinations including generate_all_formats edge case. - Document two-phase execution model (separate pytest runs). - Maintain backward compatibility with existing functions. * feat(filler): add FillingSession class with unit tests - Add FillingSession class to manage all state for a single pytest run. - Encapsulates phase management, format selection, and pre-alloc groups. - Handles loading/saving pre-alloc groups between phases. - Provides xdist support for aggregating worker groups. - Add comprehensive unit tests for all FillingSession functionality. - Fix parameter naming to avoid shadowing Python builtin 'hash'. * refactor(filler): Refactor pytest_configure and pytest_sessionstart - Updated pytest_configure to use FillingSession instance - Store phase info on config for backward compatibility - Simplified pytest_sessionstart to delegate to FillingSession - All pre-alloc group management now handled by FillingSession * refactor(filler): Refactor pytest_generate_tests and format selection - Updated pytest_generate_tests to use FillingSession.should_generate_format(). - Refactored base_test_parametrizer to use FillingSession for pre-alloc management. - Replaced direct config access with session methods throughout. - All format selection logic now centralized in FillingSession. * refactor(filler): Update static_filler to use shared session - Replaced select_format_by_phases import with get_filling_session. - Updated format selection logic to use FillingSession.should_generate_format(). - Removed unused generate_all_formats variable. - All phase management now delegated to FillingSession. * refactor(filler): Remove old phase management functions and cleanup - Removed _determine_filling_phases() function. - Removed select_format_by_phases() function. - Updated remaining direct config access to use FillingSession. - Simplified config attribute management. - Removed unused Tuple import. * style(fill): use relative imports in test modules Co-authored-by: Copilot <[email protected]> Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> style(fill): fix-up imports * refactor(filler): Remove global session and use config-based approach - Removed global _filling_session variable and get_filling_session() function. - Store FillingSession directly on config object (config.filling_session). - Updated all references to access session from config objects directly. - Added type: ignore comments for mypy compatibility. - Removed global session tests as they're no longer applicable. - More aligned with standard pytest plugin patterns. * refactor: typing * fix: unit tests * fix: docs issue --------- Co-authored-by: Mario Vega <[email protected]> * fix(ci): Ignore `stQuadraticComplexityTest` in fixture building process * fix(ci): Up timeout of fixture building workflows * fix(fixtures): Re-enable engine x for untagged static tests --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: danceratopz <[email protected]>
1 parent e4a764c commit 273d7a8

File tree

14 files changed

+1057
-189
lines changed

14 files changed

+1057
-189
lines changed

.github/configs/feature.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Unless filling for special features, all features should fill for previous forks (starting from Frontier) too
22
stable:
33
evm-type: stable
4-
fill-params: --until=Prague
4+
fill-params: --until=Prague --fill-static-tests --ignore=tests/static/state_tests/stQuadraticComplexityTest
55

66
develop:
77
evm-type: develop
8-
fill-params: --until=Osaka
9-
10-
static: # TODO: remove and add `--fill-static-tests` to both develop & static
11-
evm-type: static
12-
fill-params: --until=Osaka --fill-static-tests ./tests/static
8+
fill-params: --until=Osaka --fill-static-tests --ignore=tests/static/state_tests/stQuadraticComplexityTest
139

1410
benchmark:
1511
evm-type: benchmark # Evmone only fully supports up to Prague

.github/workflows/fixtures.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
release_name: ${{ matrix.name }}
6161
uv_version: ${{ vars.UV_VERSION }}
6262
python_version: ${{ vars.DEFAULT_PYTHON_VERSION }}
63+
timeout-minutes: 720
6364
release:
6465
runs-on: ubuntu-latest
6566
needs: build

.github/workflows/fixtures_feature.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
release_name: ${{ matrix.feature }}
5656
uv_version: ${{ vars.UV_VERSION }}
5757
python_version: ${{ vars.DEFAULT_PYTHON_VERSION }}
58+
timeout-minutes: 720
5859
release:
5960
runs-on: ubuntu-latest
6061
needs: build

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Test fixtures for use by clients are available for each release on the [Github r
1111
- Python 3.10 support was removed in this release ([#1808](https://github.com/ethereum/execution-spec-tests/pull/1808)).
1212
- Tests for the Prague fork are now marked as stable will be included in the `fixtures_stable.tar.gz` tarball from now on.
1313
- Tests for the Osaka fork are now included in the `fixtures_develop.tar.gz` tarball.
14+
- `fixtures_static.tar.gz` has been deprecated and filled static tests are now included in `fixtures_stable.tar.gz` and `fixtures_develop.tar.gz`.
1415

1516
#### 💥 Important Change for EEST developers
1617

@@ -80,6 +81,7 @@ Users can select any of the artifacts depending on their testing needs for their
8081
- ✨ Generate unique addresses with Python for compatible static tests, instead of using hard-coded addresses from legacy static test fillers ([#1781](https://github.com/ethereum/execution-spec-tests/pull/1781)).
8182
- ✨ Added support for the `--benchmark-gas-values` flag in the `fill` command, allowing a single genesis file to be used across different gas limit settings when generating fixtures. ([#1895](https://github.com/ethereum/execution-spec-tests/pull/1895)).
8283
- ✨ Static tests can now specify a maximum fork where they should be filled for ([#1977](https://github.com/ethereum/execution-spec-tests/pull/1977)).
84+
- ✨ Static tests can now be filled in every format using `--generate-all-formats` ([#2006](https://github.com/ethereum/execution-spec-tests/pull/2006)).
8385

8486
#### `consume`
8587

src/cli/pytest_commands/fill.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ def _should_use_two_phase_execution(self, args: List[str]) -> bool:
153153
"--generate-pre-alloc-groups" in args
154154
or "--generate-all-formats" in args
155155
or self._is_tarball_output(args)
156-
) and (
157-
"--fill-static-tests"
158-
not in args # TODO: remove this once we have better grouping for static tests
159156
)
160157

161158
def _ensure_generate_all_formats_for_tarball(self, args: List[str]) -> List[str]:

src/ethereum_test_fixtures/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Ethereum test fixture format definitions."""
22

3-
from .base import BaseFixture, FixtureFormat, LabeledFixtureFormat
3+
from .base import BaseFixture, FixtureFillingPhase, FixtureFormat, LabeledFixtureFormat
44
from .blockchain import (
55
BlockchainEngineFixture,
66
BlockchainEngineFixtureCommon,
@@ -25,6 +25,7 @@
2525
"EOFFixture",
2626
"FixtureCollector",
2727
"FixtureConsumer",
28+
"FixtureFillingPhase",
2829
"FixtureFormat",
2930
"LabeledFixtureFormat",
3031
"PreAllocGroups",

src/ethereum_test_fixtures/base.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import hashlib
44
import json
5+
from enum import Enum, auto
56
from functools import cached_property
6-
from typing import Annotated, Any, ClassVar, Dict, Type, Union
7+
from typing import Annotated, Any, ClassVar, Dict, List, Set, Type, Union
78

9+
import pytest
810
from pydantic import (
911
Discriminator,
1012
Field,
@@ -38,6 +40,13 @@ def fixture_format_discriminator(v: Any) -> str | None:
3840
return fixture_format
3941

4042

43+
class FixtureFillingPhase(Enum):
44+
"""Execution phase for fixture generation."""
45+
46+
PRE_ALLOC_GENERATION = auto()
47+
FILL = auto()
48+
49+
4150
class BaseFixture(CamelModel):
4251
"""Represents a base Ethereum test fixture of any type."""
4352

@@ -51,6 +60,7 @@ class BaseFixture(CamelModel):
5160
format_name: ClassVar[str] = ""
5261
output_file_extension: ClassVar[str] = ".json"
5362
description: ClassVar[str] = "Unknown fixture format; it has not been set."
63+
format_phases: ClassVar[Set[FixtureFillingPhase]] = {FixtureFillingPhase.FILL}
5464

5565
@classmethod
5666
def output_base_dir_name(cls) -> str:
@@ -145,6 +155,15 @@ def supports_fork(cls, fork: Fork) -> bool:
145155
"""
146156
return True
147157

158+
@classmethod
159+
def discard_fixture_format_by_marks(
160+
cls,
161+
fork: Fork,
162+
markers: List[pytest.Mark],
163+
) -> bool:
164+
"""Discard a fixture format from filling if the appropriate marker is used."""
165+
return False
166+
148167

149168
class LabeledFixtureFormat:
150169
"""
@@ -179,9 +198,14 @@ def __init__(
179198

180199
@property
181200
def format_name(self) -> str:
182-
"""Get the execute format name."""
201+
"""Get the filling format name."""
183202
return self.format.format_name
184203

204+
@property
205+
def format_phases(self) -> Set[FixtureFillingPhase]:
206+
"""Get the filling format phases where it should be included."""
207+
return self.format.format_phases
208+
185209
def __eq__(self, other: Any) -> bool:
186210
"""
187211
Check if two labeled fixture formats are equal.

src/ethereum_test_fixtures/blockchain.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ClassVar,
88
List,
99
Literal,
10+
Set,
1011
Tuple,
1112
Union,
1213
cast,
@@ -43,7 +44,7 @@
4344
from ethereum_test_types.block_types import WithdrawalGeneric
4445
from ethereum_test_types.transaction_types import TransactionFixtureConverter, TransactionGeneric
4546

46-
from .base import BaseFixture
47+
from .base import BaseFixture, FixtureFillingPhase
4748
from .common import FixtureAuthorizationTuple, FixtureBlobSchedule
4849

4950

@@ -556,6 +557,10 @@ class BlockchainEngineXFixture(BlockchainEngineFixtureCommon):
556557

557558
format_name: ClassVar[str] = "blockchain_test_engine_x"
558559
description: ClassVar[str] = "Tests that generate a Blockchain Test Engine X fixture."
560+
format_phases: ClassVar[Set[FixtureFillingPhase]] = {
561+
FixtureFillingPhase.FILL,
562+
FixtureFillingPhase.PRE_ALLOC_GENERATION,
563+
}
559564

560565
pre_hash: str
561566
"""Hash of the pre-allocation group this test belongs to."""

src/ethereum_test_specs/blockchain.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,14 @@ def discard_fixture_format_by_marks(
437437
markers: List[pytest.Mark],
438438
) -> bool:
439439
"""Discard a fixture format from filling if the appropriate marker is used."""
440-
if "blockchain_test_only" in [m.name for m in markers]:
441-
return fixture_format != BlockchainFixture
442-
if "blockchain_test_engine_only" in [m.name for m in markers]:
443-
return fixture_format != BlockchainEngineFixture
440+
marker_names = [m.name for m in markers]
441+
if fixture_format != BlockchainFixture and "blockchain_test_only" in marker_names:
442+
return True
443+
if (
444+
fixture_format not in [BlockchainEngineFixture, BlockchainEngineXFixture]
445+
and "blockchain_test_engine_only" in marker_names
446+
):
447+
return True
444448
return False
445449

446450
def get_genesis_environment(self, fork: Fork) -> Environment:

0 commit comments

Comments
 (0)