NethermindEth / NethermindEth/pluto

Deduplicate domain types across crates

Open
#617 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rust
Dominant language
Rust
Stars
8
Forks
5
Avg merge
4d 16h
Merged PRs (30d)
37

Description

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 #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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the cited definitions in core/signeddata.rs, core/types.rs, eth2api/validator_duty.rs, tracker/inclusion.rs, and testutil/validatormock/attest.rs, then trace the From conversions and duplicate trait definitions. Done means each listed concept has a canonical home, duplicate representations and no-op bridges are removed, and the deliberate wire-version and generated-vs-spec families remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
distributed-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.