Skip to content

refactor(validator_store): split validator_store/src/lib.rs into cohesive modules #868

@diegomrsantos

Description

@diegomrsantos

Description

anchor/validator_store/src/lib.rs is currently very large and mixes multiple concerns.

Current snapshot (from unstable @ a27f6def2):

  • ~2,980 lines
  • ~78 function definitions
  • responsibility mix: assignment caching/watch channels, QBFT/signature orchestration, proposer/attester/sync flows, slashing-protection lifecycle, and local helper types/tests

This makes the file hard to read, review, and safely modify.

Goal: split lib.rs into cohesive internal modules with no behavior change and no external API break.

Version

  • Anchor branch/commit: unstable @ a27f6def2
  • Rust: rustc 1.93.1 (01f6ddf75 2026-02-11)

Present Behaviour

Most validator-store logic lives in one monolithic file, making it difficult to:

  • identify ownership boundaries
  • reason about side-effects
  • review refactors in small, safe increments

Expected Behaviour

Validator-store internals are organized into focused modules, for example:

  • context/assignments cache and watch-channel flow
  • proposer/block signing + builder-related flow
  • attestation/aggregate flow
  • sync committee flow
  • slashing-protection helpers and shared utilities

AnchorValidatorStore remains the crate entry point and public behavior remains unchanged.

Steps to resolve

  1. Create internal modules under anchor/validator_store/src/ and move logic by responsibility.
  2. Keep public API stable (AnchorValidatorStore + existing trait behavior).
  3. Move/adjust tests from lib.rs into per-module tests or mod tests files as appropriate.
  4. Keep lib.rs as a thin composition layer (exports, wiring, constructor, module imports).
  5. Validate no regressions:
    • cargo test -p anchor_validator_store
    • targeted integration tests that cover proposer/attester/sync signing paths

Acceptance criteria

  • No functional behavior change
  • No public API breakage for downstream crates
  • lib.rs is significantly reduced and acts primarily as composition
  • Existing tests pass; any moved tests continue to cover equivalent behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions