You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(forks): add SigScheme capability and @requires marker (Stage 7 of leanEthereum#686)
Introduces the first fork-level capability and a pytest marker to gate
tests on capability presence.
Capability
----------
- New `SigScheme` runtime-checkable Protocol in `forks/capabilities.py`
asserts a `sig_scheme: ClassVar[GeneralizedXmssScheme]` attribute.
- `LstarSpec` binds `sig_scheme = TARGET_SIGNATURE_SCHEME` so
`isinstance(LstarSpec(), SigScheme)` returns True.
- The three spec methods that previously took
`scheme=TARGET_SIGNATURE_SCHEME` (`verify_signatures`,
`on_gossip_attestation`, `on_block`) drop the parameter and read
`self.sig_scheme` directly. The capability becomes the runtime source
of truth.
Marker
------
- `requires(*capabilities)` pytest marker, registered in
`pytest_plugins/filler.py`. Composes (AND) with the existing
`valid_from` / `valid_until` / `valid_at` fork-range markers.
- `_check_markers_valid_for_fork` instantiates the active spec once and
runs `isinstance(spec, capability)` per required capability.
- A `requires(...)` helper in `framework.markers` works around pytest's
auto-detect-class shortcut (which trips on Protocol args to
`@pytest.mark.requires(...)`).
Tests
-----
- 11 unit tests in `tests/lean_spec/forks/test_capabilities.py` cover
the Protocol and the dispatch helper (composition with the
fork-range markers, multiple `@requires` markers, error path for
non-runtime_checkable Protocol).
- One smoke filler test in
`tests/consensus/lstar/test_capability_gating.py` exercises the
marker through pytest's live collection: one test marked with
SigScheme runs, one marked with a synthetic absent capability is
deselected.
Filler scheme override
----------------------
The three filler call sites that previously passed
`scheme=LEAN_ENV_TO_SCHEMES[self.lean_env]` to spec methods (in
`test_fixtures/fork_choice.py` and `test_types/block_spec.py`) drop the
kwarg. The PR description has the trade-off note and revert path if
that override is in fact needed somewhere we missed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(forks): tighten capability marker and apply review feedback
- Rename the marker helper to requires_capability and validate
runtime-checkable Protocols at call time (fail at import, not
at collection)
- Cache the fork spec instance in marker dispatch instead of
constructing it once per test
- Re-export the capabilities namespace from lean_spec.forks so
future capabilities don't need new import-site edits
- Register valid_from / valid_at / requires markers in pyproject
so unit tests can build real pytest Marks under strict-markers
- Drop the hand-rolled Mark stand-in in tests; build real Marks
via the MarkDecorator path; drop is True / is False on bool
predicates
- Tighten docstrings per project style (no paragraph blocks, no
backtick references, no internal-name references)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(forks): tighten dispatcher-guard test docstring
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
0 commit comments