Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f0b95d5
Migrate ForeignToNativeId to XCM V5
yrong May 16, 2025
a182c17
Add tests to verify PNA compatibility between XCM v4 and v5
yrong May 16, 2025
3ae7bc6
Add logs
yrong May 16, 2025
e8a06d9
Add migration logs for checking
yrong May 16, 2025
69a40bb
Merge branch 'ron/migration-token-id-to-xcm-v5' of https://github.com…
yrong May 16, 2025
7ec17d5
More tests
yrong May 18, 2025
06cbe6a
Improve try-runtime with more checks
yrong May 18, 2025
6df5e80
Fix clippy
yrong May 18, 2025
9ea0ba9
Update change log
yrong May 18, 2025
b095bb1
Rename V5 to latest
yrong May 18, 2025
2c972cb
Rename to MigratePNAsToXcm5
yrong May 19, 2025
4cb7a07
Rename to MigrateLocationsToXcmV5
yrong May 20, 2025
131821c
Merge branch 'main' into migration-token-id-to-xcm-v5
yrong May 27, 2025
9ef362c
Fix changelog
yrong May 27, 2025
8ea30d3
Merge branch 'main' into migration-token-id-to-xcm-v5
yrong Jun 6, 2025
f8f1d26
RemoveNativeToForeignId
yrong Jul 1, 2025
82bbb6e
Merge branch 'main' into migration-token-id-to-xcm-v5
yrong Jul 1, 2025
701ac13
Switch to storage_alias
yrong Jul 1, 2025
1ffb3a0
Cleanup
yrong Jul 1, 2025
1ec6d02
Fix pallet name
yrong Jul 1, 2025
0cfb27e
Update system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
yrong Jul 1, 2025
3e13b36
Update system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbr…
yrong Jul 1, 2025
47961f0
More comments
yrong Jul 1, 2025
055f9ee
More comments
yrong Jul 1, 2025
e051c64
Cleanup
yrong Jul 1, 2025
ea05263
Merge branch 'main' into migration-token-id-to-xcm-v5
acatangiu Jul 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Slash and disable lazy and spammy validators as part of the new validator disabling strategy ([SDK #6827](https://github.com/paritytech/polkadot-sdk/pull/6827), [polkadot-fellows/runtimes/pull/782](https://github.com/polkadot-fellows/runtimes/pull/782))
- Switch to UpToLimitWithReEnablingDisablingStrategy (Polkadot & Kusama) which always prioritises highest offenders for disabling instead of stopping when limit is reached ([polkadot-fellows/runtimes/pull/781](https://github.com/polkadot-fellows/runtimes/pull/781))
- Snowbridge: Remove `snowbridge-pallet-system::NativeToForeignId` which is unused. ([#730](https://github.com/polkadot-fellows/runtimes/pull/730))

## [1.6.0] 19.06.2025

Expand All @@ -24,7 +25,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- [[#711](https://github.com/polkadot-fellows/runtimes/pull/711)] Pallet-broker: add extrinsic to remove a lease ([SDK stable2503 #7026](https://github.com/paritytech/polkadot-sdk/pull/7026)).
- [[#711](https://github.com/polkadot-fellows/runtimes/pull/711)] Pallet-broker: add extrinsic to remove an assignment ([SDK stable2503 #7080](https://github.com/paritytech/polkadot-sdk/pull/7080)).
- [[#711](https://github.com/polkadot-fellows/runtimes/pull/711)] Pallet-broker: add extrinsic to reserve a system core without having to wait two sale boundaries ([SDK stable2503 #4273](https://github.com/paritytech/polkadot-sdk/pull/4273)).

- [[#755](https://github.com/polkadot-fellows/runtimes/pull/755)] Added `pallet_revive` to Kusama AssetHub.

### Changed
Expand Down
10 changes: 7 additions & 3 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;

parameter_types! {
pub const BridgeKusamaMessagesPalletName: &'static str = "BridgeKusamaMessages";
pub const OutboundLanesCongestedSignalsKey: &'static str = "OutboundLanesCongestedSignals";
pub const EthereumSystemPalletName: &'static str = "EthereumSystem";
pub const NativeToForeignIdKey: &'static str = "NativeToForeignId";
}

/// Migrations to apply on runtime upgrade.
Expand All @@ -154,7 +154,11 @@ pub type Migrations = (
Runtime,
bridge_to_kusama_config::XcmOverBridgeHubKusamaInstance,
>,
snowbridge_pallet_system::migration::FeePerGasMigrationV0ToV1<Runtime>,
frame_support::migrations::RemoveStorage<
EthereumSystemPalletName,
NativeToForeignIdKey,
RocksDbWeight,
>,
pallet_session::migrations::v1::MigrateV0ToV1<
Runtime,
pallet_session::migrations::v1::InitOffenceSeverity<Runtime>,
Expand Down
123 changes: 120 additions & 3 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,35 @@

#![cfg(test)]

use bp_bridge_hub_polkadot::{snowbridge::EthereumLocation, BRIDGE_HUB_POLKADOT_PARACHAIN_ID};
use bp_polkadot_core::Signature;
use bridge_hub_polkadot_runtime::{
bridge_to_ethereum_config::{EthereumGatewayAddress, EthereumNetwork},
bridge_to_kusama_config::OnBridgeHubPolkadotRefundBridgeHubKusamaMessages,
xcm_config::{GovernanceLocation, XcmConfig, XcmFeeManagerFromComponentsBridgeHub},
xcm_config::{
GovernanceLocation, UniversalLocation, XcmConfig, XcmFeeManagerFromComponentsBridgeHub,
},
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive,
MessageQueueServiceWeight, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, TxExtension,
UncheckedExtrinsic,
};
use bridge_hub_test_utils::GovernanceOrigin;
use codec::{Decode, Encode};
use cumulus_primitives_core::XcmError::{FailedToTransactAsset, TooExpensive};
use cumulus_primitives_core::{
ParaId,
XcmError::{FailedToTransactAsset, TooExpensive},
};
use frame_support::{
assert_err, assert_ok, parameter_types,
traits::{fungible::Mutate, Contains},
};
use hex_literal::hex;
use parachains_common::{AccountId, AuraId, Balance};
pub use parachains_runtimes_test_utils::test_cases::change_storage_constant_by_governance_works;
use parachains_runtimes_test_utils::{
AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, ValidatorIdOf,
};
use snowbridge_core::{TokenId, TokenIdOf};
use snowbridge_pallet_ethereum_client::WeightInfo;
use snowbridge_pallet_ethereum_client_fixtures::*;
use sp_core::{Get, H160};
Expand All @@ -47,7 +55,8 @@ use sp_runtime::{
};
use xcm::latest::prelude::*;
use xcm_builder::HandleFee;
use xcm_executor::traits::{FeeManager, FeeReason};
use xcm_executor::traits::{ConvertLocation, FeeManager, FeeReason};

parameter_types! {
pub const DefaultBridgeHubEthereumBaseFee: Balance = 3_833_568_200_000;
}
Expand Down Expand Up @@ -416,3 +425,111 @@ fn construct_and_apply_extrinsic(
let r = Executive::apply_extrinsic(xt);
r.unwrap()
}

// Check compatibility for `token_id` stored on ethereum. If this test starts to fail, the [TokenIdOf](https://github.com/paritytech/polkadot-sdk/blob/20510c488198e8ee72b241fd2d0f6d1784982734/bridges/snowbridge/primitives/core/src/location.rs#L38-L43)
// converter should be updated to ensure the generated token ID remains consistent and unchanged.
#[test]
fn check_compatibility_for_token_id_stored_on_ethereum() {
pub struct RegisterTokenTestCase {
/// Input: Location of Polkadot-native token relative to BH
pub native: Location,
/// Output: Reanchored, canonicalized location
pub reanchored: Location,
/// Output: Stable hash of reanchored location
pub foreign: TokenId,
}
let test_cases = vec![
// DOT
RegisterTokenTestCase {
native: Location::parent(),
reanchored: Location::new(1, GlobalConsensus(Polkadot)),
foreign: hex!("4e241583d94b5d48a27a22064cd49b2ed6f5231d2d950e432f9b7c2e0ade52b2")
.into(),
},
// KSM
RegisterTokenTestCase {
native: Location::new(2, [GlobalConsensus(Kusama)]),
reanchored: Location::new(1, [GlobalConsensus(Kusama)]),
foreign: hex!("03b6054d0c576dd8391e34e1609cf398f68050c23009d19ce93c000922bcd852")
.into(),
},
// PINK
RegisterTokenTestCase {
native: Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(23)]),
reanchored: Location::new(
1,
[GlobalConsensus(Polkadot), Parachain(1000), PalletInstance(50), GeneralIndex(23)],
),
foreign: hex!("bc8785969587ef3d22739d3385cb519a9e0133dd5da8d320c376772468c19be6")
.into(),
},
// TEER
RegisterTokenTestCase {
native: Location::new(1, [Parachain(2039)]),
reanchored: Location::new(1, [GlobalConsensus(Polkadot), Parachain(2039)]),
foreign: hex!("3b7f577715347bdcde4739a1bf1a7f1dec71e8ff4dbe23a6a49348ebf920c658")
.into(),
},
// Hydration
RegisterTokenTestCase {
native: Location::new(1, [Parachain(2034), GeneralIndex(0)]),
reanchored: Location::new(
1,
[GlobalConsensus(Polkadot), Parachain(2034), GeneralIndex(0)],
),
foreign: hex!("d5678e3bb6486c4fef73dc109cf23d5648654edd4b41fb32e1ce9f9a984a3d59")
.into(),
},
// Voucher DOT
RegisterTokenTestCase {
native: Location::new(
1,
[
Parachain(2030),
GeneralKey {
length: 2,
data: hex!(
"0900000000000000000000000000000000000000000000000000000000000000"
),
},
],
),
reanchored: Location::new(
1,
[
GlobalConsensus(Polkadot),
Parachain(2030),
GeneralKey {
length: 2,
data: hex!(
"0900000000000000000000000000000000000000000000000000000000000000"
),
},
],
),
foreign: hex!("2a8080362874bbfeb585d676eba3f06e3b878d7c5d5f98d2a092ebb375bd484c")
.into(),
},
];
for tc in test_cases.iter() {
ExtBuilder::<Runtime>::default()
.with_collators(collator_session_keys().collators())
.with_session_keys(collator_session_keys().session_keys())
.with_para_id(ParaId::from(BRIDGE_HUB_POLKADOT_PARACHAIN_ID))
.with_tracing()
.build()
.execute_with(|| {
let ethereum_location = EthereumLocation::get();
// reanchor to Ethereum context
let location = tc
.native
.clone()
.reanchored(&ethereum_location, &UniversalLocation::get())
.unwrap();
assert_eq!(location, tc.reanchored);

let token_id = TokenIdOf::convert_location(&location).unwrap();
assert_eq!(token_id, tc.foreign);
})
}
}
Loading