Raptorcast: Canonicalize depth and reserved fields - #3247
xinyuan-dev wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A newly added test asserts the wrong expected InvalidMode byte value (it doesn’t match the actual mutated mode/depth byte), which will cause test failures.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens Raptorcast v1 receiver-side validation by enforcing reserved-field rules and rejecting chunks whose Merkle tree depth is valid-but-non-canonical for the receiver’s expected parameters, aligning parsing/ingestion behavior with v1 packet invariants.
Changes:
- Enforce v1 reserved-field rules in packet parsing (reserved bits in mode/depth byte; reserved
u16in chunk header). - Plumb
merkle_tree_depththroughValidatedChunkand reject deterministic primary/secondary chunks whose depth is non-canonical for the receiver. - Add/extend deterministic tests for reserved-field rejection and non-canonical depth handling.
File summaries
| File | Description |
|---|---|
| monad-raptorcast/src/udp.rs | Reject deterministic chunks early when Merkle tree depth is non-canonical; add tests for reserved fields and depth rejection. |
| monad-raptorcast/src/parser/packet_parser.rs | Add v1 reserved-field validation and carry merkle_tree_depth into validated chunk metadata/errors. |
| monad-raptorcast/src/round_info.rs | Update test helper ValidatedChunk construction to include merkle_tree_depth. |
| monad-raptorcast/src/decoding.rs | Update decoding tests’ ValidatedChunk construction to include merkle_tree_depth. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4681a53 to
bd2c995
Compare
ec89401 to
e021dd7
Compare
|
@claude review |
|
Claude finished @xinyuan-dev's task in 5m 27s —— View job Review of PR #3247 — Canonicalize depth and reserved fields
Note: the code on the branch has been substantially reworked since the earlier automated reviews — the per-packet depth check in OverallThe design is sound. Enforcing depth canonicality via symbol length works because Findings1. Three panics on a network-input path in The function has two
Each is currently correct, but the guards live in the parser and udp routing, several layers away, and 2. The early rejection is best-effort, not airtight — worth a comment — low The check compares the observed symbol length to the canonical one, but the symbol length on the wire is attacker-chosen independently of the Merkle depth: a sender can build a packet with non-canonical depth 3. Validator-set skew now warns per chunk with no metric — low (carries over from the earlier bot review) If the receiver's epoch validator set differs from the sender's enough to shift the canonical depth (the removed udp test showed depth 9 vs 7 for 16 KiB at 100 vs 10 validators), every chunk of the proposal fails at decoder open. Each failure emits a 4. Minor nits
Not verifiedI could not run |
e021dd7 to
7f958e2
Compare
i removed the panics.
this claim is not true for v1. in v1, the segment length is fixed. so the symbol length is canonical iff depth is canonical.
live validators are expected to have their validator sets in sync, so no two honest validators have mismatching validator set for a given round, even at epoch boundaries. for lagging validators, blocks are sync'ed through blocksync/statesync. |
This PR enforces v1 packet rules the receiver was not previously checking.
modefieldThese changes are made to align with the MIP specification.