Skip to content

Deduplicate domain types across crates #617

Description

@emlautarom1

Summary

Follow-up evidence for #127 ("Centralize helper at core") — the concrete duplicates:

  • AttesterDuty: 4 near-identical structscore/signeddata.rs#L1200-L1213 (no pubkey), testutil/validatormock/attest.rs (same + pubkey), eth2api/validator_duty.rs (3-field subset), tracker/inclusion.rs (2-field subset) — plus AttesterDutyDefinition, which exists only because the core struct dropped the pubkey.
  • ProposerDuty / SyncCommitteeDuty: same fields defined in eth2api and core with different newtypes and a field rename (validator_indexv_idx), bridged by Froms.
  • Validator pubkey: 3 representations (crypto::PublicKey = [u8;48], eth2api::BLSPubKey = [u8;48], core::PubKey([u8;48])), plus bare Vec<u8> pubkeys in 6 cluster::distvalidator fields. Signature: 2 aliases for [u8;96] bridged by no-op converters.
  • Slot: 3 shapesphase0::Slot = u64, core::SlotNumber(u64), and a core::Slot context struct sharing the name.
  • Selections: BeaconCommitteeSelection/SyncCommitteeSelection exist in three layers (eth2api canonical, core #[serde(transparent)] newtypes, and independent testutil redefinitions with identical fields).
  • Duplicate trait names across crates: two unrelated Consensus traits (consensus::wrapper vs priority::consensus) and two unrelated Clock traits (core::clock vs testutil::validatormock::clock — different time types; relates Unify time mocking strategy across the codebase #306).

Deliberate non-duplicates to leave alone: the cluster wire-version struct families (DistValidatorV1x..., LockV1x...) encode real format versions, and the generated-vs-spec split in eth2api is the eth2api replacement issue's territory (#611).

Proposed change

Pick the canonical home per concept (core for domain types, eth2api spec types at the API boundary), collapse the copies, and give the survivors the fields their consumers actually need (e.g. put pubkey back on AttesterDuty, deleting AttesterDutyDefinition). Rename one of the Consensus/Clock trait pairs.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    rustPull requests that update rust code

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions