Extract shared Protobuf conversion helpers; standardize prost `Option`/default handling
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 45/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- rust
調査の方向性
まず core/src/types.rs、consensus/src/qbft/msg.rs、priority/src/prioritiser.rs にある Duty の変換を比較し、次に core/unsigneddata.rs と cluster/build.rs の map 処理を調べます。共通の変換ヘルパーとエンコーディングヘルパーを設計する前に、hash_proto と protobuf のビルド設定を追跡してください。変換とゼロ値の規約が集約され、descriptor 駆動のテストで map フィールドがカバーされ、cluster/build.rs が pluto-build-proto を使用していれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
proto3 presence semantics as prost surfaces them (every message field is Option, scalars silently default) are handled ad hoc per crate:
Duty ↔ pbcore::Dutyis implemented three times with three failure semantics: fallibleTryFromincore/src/types.rs#L282-L304; a lossy infallibleduty_from_protoinconsensus qbft/msg.rs#L370-L382(None→Duty::new(0, Unknown)); and another infallible pair inpriority/src/prioritiser.rs#L73-L88. Two share the nameduty_from_protowith different tolerance.- ~11
.ok_or(...)unwrap sites and 15+Some(...)wrapping sites for message fields; duplicatedBTreeMap<String,_> ↔ HashMap<PubKey,_>transcode loops and empty-map-means-invalid checks betweencore/types.rsandcore/unsigneddata.rs. - Zero-value conventions are hand-rolled per site: "absent vs zero hash" (
msg.rs#L330-L337), "empty bytes means missing signature" (#L315-L317). cluster/build.rsinlines its ownprost_build::Configinstead of usingpluto-build-proto, silently skippingenable_type_names()and the lint-header injection every other crate gets.
Message-field presence is proto3, not prost — any generator carries the same absent-vs-default ambiguity, so the leverage is in centralizing the handling, not switching generators.
One default-value problem is prost-specific and needs a different fix. prost omits a map entry's key or value field when it equals the type default, where protoc and Go always emit both. Reference bytes from protoc 32.1, byte-identical to Go:
| value | protoc / Go |
prost |
|---|---|---|
UnsignedDataSet{"0xaa": b""} |
0a080a04307861611200 |
0a060a0430786161 |
UnsignedDataSet{"": b""} |
0a040a001200 |
0a00 |
map<string,int32>{"a": 0} |
0a050a01611000 |
0a030a0161 |
hash_proto SSZ-hashes those bytes into the QBFT consensus value hash, so a mixed pluto/charon cluster derives different hashes for an identical value and fails to agree with nothing erroring. It is settled upstream — prost#99 closed as working-as-intended, the omission being spec-permitted even though no Google implementation does it — so the correction has to live on pluto's side. ParSignedDataSet has the same exposure, latent only because it never reaches hash_proto.
Proposed change
- One conversion module in
core(relates #127): a single fallibleDutyconversion (callers that want lossy behavior make it explicit), afn required<T>(field: Option<T>, name: &'static str) -> Result<T, ProtoFieldError>helper replacing theok_orboilerplate, and the shared map-transcode helpers. - Document the zero-value conventions (zero hash = absent, empty bytes = absent) once, next to the helpers.
- Correct map-entry encoding once for every message rather than per hashing call site, and guard it with a descriptor-driven test: walk the
FileDescriptorSet(prost_buildemits one viafile_descriptor_set_path) and assert every map field in the workspace emits both entry fields for a zero-valued key and value. Without that guard, adding a map to a hashed message is a silent consensus divergence. - Route
cluster/build.rsthroughpluto-build-proto.
- 主要言語
- Rust
- スター
- 8
- フォーク
- 5
- 平均マージ
- 2時間 12分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NethermindEth/pluto のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
NethermindEth/pluto#719 ·
-
enhancement rust
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
NethermindEth/pluto#640 ·
-
enhancement rust
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
NethermindEth/pluto#635 ·
-
Improve `alpha test peers`: match Charon's probes; reduce timeouts対応中かも @varex83agent が 32 日前に担当しました。 オープンbug track:orchestration-cli
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
NethermindEth/pluto#632 ·
-
enhancement rust
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
NethermindEth/pluto#631 ·
NethermindEth/pluto の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
test(hydro_std): track_membership join and leave are untested対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
hydro-project/hydro#3289 ·
メンテナーはふだん 1 日以内に返信
-
diagram-bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
enhapu-afk/omaspec#4 ·
-
priority: low ☕️ type: bug 🐛
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
bug security
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 4 日以内に返信