refactor(network): update DMQ message structure#776
Conversation
This allows to enforce the computation of the DMQ message id based on the DMQ payload.
📝 WalkthroughWalkthroughThis PR refactors the DMQ message protocol by moving the ChangesDMQ Message Structure and Codec Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pallas-network/src/miniprotocols/localmsgsubmission/codec.rs`:
- Around line 31-33: The encode path is currently serializing the
caller-provided self.msg_id instead of deriving the id from the payload, so
compute the message id from self.msg_payload and serialize that computed id
instead of self.msg_id; locate the serialization block that calls e.array(5) /
e.bytes(&self.msg_id) / e.encode(&self.msg_payload) and replace the
e.bytes(&self.msg_id) step with bytes of the payload-derived id (using the same
hash/derivation routine used elsewhere in the crate or a private constructor),
ensuring the canonical id computation is used consistently before emitting
bytes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 49830b2c-4a52-4976-9bbc-7312f5ff3b8d
📒 Files selected for processing (3)
pallas-network/src/miniprotocols/localmsgsubmission/codec.rspallas-network/src/miniprotocols/localmsgsubmission/protocol.rspallas-network/tests/protocols.rs
| e.array(5)?; | ||
| e.bytes(&self.msg_id)?; | ||
| e.encode(&self.msg_payload)?; |
There was a problem hiding this comment.
Compute msg_id from msg_payload instead of serializing caller input.
This still allows invalid msg_id/payload pairs on the wire, so the PR objective of enforcing a payload-derived id is not met yet. The updated fixtures already demonstrate the gap by using the same msg_id for different payloads. Derive the id here (or behind a constructor/private field) rather than trusting self.msg_id.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pallas-network/src/miniprotocols/localmsgsubmission/codec.rs` around lines 31
- 33, The encode path is currently serializing the caller-provided self.msg_id
instead of deriving the id from the payload, so compute the message id from
self.msg_payload and serialize that computed id instead of self.msg_id; locate
the serialization block that calls e.array(5) / e.bytes(&self.msg_id) /
e.encode(&self.msg_payload) and replace the e.bytes(&self.msg_id) step with
bytes of the payload-derived id (using the same hash/derivation routine used
elsewhere in the crate or a private constructor), ensuring the canonical id
computation is used consistently before emitting bytes.
This PR includes updates of the DMA Protocol described in CIP-0137:
msg_idfield fromDmqMsgPayloadmsg_idfield toDmqMsgThese modifications are being reflected into a CIP update.
Summary by CodeRabbit
Refactor
Tests