Deduplicate domain types across crates

未关闭
#617 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
28/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
rust

调研方向

首先阅读 core/signeddata.rs、core/types.rs、eth2api/validator_duty.rs、tracker/inclusion.rs 和 testutil/validatormock/attest.rs 中引用的定义,然后跟踪 From 转换和重复的 trait 定义。完成的标准是:列出的每个概念都有一个规范归属位置,重复的表示形式和无操作桥接都已移除,并且有意保留的 wire-version 和 generated-vs-spec 系列保持不变。

由索引模型根据 Issue 内容生成。

描述

rust

Summary

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

  • AttesterDuty: 4 near-identical structs — core/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_index → v_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 shapes — phase0::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.

主要语言
Rust
星标
8
派生
5
平均合并
3 天 1 小时
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NethermindEth/pluto 的其他 Issue

查看 NethermindEth/pluto 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。