Skip to content

refactor(network): update DMQ message structure#776

Merged
scarmuega merged 1 commit into
txpipe:mainfrom
cardano-scaling:jpraynaud/update-dmq-message-payload
May 12, 2026
Merged

refactor(network): update DMQ message structure#776
scarmuega merged 1 commit into
txpipe:mainfrom
cardano-scaling:jpraynaud/update-dmq-message-payload

Conversation

@jpraynaud
Copy link
Copy Markdown
Contributor

@jpraynaud jpraynaud commented May 12, 2026

This PR includes updates of the DMA Protocol described in CIP-0137:

  • The structure of the DMQ message has evolved:
    • removed the msg_id field from DmqMsgPayload
    • added the msg_id field to DmqMsg
  • The tests and golden vectors have been updated accordingly.

These modifications are being reflected into a CIP update.

Summary by CodeRabbit

  • Refactor

    • Restructured message format in the local message submission protocol with reorganized field placement and updated serialization layout
  • Tests

    • Updated unit tests and test fixtures to align with the new message structure and field organization

Review Change Stack

This allows to enforce the computation of the DMQ message id based on the DMQ payload.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

This PR refactors the DMQ message protocol by moving the msg_id field from DmqMsgPayload to the outer DmqMsg struct, and updates the CBOR serialization format accordingly. The codec now encodes DmqMsg as a 5-element array and DmqMsgPayload as a 3-element array, with unit and integration tests updated to match.

Changes

DMQ Message Structure and Codec Refactoring

Layer / File(s) Summary
Data model restructuring
pallas-network/src/miniprotocols/localmsgsubmission/protocol.rs
DmqMsg struct adds a msg_id: Vec<u8> field; DmqMsgPayload struct removes msg_id field and now contains only msg_body, kes_period, and expires_at.
CBOR codec serialization logic
pallas-network/src/miniprotocols/localmsgsubmission/codec.rs
DmqMsg decoder/encoder handle a 5-element CBOR array with msg_id as the first element; DmqMsgPayload decoder/encoder handle a 3-element CBOR array without msg_id. Both simple and real-bytes unit tests are updated with new expected CBOR byte vectors, and the protocol golden test for bytes_to_sign() is updated to reflect the new payload structure.
Integration test fixture updates
pallas-network/tests/protocols.rs
Test helpers in fake_msgs() and fake_msg() now construct DmqMsg instances with msg_id: vec![1, 2, 3].

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • txpipe/pallas#706: Modifies the same DMQ message encoding and structure in pallas-network's localmsgsubmission module, affecting codec and protocol definitions.

Suggested reviewers

  • scarmuega
  • turmelclem

Poem

🐰 A message's identity, once nested deep,
Now rests at the top where structures leap—
Five elements now in CBOR's array,
Three in the payload, a tidier way.
hops — the refactoring dances in grace!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main structural change: moving msg_id from DmqMsgPayload to DmqMsg, which is the primary objective across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c2eaac and 605511c.

📒 Files selected for processing (3)
  • pallas-network/src/miniprotocols/localmsgsubmission/codec.rs
  • pallas-network/src/miniprotocols/localmsgsubmission/protocol.rs
  • pallas-network/tests/protocols.rs

Comment on lines +31 to 33
e.array(5)?;
e.bytes(&self.msg_id)?;
e.encode(&self.msg_payload)?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

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.

@scarmuega scarmuega merged commit e2022d4 into txpipe:main May 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants