Skip to content

Commit 85521e8

Browse files
franciscoaguirreacatangiux3c41abkonturprogramskillforverification
authored
XCM v5 (#4826)
# Context This PR aims to introduce XCMv5, for now it's in progress and will be updated over time. This branch will serve as a milestone branch for merging in all features we want to add to XCM, roughly outlined [here](polkadot-fellows/xcm-format#60). More features could be added. ## TODO - [x] Migrate foreign assets from v3 to v4 - [x] Setup v5 skeleton - [x] Remove XCMv2 - [x] #5390 - [x] #5585 - [x] #5420 - [x] #5876 - [x] #5971 - [x] #6148 - [x] #6228 Fixes #3434 Fixes #4190 Fixes #5209 Fixes #5241 Fixes #4284 --------- Signed-off-by: Adrian Catangiu <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: Andrii <[email protected]> Co-authored-by: Branislav Kontur <[email protected]> Co-authored-by: Joseph Zhao <[email protected]> Co-authored-by: Nazar Mokrynskyi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Shawn Tabrizi <[email protected]> Co-authored-by: command-bot <> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Serban Iorga <[email protected]>
1 parent c1238b6 commit 85521e8

File tree

227 files changed

+12140
-7048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+12140
-7048
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bridges/modules/xcm-bridge-hub-router/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ impl InspectMessageQueues for TestToBridgeHubSender {
141141
.iter()
142142
.map(|(location, message)| {
143143
(
144-
VersionedLocation::V4(location.clone()),
145-
vec![VersionedXcm::V4(message.clone())],
144+
VersionedLocation::from(location.clone()),
145+
vec![VersionedXcm::from(message.clone())],
146146
)
147147
})
148148
.collect()

bridges/modules/xcm-bridge-hub/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use sp_runtime::{
3838
AccountId32, BuildStorage, StateVersion,
3939
};
4040
use sp_std::cell::RefCell;
41-
use xcm::prelude::*;
41+
use xcm::{latest::ROCOCO_GENESIS_HASH, prelude::*};
4242
use xcm_builder::{
4343
AllowUnpaidExecutionFrom, DispatchBlob, DispatchBlobError, FixedWeightBounds,
4444
InspectMessageQueues, NetworkExportTable, NetworkExportTableItem, ParentIsPreset,
@@ -160,7 +160,7 @@ parameter_types! {
160160
pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into();
161161
pub BridgedRelativeDestination: InteriorLocation = [Parachain(BRIDGED_ASSET_HUB_ID)].into();
162162
pub BridgedUniversalDestination: InteriorLocation = [GlobalConsensus(BridgedRelayNetwork::get()), Parachain(BRIDGED_ASSET_HUB_ID)].into();
163-
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo;
163+
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
164164

165165
pub const BridgeDeposit: Balance = 100_000;
166166

bridges/primitives/xcm-bridge-hub/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,11 @@ impl BridgeLocations {
359359
#[cfg(test)]
360360
mod tests {
361361
use super::*;
362+
use xcm::latest::ROCOCO_GENESIS_HASH;
362363

363364
const LOCAL_NETWORK: NetworkId = Kusama;
364365
const REMOTE_NETWORK: NetworkId = Polkadot;
365-
const UNREACHABLE_NETWORK: NetworkId = Rococo;
366+
const UNREACHABLE_NETWORK: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
366367
const SIBLING_PARACHAIN: u32 = 1000;
367368
const LOCAL_BRIDGE_HUB: u32 = 1001;
368369
const REMOTE_PARACHAIN: u32 = 2000;

bridges/snowbridge/pallets/inbound-queue/src/mock.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ use sp_runtime::{
1919
BuildStorage, FixedU128, MultiSignature,
2020
};
2121
use sp_std::{convert::From, default::Default};
22-
use xcm::{latest::SendXcm, prelude::*};
22+
use xcm::{
23+
latest::{SendXcm, WESTEND_GENESIS_HASH},
24+
prelude::*,
25+
};
2326
use xcm_executor::AssetsInHolding;
2427

2528
use crate::{self as inbound_queue};
@@ -113,8 +116,8 @@ parameter_types! {
113116
pub const InitialFund: u128 = 1_000_000_000_000;
114117
pub const InboundQueuePalletInstance: u8 = 80;
115118
pub UniversalLocation: InteriorLocation =
116-
[GlobalConsensus(Westend), Parachain(1002)].into();
117-
pub AssetHubFromEthereum: Location = Location::new(1,[GlobalConsensus(Westend),Parachain(1000)]);
119+
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(1002)].into();
120+
pub AssetHubFromEthereum: Location = Location::new(1,[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),Parachain(1000)]);
118121
}
119122

120123
#[cfg(feature = "runtime-benchmarks")]

bridges/snowbridge/pallets/inbound-queue/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ fn test_submit_happy_path() {
4040
.into(),
4141
nonce: 1,
4242
message_id: [
43-
255, 125, 48, 71, 174, 185, 100, 26, 159, 43, 108, 6, 116, 218, 55, 155, 223, 143,
44-
141, 22, 124, 110, 241, 18, 122, 217, 130, 29, 139, 76, 97, 201,
43+
11, 25, 133, 51, 23, 68, 111, 211, 132, 94, 254, 17, 194, 252, 198, 233, 10, 193,
44+
156, 93, 72, 140, 65, 69, 79, 155, 154, 28, 141, 166, 171, 255,
4545
],
4646
fee_burned: 110000000000,
4747
}

bridges/snowbridge/pallets/system/src/benchmarking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ mod benchmarks {
169169
T::Token::mint_into(&caller, amount)?;
170170

171171
let relay_token_asset_id: Location = Location::parent();
172-
let asset = Box::new(VersionedLocation::V4(relay_token_asset_id));
172+
let asset = Box::new(VersionedLocation::from(relay_token_asset_id));
173173
let asset_metadata = AssetMetadata {
174174
name: "wnd".as_bytes().to_vec().try_into().unwrap(),
175175
symbol: "wnd".as_bytes().to_vec().try_into().unwrap(),

bridges/snowbridge/pallets/system/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ pub mod pallet {
269269
/// Lookup table for foreign token ID to native location relative to ethereum
270270
#[pallet::storage]
271271
pub type ForeignToNativeId<T: Config> =
272-
StorageMap<_, Blake2_128Concat, TokenId, xcm::v4::Location, OptionQuery>;
272+
StorageMap<_, Blake2_128Concat, TokenId, xcm::v5::Location, OptionQuery>;
273273

274274
/// Lookup table for native location relative to ethereum to foreign token ID
275275
#[pallet::storage]
276276
pub type NativeToForeignId<T: Config> =
277-
StorageMap<_, Blake2_128Concat, xcm::v4::Location, TokenId, OptionQuery>;
277+
StorageMap<_, Blake2_128Concat, xcm::v5::Location, TokenId, OptionQuery>;
278278

279279
#[pallet::genesis_config]
280280
#[derive(frame_support::DefaultNoBound)]

bridges/snowbridge/primitives/core/src/location.rs

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,12 @@ impl DescribeLocation for DescribeTokenTerminal {
9797
#[cfg(test)]
9898
mod tests {
9999
use crate::TokenIdOf;
100-
use xcm::prelude::{
101-
GeneralIndex, GeneralKey, GlobalConsensus, Junction::*, Location, NetworkId::*,
102-
PalletInstance, Parachain,
100+
use xcm::{
101+
latest::WESTEND_GENESIS_HASH,
102+
prelude::{
103+
GeneralIndex, GeneralKey, GlobalConsensus, Junction::*, Location, NetworkId::ByGenesis,
104+
PalletInstance, Parachain,
105+
},
103106
};
104107
use xcm_executor::traits::ConvertLocation;
105108

@@ -108,17 +111,24 @@ mod tests {
108111
let token_locations = [
109112
// Relay Chain cases
110113
// Relay Chain relative to Ethereum
111-
Location::new(1, [GlobalConsensus(Westend)]),
114+
Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]),
112115
// Parachain cases
113116
// Parachain relative to Ethereum
114-
Location::new(1, [GlobalConsensus(Westend), Parachain(2000)]),
117+
Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(2000)]),
115118
// Parachain general index
116-
Location::new(1, [GlobalConsensus(Westend), Parachain(2000), GeneralIndex(1)]),
119+
Location::new(
120+
1,
121+
[
122+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
123+
Parachain(2000),
124+
GeneralIndex(1),
125+
],
126+
),
117127
// Parachain general key
118128
Location::new(
119129
1,
120130
[
121-
GlobalConsensus(Westend),
131+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
122132
Parachain(2000),
123133
GeneralKey { length: 32, data: [0; 32] },
124134
],
@@ -127,7 +137,7 @@ mod tests {
127137
Location::new(
128138
1,
129139
[
130-
GlobalConsensus(Westend),
140+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
131141
Parachain(2000),
132142
AccountKey20 { network: None, key: [0; 20] },
133143
],
@@ -136,24 +146,36 @@ mod tests {
136146
Location::new(
137147
1,
138148
[
139-
GlobalConsensus(Westend),
149+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
140150
Parachain(2000),
141151
AccountId32 { network: None, id: [0; 32] },
142152
],
143153
),
144154
// Parchain Pallet instance cases
145155
// Parachain pallet instance
146-
Location::new(1, [GlobalConsensus(Westend), Parachain(2000), PalletInstance(8)]),
156+
Location::new(
157+
1,
158+
[
159+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
160+
Parachain(2000),
161+
PalletInstance(8),
162+
],
163+
),
147164
// Parachain Pallet general index
148165
Location::new(
149166
1,
150-
[GlobalConsensus(Westend), Parachain(2000), PalletInstance(8), GeneralIndex(1)],
167+
[
168+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
169+
Parachain(2000),
170+
PalletInstance(8),
171+
GeneralIndex(1),
172+
],
151173
),
152174
// Parachain Pallet general key
153175
Location::new(
154176
1,
155177
[
156-
GlobalConsensus(Westend),
178+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
157179
Parachain(2000),
158180
PalletInstance(8),
159181
GeneralKey { length: 32, data: [0; 32] },
@@ -163,7 +185,7 @@ mod tests {
163185
Location::new(
164186
1,
165187
[
166-
GlobalConsensus(Westend),
188+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
167189
Parachain(2000),
168190
PalletInstance(8),
169191
AccountKey20 { network: None, key: [0; 20] },
@@ -173,7 +195,7 @@ mod tests {
173195
Location::new(
174196
1,
175197
[
176-
GlobalConsensus(Westend),
198+
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
177199
Parachain(2000),
178200
PalletInstance(8),
179201
AccountId32 { network: None, id: [0; 32] },

bridges/snowbridge/primitives/router/src/inbound/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod tests;
77

88
use codec::{Decode, Encode};
99
use core::marker::PhantomData;
10-
use frame_support::{traits::tokens::Balance as BalanceT, weights::Weight, PalletError};
10+
use frame_support::{traits::tokens::Balance as BalanceT, PalletError};
1111
use scale_info::TypeInfo;
1212
use snowbridge_core::TokenId;
1313
use sp_core::{Get, RuntimeDebug, H160, H256};
@@ -279,7 +279,6 @@ where
279279
// Call create_asset on foreign assets pallet.
280280
Transact {
281281
origin_kind: OriginKind::Xcm,
282-
require_weight_at_most: Weight::from_parts(400_000_000, 8_000),
283282
call: (
284283
create_call_index,
285284
asset_id,

0 commit comments

Comments
 (0)