Skip to content

Add XCM benchmarking support#1450

Merged
Chralt98 merged 1 commit intomainfrom
chralt98-add-xcm-benchmarks
Nov 26, 2025
Merged

Add XCM benchmarking support#1450
Chralt98 merged 1 commit intomainfrom
chralt98-add-xcm-benchmarks

Conversation

@Chralt98
Copy link
Copy Markdown
Member

@Chralt98 Chralt98 commented Nov 24, 2025

What does it do?

Fixes #1425

What important points should reviewers know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues?

References

Summary by CodeRabbit

  • New Features
    • Added comprehensive Cross-Chain Message (XCM) functionality including teleportation, asset transfers, reserve transfers, version management, query resolution, and asset claims with full performance benchmarking integration
    • Expanded runtime benchmarking infrastructure to support and measure parachain operations
    • Enhanced cross-chain interoperability through extended dependency support and runtime configuration

✏️ Tip: You can customize this high-level summary in your review settings.

@Chralt98 Chralt98 self-assigned this Nov 24, 2025
@Chralt98 Chralt98 added the s:review-needed The pull request requires reviews label Nov 24, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 24, 2025

Walkthrough

This PR introduces pallet_xcm weight benchmarking support by adding conditional WeightInfo trait implementations in the template, wiring pallet_xcm configuration in the runtime, creating autogenerated weight modules, and extending benchmark dependencies and scripts.

Changes

Cohort / File(s) Summary
Weight Template & Benchmarking Config
misc/frame_weight_template.hbs, scripts/benchmarks/configuration.sh
Modified template to conditionally select WeightInfo path: pallet_xcm::WeightInfo for pallet_xcm, {{pallet}}::weights::WeightInfo for others. Added pallet_xcm to FRAME_PALLETS_PARACHAIN array.
Runtime Configuration
runtime/battery-station/src/lib.rs, runtime/zeitgeist/src/lib.rs
Added crate-level #![allow(non_local_definitions)] attribute to both runtime crates.
Cargo Dependencies
runtime/common/Cargo.toml
Added optional workspace dependencies for benchmarking and XCM (frame-benchmarking, frame-system-benchmarking, orml-benchmarking, pallet-xcm, xcm, xcm-builder, xcm-executor). Extended parachain, runtime-benchmarks, and std features with corresponding enablements.
Runtime pallet_xcm Integration
runtime/common/src/lib.rs
Added XcmReserveTransferFilter to cumulus_pallet_xcm::Config with conditional defaults (Everything for runtime-benchmarks, Nothing otherwise). Changed pallet_xcm WeightInfo from TestWeightInfo to weights::pallet_xcm::WeightInfo.
Weight Module Exports
runtime/common/src/weights/mod.rs
Added public pallet_xcm module export under parachain feature guard.
pallet_xcm Weight Implementation
runtime/common/src/weights/pallet_xcm.rs
New autogenerated weight module providing WeightInfo struct and trait implementation for pallet_xcm with weight functions for all extrinsics (send, teleport_assets, reserve_transfer_assets, transfer_assets, execute, force_xcm_version, migrations, query operations, and claim_assets).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Template conditional logic for WeightInfo path selection requires verification
  • Autogenerated weight calculations should be spot-checked for accuracy
  • Runtime configuration changes for cumulus_pallet_xcm::Config and WeightInfo wiring need validation

Possibly related PRs

  • zeitgeistpm/zeitgeist#1444 — Directly related broad weights update that also adds and implements pallet_xcm weights with runtime/common weight wiring.

Suggested labels

s:accepted

Suggested reviewers

  • robhyrk
  • saboonikhil

Poem

🐰 The template now knows which path to take,
For pallet_xcm, a special case to make,
With weights and configs all in place,
Benchmarks flow with elegant grace,
XCM support hops along our race! 🚀

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add XCM benchmarking support' clearly and concisely describes the main change: introducing benchmarking capabilities for the XCM (Cross-Chain Messaging) system, which is directly supported by changes across multiple files including new weight modules, Cargo.toml dependencies, and benchmark configuration.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chralt98-add-xcm-benchmarks

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: 0

🧹 Nitpick comments (1)
runtime/battery-station/src/lib.rs (1)

21-21: Verify necessity of broad lint suppression.

The #![allow(non_local_definitions)] attribute suppresses warnings crate-wide. This is often needed for macro-generated code in Substrate runtimes, but consider documenting why this suppression is necessary (e.g., which macros trigger it) to help future maintainers understand the rationale.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5960a02 and ac10fa9.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • misc/frame_weight_template.hbs (1 hunks)
  • runtime/battery-station/src/lib.rs (1 hunks)
  • runtime/common/Cargo.toml (5 hunks)
  • runtime/common/src/lib.rs (6 hunks)
  • runtime/common/src/weights/mod.rs (1 hunks)
  • runtime/common/src/weights/pallet_xcm.rs (1 hunks)
  • runtime/zeitgeist/src/lib.rs (1 hunks)
  • scripts/benchmarks/configuration.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Coverage
  • GitHub Check: Test parachain build
  • GitHub Check: Fuzz
  • GitHub Check: Quick check benchmarks
  • GitHub Check: Test standalone build
  • GitHub Check: Format
  • GitHub Check: Checks (parachain)
  • GitHub Check: Checks (clippy)
  • GitHub Check: Checks (standalone)
  • GitHub Check: Summary
🔇 Additional comments (10)
scripts/benchmarks/configuration.sh (1)

16-20: LGTM!

The addition of pallet_xcm to the parachain pallets benchmarking list is correct and aligns with the PR objectives.

runtime/zeitgeist/src/lib.rs (1)

21-21: Same lint suppression as battery-station runtime.

See the comment on runtime/battery-station/src/lib.rs:21 regarding this lint suppression.

runtime/common/Cargo.toml (1)

1-108: LGTM!

The addition of benchmarking and XCM dependencies is well-structured with proper optional dependency handling and feature flags. The use of ? syntax correctly handles conditional feature enablement.

runtime/common/src/lib.rs (3)

616-619: LGTM - Appropriate security configuration.

The conditional XcmReserveTransferFilter is correctly configured:

  • Everything during benchmarks allows testing all code paths
  • Nothing in production is a safe default that restricts reserve transfers

This is a security-sensitive setting and the conservative production default is appropriate.


628-628: LGTM - Switches to production weights.

Correctly replaces TestWeightInfo with the autogenerated weights::pallet_xcm::WeightInfo<Runtime>. This is essential for proper weight accounting in production.


1783-2012: LGTM - Comprehensive benchmarking configuration.

The pallet_xcm benchmarking setup is well-implemented:

  • Properly gated with #[cfg(feature = "parachain")]
  • TestDeliveryHelper correctly funds accounts for benchmark execution
  • benchmarking::Config implementation provides all required methods
  • Asset and location handling appears correct
runtime/common/src/weights/mod.rs (1)

27-27: LGTM!

The export of pallet_xcm weights module is correctly placed under the parachain feature guard, consistent with other parachain-specific weight modules.

misc/frame_weight_template.hbs (1)

23-23: LGTM - Handles pallet_xcm's different module structure.

The conditional logic correctly accounts for pallet_xcm having its WeightInfo trait directly in the pallet module (pallet_xcm::WeightInfo) rather than in a submodule (pallet_xcm::weights::WeightInfo) like other pallets.

runtime/common/src/weights/pallet_xcm.rs (2)

72-80: Verify intentionally disabled benchmarks.

The teleport_assets function shows a weight of 18_446_744_073_709_551_000 (u64::MAX) and references Benchmark::Override storage, suggesting this benchmark is intentionally disabled or not supported. Please confirm this is intentional and consider adding a comment explaining why these operations are not benchmarked (e.g., if teleport assets are not supported in this runtime configuration).

The same pattern appears for the execute function at lines 123-130.


56-320: LGTM - Autogenerated weights look correct.

The autogenerated weight implementations follow the expected pattern with proper storage access annotations and reasonable weight calculations. The file is well-structured and includes all necessary pallet_xcm extrinsics.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 24, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.32%. Comparing base (5960a02) to head (ac10fa9).
⚠️ Report is 3 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1450   +/-   ##
=======================================
  Coverage   93.32%   93.32%           
=======================================
  Files         181      181           
  Lines       34769    34769           
=======================================
  Hits        32448    32448           
  Misses       2321     2321           
Flag Coverage Δ
tests 93.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Chralt98 Chralt98 merged commit e365af7 into main Nov 26, 2025
13 checks passed
@Chralt98 Chralt98 deleted the chralt98-add-xcm-benchmarks branch November 26, 2025 10:35
@Chralt98 Chralt98 added s:accepted This pull request is ready for merge and removed s:review-needed The pull request requires reviews labels Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s:accepted This pull request is ready for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Pallet XCM benchmarks and weights

3 participants