Skip to content

Storage migration for pallet-xcm SafeXcmVersion constant #2422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mattheworris
Copy link
Collaborator

@mattheworris mattheworris commented May 29, 2025

This pull request introduces several changes to support bridging functionality. Key updates include adding new features for bridging pallets, extending Makefile targets for bridging-related builds and checks, and updating documentation and configuration files to reflect these additions.

Discussion

  • Implemented pallet_xcm::on_runtime_upgrade and tests to correctly set SafeXcmVersion.
  • Introduced new Makefile targets for bridging builds, checks, and runtime migrations (build-bridging-westend, check-bridging, try-runtime-check-migrations-westend-testnet, etc.).

Closes #2401

Testing

  • Unit tests will check the storage migrations.
  1. Run make start-bridging-westend-local in a terminal.
  2. In another terminal, run make try-rumtime-check-migrations-local (pre and post checks) or make try-runtime-check-migrations-none-local (checks=none).

Checklist

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

## Summary
- add SAFE_XCM_VERSION constant for bridging
- migrate pallet-xcm SafeXcmVersion during runtime upgrade
- add tests for pre and post upgrade
- bump spec_version
@mattheworris mattheworris self-assigned this May 29, 2025
@mattheworris mattheworris added this to the Bridge milestone May 29, 2025
AGENTS.md Outdated
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 file is useful for testing with OpenAI's Codex, which is enabled as a research preview.

@@ -373,6 +373,14 @@ check-try-runtime-installed:
try-runtime-create-snapshot-paseo-testnet: check-try-runtime-installed
try-runtime create-snapshot --uri wss://0.rpc.testnet.amplica.io:443 testnet-paseo-all-pallets.state

try-runtime-create-snapshot-westend-testnet: check-try-runtime-installed
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we change the RPC to not include the API key, then we can remove this check. Otherwise, being cautious and not checking in API keys.

Comment on lines +403 to +411

// --- XCM Version ---
#[cfg(feature = "frequency-bridging")]
pub mod xcm_version {
/// The default XCM version considered safe for the network.
/// This is not the latest version, but the one that is considered stable and safe to use.
/// It is used to ensure that the network can handle XCM messages without issues.
pub const SAFE_XCM_VERSION: u32 = 4;
}
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 can probably be moved to an xcm commmon or other, but don't want to step on other refactoring coming in soon.

@@ -17,6 +17,7 @@
//! Mock runtime for tests.
//! Implements both runtime APIs for fee estimation and getting the messages for transfers.

use common_runtime::weights::rocksdb_weights::constants::RocksDbWeight;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updating for migration tests, which were returning 0 weight in all cases.

@@ -0,0 +1,93 @@
use super::*;
use crate::xcm::tests::mock::{new_test_ext_with_balances, TestRuntime};
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 mock runtime is enough to test storage migration for the SafeXcmVersion constant.

Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

🚀 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 May 30, 2025
@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 May 30, 2025
@mattheworris mattheworris requested review from enddynayn and Copilot May 30, 2025 17:51
@mattheworris mattheworris marked this pull request as ready for review May 30, 2025 17:51
@mattheworris mattheworris requested a review from wilwade as a code owner May 30, 2025 17:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a storage migration to initialize the XCM pallet’s SafeXcmVersion and wires it into the runtime, along with tests and updated build targets for bridging.

  • Implements SetSafeXcmVersion migration and accompanying pre_upgrade/post_upgrade tests.
  • Introduces a new SAFE_XCM_VERSION constant and bumps the runtime spec versions.
  • Extends the Makefile with bridging and try-runtime targets, and adjusts startup scripts and test module visibility.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/init.sh Removed the --dev flag when starting frequency for bridging
runtime/frequency/src/xcm/tests/mod.rs Made the mock module public so it can be reused in new tests
runtime/frequency/src/xcm/tests/mock.rs Added RocksDbWeight import and set DbWeight for TestRuntime
runtime/frequency/src/migration_tests.rs New try-runtime migration tests for SafeXcmVersion
runtime/frequency/src/lib.rs Added SetSafeXcmVersion migration, updated Executive, bumped spec versions
runtime/common/src/constants.rs Defined SAFE_XCM_VERSION constant under frequency-bridging
Makefile Added bridging/try-runtime targets and --blocktime flags
AGENTS.md New contributor guidelines document
Comments suppressed due to low confidence (1)

scripts/init.sh:189

  • The --dev flag was removed, which may change the chain spec used by the node startup—re-add --dev (or the intended --chain argument) to ensure the local development environment is launched correctly.
./target/debug/frequency \

@@ -17,6 +17,7 @@
//! Mock runtime for tests.
//! Implements both runtime APIs for fee estimation and getting the messages for transfers.

use common_runtime::weights::rocksdb_weights::constants::RocksDbWeight;
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Importing and using production RocksDbWeight in tests may tie test behavior to real database weights; consider defining a lightweight or stub weight implementation to keep tests deterministic and performant.

Copilot uses AI. Check for mistakes.

echo "Example: ONFINALITY_APIKEY=your-api-key-here make try-runtime-check-migrations-westend-testnet"; \
exit 1; \
fi
try-runtime create-snapshot --uri wss://node-7330371704012918784.nv.onfinality.io/ws?apikey=$(ONFINALITY_APIKEY) testnet-paseo-all-pallets.state
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

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

The snapshot filename testnet-paseo-all-pallets.state appears to be for the Paseo network, not Westend; update it to the appropriate Westend state filename or URI to avoid confusion and ensure correct snapshot usage.

Suggested change
try-runtime create-snapshot --uri wss://node-7330371704012918784.nv.onfinality.io/ws?apikey=$(ONFINALITY_APIKEY) testnet-paseo-all-pallets.state
try-runtime create-snapshot --uri wss://node-7330371704012918784.nv.onfinality.io/ws?apikey=$(ONFINALITY_APIKEY) westend-testnet-all-pallets.state

Copilot uses AI. Check for mistakes.

@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label May 30, 2025
Copy link
Collaborator

@enddynayn enddynayn left a comment

Choose a reason for hiding this comment

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

👍 great!

@github-actions github-actions bot removed the metadata-changed Metadata has changed since the latest full release label Jun 2, 2025
@mattheworris mattheworris merged commit be6fce7 into feat/eth-bridging-development Jun 2, 2025
15 of 20 checks passed
@mattheworris mattheworris deleted the 2401-bridge-storage-migration-needed-for-any-xcm-related-pallet-constants branch June 2, 2025 14:07
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