Skip to content

Conversation

JoeCap08055
Copy link
Collaborator

Goal

The goal of this PR is to migrate the messages pallet to add schema_id to message storage, and use intent_id as the index instead.

Existing index values do not need to be changed, as the schemas pallet migration ensures that the chain is seeded with Intent IDs that match existing Schema IDs

Related to #2581

Checklist

  • Updated Pallet Readme?
  • Updated js/api-augment for Custom RPC APIs?
  • Design doc(s) updated?
  • Unit Tests added?
  • e2e Tests added?
  • Benchmarks added?
  • Spec version incremented?

Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 72.19251% with 52 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pallets/messages/src/types.rs 54.43% 36 Missing ⚠️
common/primitives/src/messages.rs 0.00% 13 Missing ⚠️
pallets/messages/src/migration/v3.rs 97.26% 2 Missing ⚠️
pallets/messages/src/migration/v2/mod.rs 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
pallets/messages/src/lib.rs 91.91% <100.00%> (ø)
pallets/messages/src/rpc/src/lib.rs 96.07% <100.00%> (ø)
pallets/messages/src/migration/v2/mod.rs 50.00% <50.00%> (ø)
pallets/messages/src/migration/v3.rs 97.26% <97.26%> (ø)
common/primitives/src/messages.rs 92.54% <0.00%> (ø)
pallets/messages/src/types.rs 58.06% <54.43%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 30, 2025
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made the following enhancements for try-runtime-* targets:

  • Only build the runtime, not the entire node; speeds up the build
  • Consolidate targets using patterns to avoid duplicated targets/commands
  • Fetch state for a minimal set of system pallets so that multi-block migrations can be properly tested
  • Allow the use of the PALLETS env var to specify additional pallets for dumping/restoring state

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Revert types here; need to remain compatible with existing custom RPC

Comment on lines -82 to -87
// Max payload size was picked specifically to be large enough to accommodate
// a CIDv1 using SHA2-256, but too small to accommodate CIDv1 w/SHA2-512.
// This is purely so that we can test the error condition. Real world configuration
// should have this set large enough to accommodate the largest possible CID.
// Take care when adding new tests for on-chain (not IPFS) messages that the payload
// is not too big.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was an erroneous assumption. Since the configured value would never be this small on mainnet or testnet, it's better to allow a CIDv1/SHA2-512 by size, and have it fail for CID validation instead of for size reasons.

/// Helper function to generate message payloads
///
/// # Arguments
/// * `num_items` - Number of message to include in payload
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This seemed overly complicated--a payload is just an array of bytes; why all the JSON stuff?

@github-actions github-actions bot removed metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 30, 2025
Comment on lines +393 to +394
let cid = Cid::read_bytes(&cid_b[..]).map_err(|_| Error::<T>::InvalidCid)?;
ensure!([SHA2_256, BLAKE3].contains(&cid.hash().code()), Error::<T>::InvalidCid);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When cleaning up the mocks for the tests, noticed that it was attempting to test failure to accept CIDv1 (SHA2-512) by setting the max payload length artificially small.

The more correct approach (and what was missing from the code, eclipsed by that artificial test scenario) is to reject any CIDs with an unsupported hash. DSNP supports ONLY SHA2-256 and Blake3.

@JoeCap08055 JoeCap08055 marked this pull request as ready for review September 30, 2025 20:06
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 30, 2025
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented and removed metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented labels Sep 30, 2025
@JoeCap08055 JoeCap08055 changed the title 2581 update messages and stateful storage pallets to support intents 2581 update messages pallet to support intents Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metadata-changed Metadata has changed since the latest full release metadata-version-not-incremented Metadata has changed since the latest full release, but the version has not been incremented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants