Skip to content

test(validator): property-test slashing protection against the slashing conditions - #913

Open
pablodeymo wants to merge 1 commit into
test/ephyra-property-testsfrom
test/ephyra-slashing-protection
Open

pablodeymo wants to merge 1 commit into
test/ephyra-property-testsfrom
test/ephyra-slashing-protection

Conversation

@pablodeymo

Copy link
Copy Markdown
Collaborator

🗒️ Description / Motivation

Slashing protection is the last check between a validator client bug and a slashed key. This adds an ephyra property that drives the real on-disk record (src/slashing_protection/) through random sequences of what the client does with it, checked against two oracles that are not derived from the code:

  • Safety, from the consensus specs' slashing conditions. Nothing the record approves may be a double proposal, a double vote, or a surround vote with anything the same key signed. That covers messages signed here and messages in an imported history.
  • Exactness, from the documented rule (EIP-3076 minimal variant). An independent watermark model must give every verdict the record gives, refusal reason included. This catches refusing honest messages, not just approving bad ones.

Stacked on #904 (ephyra integration). It doesn't depend on #912.

What Changed

  • crates/validator/tests/slashing_protection_properties.rs (new). The steps are:
    • Signing: proposals; attestation batches, including a key listed twice; check_block.
    • Restarts: drop the record and reopen the directory.
    • Migration: export every key to an EIP-3076 interchange, import it into a fresh directory, then restart there.
    • Imports: complete interchanges for arbitrary histories, written by hand rather than by the module's own renderer, including invalid source/target pairs, which must refuse the whole file.
    • Registration of a previously unregistered key.
    • Relative votes: besides random votes, an honest next vote and a surround attempt, computed from the key's current watermarks when the step runs. Without these, surround refusals were reached in only 5–8% of cases; with them, about 55%.
  • crates/validator/Cargo.toml: ephyra dev-dependency. The lockfile change is one line.
  • docs/property_testing.md and CLAUDE.md: the new suite, its cost, and a findings entry.

Correctness / Behavior Guarantees

  • Test-only; no non-test code changes.
  • Cost: every approval is a durable write with fsync, as in production, so a 40-step case takes about 160 ms on macOS. The default is 100 cases, about 18 s locally (likely less on Linux CI). Longer hunts set EPHYRA_BUDGET_MS. If this is too slow for test-node, it can be marked #[ignore] and run by name instead.
  • The oracles demonstrably fire. I planted two bugs, one at a time, and reverted each:
    • Missing source-regression check: fails in two steps. Import a (1, 2) vote, then the surround attempt (0, 3) is wrongly approved.
    • A write that drops the changed watermarks: fails in one step (Migrate); the new directory's record has lost its keys.

Tests Added / Run

  • Result: no findings. 4,294 sequences of up to 40 steps (seeds 1–3, 4 minutes each).
    • Reached a surround refusal: 2,365.
    • Reached a double-vote refusal: 3,164.
    • Included a restart: 3,382.
    • Included a migration: 3,365.
    • An import raised a watermark: 2,541.
    • Every approval was safe, and every verdict matched the model.
  • cargo test --profile release-fast -p ethlambda-validator --test slashing_protection_properties: passes (100 cases).
  • cargo clippy --profile release-fast -p ethlambda-validator --all-targets -- -D warnings: clean.

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt — clean
  • Ran make lint (clippy with -D warnings) — clippy on ethlambda-validator only
  • Ran make test (test-consensus plus test-node, at release-fast) — the new test only

…ng conditions

Slashing protection is the one check between a validator client bug and a
slashed key. `slashing_protection_properties.rs` drives the real on-disk
record through random sequences of what the client does with it:
proposals, attestation batches (a key listed twice included), `check_block`,
restarts, a move to a fresh directory through an EIP-3076 export and
import, imported histories (complete interchanges, written by hand rather
than by the module's renderer) and registrations. Besides random votes, it
generates relative ones, an honest next vote and a surround attempt,
resolved against the key's marks when the step runs.

Two oracles, neither taken from the code:

- safety, from the consensus specs' slashing conditions: nothing the record
  approves is a double proposal, a double vote or a surround with anything
  the key signed, here or in an imported history;
- exactness, from the documented EIP-3076 minimal rule: an independent
  watermark model gives every verdict the record gives, refusal reason
  included, so honest messages are not refused either.

Every approval is a durable write, as in production, so a 40-step case
takes about 160 ms on macOS; the default is 100 cases, and longer hunts
set `EPHYRA_BUDGET_MS`.

Result: 4,294 sequences over 3 seeds (4 minutes each), clean. The oracles
are known to fire: a missing source-regression check fails in two steps
(import a (1, 2) vote, then attempt (0, 3)), and a write that drops the
changed marks fails in one (`Migrate`).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant