Skip to content
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

XCM v5 #4826

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open

XCM v5 #4826

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b01161f
feat(xcm-v5): skeleton
franciscoaguirre Jun 5, 2024
0b83e68
feat(xcm-v3): no longer use v2 types
franciscoaguirre Jun 5, 2024
e917d67
feat: remove XCMv2
franciscoaguirre Jun 5, 2024
9005e04
Merge branch 'master' into xcm-v5
franciscoaguirre Jun 19, 2024
5fc4a32
fix(xcm-v5): fix most compilation errors
franciscoaguirre Jun 19, 2024
337e26e
Merge branch 'master' into xcm-v5
franciscoaguirre Jun 26, 2024
19cc1da
fix(pallet-xcm): change V4 to V5
franciscoaguirre Jun 26, 2024
5cfd108
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 14, 2024
96b5b4b
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 14, 2024
6de7a42
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 16, 2024
126ef2f
fix(xcm-v5): change v4 to v5
franciscoaguirre Aug 16, 2024
a16e19f
fix: more v4 to v5 conversions
franciscoaguirre Aug 16, 2024
a3a09af
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 16, 2024
bbba323
fix: more v4 to v5 conversions
franciscoaguirre Aug 16, 2024
98c3906
fix: more v4 to v5 conversions
franciscoaguirre Aug 16, 2024
08a82d1
fix(xcm-builder): use previously unused function
franciscoaguirre Aug 19, 2024
1f031ec
fix(xcm-executor): change v4 to v5
franciscoaguirre Aug 19, 2024
5b423ad
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 21, 2024
1116cbb
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 21, 2024
cfa2ef4
Merge branch 'master' into xcm-v5
franciscoaguirre Aug 27, 2024
241e992
Merge branch 'master' into xcm-v5
franciscoaguirre Sep 4, 2024
d421d3f
Merge branch 'master' into xcm-v5
franciscoaguirre Sep 4, 2024
3e85791
Merge branch 'master' into xcm-v5
franciscoaguirre Oct 1, 2024
f80c76a
fix: v4 -> v5
franciscoaguirre Oct 1, 2024
d1425bb
[XCMv5] Better fee mechanism (#5420)
franciscoaguirre Oct 17, 2024
f481f8e
Merge branch 'master' of github.com:paritytech/polkadot-sdk into xcm-v5
acatangiu Oct 17, 2024
678a379
Merge branch 'master' into xcm-v5
acatangiu Oct 17, 2024
4d9cc77
Merge branch 'master' of github.com:paritytech/polkadot-sdk into xcm-v5
acatangiu Oct 17, 2024
cdfecb7
fix merge dmg
acatangiu Oct 17, 2024
446465b
Added SetAssetClaimer Instruction to XCM v5 (#5585)
x3c41a Oct 21, 2024
4a6e85c
Merge branch 'master' into xcm-v5
acatangiu Oct 21, 2024
8fe7700
[xcm-v5] implement RFC#100: add new InitiateTransfer instruction (#5876)
acatangiu Oct 23, 2024
10d6795
Merge branch 'master' into xcm-v5
franciscoaguirre Oct 23, 2024
a1b8381
Transact without specifying weight (#6228)
franciscoaguirre Oct 29, 2024
86542d6
[xcm-v5] implement RFC#122: InitiateTransfer can alias XCM original o…
acatangiu Oct 29, 2024
e8807a3
Merge branch 'master' into xcm-v5
acatangiu Oct 29, 2024
4c29910
Merge branch 'master' into xcm-v5
franciscoaguirre Oct 30, 2024
d2a98f4
Merge branch 'master' into xcm-v5
franciscoaguirre Oct 31, 2024
a9762d6
Merge branch 'master' into xcm-v5
franciscoaguirre Oct 31, 2024
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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bridges/modules/xcm-bridge-hub-router/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ impl InspectMessageQueues for TestToBridgeHubSender {
.iter()
.map(|(location, message)| {
(
VersionedLocation::V4(location.clone()),
vec![VersionedXcm::V4(message.clone())],
VersionedLocation::from(location.clone()),
vec![VersionedXcm::from(message.clone())],
)
})
.collect()
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/pallets/system/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod benchmarks {
T::Token::mint_into(&caller, amount)?;

let relay_token_asset_id: Location = Location::parent();
let asset = Box::new(VersionedLocation::V4(relay_token_asset_id));
let asset = Box::new(VersionedLocation::from(relay_token_asset_id));
let asset_metadata = AssetMetadata {
name: "wnd".as_bytes().to_vec().try_into().unwrap(),
symbol: "wnd".as_bytes().to_vec().try_into().unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions bridges/snowbridge/pallets/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ pub mod pallet {
/// Lookup table for foreign token ID to native location relative to ethereum
#[pallet::storage]
pub type ForeignToNativeId<T: Config> =
StorageMap<_, Blake2_128Concat, TokenId, xcm::v4::Location, OptionQuery>;
StorageMap<_, Blake2_128Concat, TokenId, xcm::v5::Location, OptionQuery>;

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

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
Expand Down
10 changes: 7 additions & 3 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod tests;

use codec::{Decode, Encode};
use core::marker::PhantomData;
use frame_support::{traits::tokens::Balance as BalanceT, weights::Weight, PalletError};
use frame_support::{traits::tokens::Balance as BalanceT, PalletError};
use scale_info::TypeInfo;
use snowbridge_core::TokenId;
use sp_core::{Get, RuntimeDebug, H160, H256};
Expand Down Expand Up @@ -279,7 +279,6 @@ where
// Call create_asset on foreign assets pallet.
Transact {
origin_kind: OriginKind::Xcm,
require_weight_at_most: Weight::from_parts(400_000_000, 8_000),
call: (
create_call_index,
asset_id,
Expand Down Expand Up @@ -461,8 +460,10 @@ where
{
fn convert_location(location: &Location) -> Option<AccountId> {
match location.unpack() {
(_, [GlobalConsensus(Ethereum { chain_id })]) =>
(2, [GlobalConsensus(Ethereum { chain_id })]) =>
Some(Self::from_chain_id(chain_id).into()),
(2, [GlobalConsensus(Ethereum { chain_id }), AccountKey20 { network: _, key }]) =>
Some(Self::from_chain_id_with_key(chain_id, *key).into()),
_ => None,
}
}
Expand All @@ -472,4 +473,7 @@ impl<AccountId> GlobalConsensusEthereumConvertsFor<AccountId> {
pub fn from_chain_id(chain_id: &u64) -> [u8; 32] {
(b"ethereum-chain", chain_id).using_encoded(blake2_256)
}
pub fn from_chain_id_with_key(chain_id: &u64, key: [u8; 20]) -> [u8; 32] {
(b"ethereum-chain", chain_id, key).using_encoded(blake2_256)
}
}
9 changes: 3 additions & 6 deletions bridges/snowbridge/runtime/test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ use snowbridge_pallet_ethereum_client_fixtures::*;
use sp_core::{Get, H160, U256};
use sp_keyring::AccountKeyring::*;
use sp_runtime::{traits::Header, AccountId32, DigestItem, SaturatedConversion, Saturating};
use xcm::{
latest::prelude::*,
v3::Error::{self, Barrier},
};
use xcm::latest::prelude::*;
use xcm_executor::XcmExecutor;

type RuntimeHelper<Runtime, AllPalletsWithoutSystem = ()> =
Expand Down Expand Up @@ -374,7 +371,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
Weight::zero(),
);
// check error is barrier
assert_err!(outcome.ensure_complete(), Barrier);
assert_err!(outcome.ensure_complete(), XcmError::Barrier);
});
}

Expand All @@ -388,7 +385,7 @@ pub fn send_transfer_token_message_failure<Runtime, XcmConfig>(
weth_contract_address: H160,
destination_address: H160,
fee_amount: u128,
expected_error: Error,
expected_error: XcmError,
) where
Runtime: frame_system::Config
+ pallet_balances::Config
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ impl<T: Config> InspectMessageQueues for Pallet<T> {
}

(
VersionedLocation::V4((Parent, Parachain(para_id.into())).into()),
VersionedLocation::from(Location::new(1, Parachain(para_id.into()))),
decoded_messages,
)
})
Expand Down
23 changes: 12 additions & 11 deletions cumulus/pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ fn send_xcm_nested_works() {
XcmpQueue::take_outbound_messages(usize::MAX),
vec![(
HRMP_PARA_ID.into(),
(XcmpMessageFormat::ConcatenatedVersionedXcm, VersionedXcm::V4(good.clone()))
(XcmpMessageFormat::ConcatenatedVersionedXcm, VersionedXcm::from(good.clone()))
.encode(),
)]
);
Expand Down Expand Up @@ -512,7 +512,7 @@ fn hrmp_signals_are_prioritized() {
// Without a signal we get the messages in order:
let mut expected_msg = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
for _ in 0..31 {
expected_msg.extend(VersionedXcm::V4(message.clone()).encode());
expected_msg.extend(VersionedXcm::from(message.clone()).encode());
}

hypothetically!({
Expand All @@ -539,6 +539,7 @@ fn maybe_double_encoded_versioned_xcm_works() {
// pre conditions
assert_eq!(VersionedXcm::<()>::V3(Default::default()).encode(), &[3, 0]);
assert_eq!(VersionedXcm::<()>::V4(Default::default()).encode(), &[4, 0]);
assert_eq!(VersionedXcm::<()>::V5(Default::default()).encode(), &[5, 0]);
}

// Now also testing a page instead of just concat messages.
Expand Down Expand Up @@ -597,7 +598,7 @@ fn take_first_concatenated_xcm_good_recursion_depth_works() {
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
}
let good = VersionedXcm::V4(good);
let good = VersionedXcm::from(good);

let page = good.encode();
assert_ok!(XcmpQueue::take_first_concatenated_xcm(&mut &page[..], &mut WeightMeter::new()));
Expand All @@ -610,7 +611,7 @@ fn take_first_concatenated_xcm_good_bad_depth_errors() {
for _ in 0..MAX_XCM_DECODE_DEPTH {
bad = Xcm(vec![SetAppendix(bad)]);
}
let bad = VersionedXcm::V4(bad);
let bad = VersionedXcm::from(bad);

let page = bad.encode();
assert_err!(
Expand Down Expand Up @@ -872,18 +873,18 @@ fn get_messages_works() {
queued_messages,
vec![
(
VersionedLocation::V4(other_destination),
VersionedLocation::from(other_destination),
vec![
VersionedXcm::V4(Xcm(vec![ClearOrigin])),
VersionedXcm::V4(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
],
),
(
VersionedLocation::V4(destination),
VersionedLocation::from(destination),
vec![
VersionedXcm::V4(Xcm(vec![ClearOrigin])),
VersionedXcm::V4(Xcm(vec![ClearOrigin])),
VersionedXcm::V4(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
],
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ use sp_keyring::Sr25519Keyring as Keyring;

// Cumulus
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, PenpalSiblingSovereignAccount,
PenpalTeleportableAssetLocation, RESERVABLE_ASSET_ID, SAFE_XCM_VERSION, USDT_ID,
accounts, build_genesis_storage, collators, PenpalASiblingSovereignAccount,
PenpalATeleportableAssetLocation, PenpalBSiblingSovereignAccount,
PenpalBTeleportableAssetLocation, RESERVABLE_ASSET_ID, SAFE_XCM_VERSION, USDT_ID,
};
use parachains_common::{AccountId, Balance};

Expand Down Expand Up @@ -77,10 +78,17 @@ pub fn genesis() -> Storage {
},
foreign_assets: asset_hub_rococo_runtime::ForeignAssetsConfig {
assets: vec![
// Penpal's teleportable asset representation
// PenpalA's teleportable asset representation
(
PenpalTeleportableAssetLocation::get(),
PenpalSiblingSovereignAccount::get(),
PenpalATeleportableAssetLocation::get(),
PenpalASiblingSovereignAccount::get(),
false,
ED,
),
// PenpalB's teleportable asset representation
(
PenpalBTeleportableAssetLocation::get(),
PenpalBSiblingSovereignAccount::get(),
false,
ED,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl_accounts_helpers_for_parachain!(AssetHubRococo);
impl_assert_events_helpers_for_parachain!(AssetHubRococo);
impl_assets_helpers_for_system_parachain!(AssetHubRococo, Rococo);
impl_assets_helpers_for_parachain!(AssetHubRococo);
impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, xcm::v4::Location);
impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, xcm::v5::Location);
impl_xcm_helpers_for_parachain!(AssetHubRococo);
impl_bridge_helpers_for_chain!(
AssetHubRococo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use sp_keyring::Sr25519Keyring as Keyring;

// Cumulus
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, PenpalBSiblingSovereignAccount,
PenpalBTeleportableAssetLocation, PenpalSiblingSovereignAccount,
PenpalTeleportableAssetLocation, RESERVABLE_ASSET_ID, SAFE_XCM_VERSION, USDT_ID,
accounts, build_genesis_storage, collators, PenpalASiblingSovereignAccount,
PenpalATeleportableAssetLocation, PenpalBSiblingSovereignAccount,
PenpalBTeleportableAssetLocation, RESERVABLE_ASSET_ID, SAFE_XCM_VERSION, USDT_ID,
};
use parachains_common::{AccountId, Balance};

Expand Down Expand Up @@ -75,10 +75,10 @@ pub fn genesis() -> Storage {
},
foreign_assets: asset_hub_westend_runtime::ForeignAssetsConfig {
assets: vec![
// Penpal's teleportable asset representation
// PenpalA's teleportable asset representation
(
PenpalTeleportableAssetLocation::get(),
PenpalSiblingSovereignAccount::get(),
PenpalATeleportableAssetLocation::get(),
PenpalASiblingSovereignAccount::get(),
false,
ED,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl_accounts_helpers_for_parachain!(AssetHubWestend);
impl_assert_events_helpers_for_parachain!(AssetHubWestend);
impl_assets_helpers_for_system_parachain!(AssetHubWestend, Westend);
impl_assets_helpers_for_parachain!(AssetHubWestend);
impl_foreign_assets_helpers_for_parachain!(AssetHubWestend, xcm::v4::Location);
impl_foreign_assets_helpers_for_parachain!(AssetHubWestend, xcm::v5::Location);
impl_xcm_helpers_for_parachain!(AssetHubWestend);
impl_bridge_helpers_for_chain!(
AssetHubWestend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
pub mod genesis;

pub use bridge_hub_westend_runtime::{
xcm_config::XcmConfig as BridgeHubWestendXcmConfig,
self, xcm_config::XcmConfig as BridgeHubWestendXcmConfig,
ExistentialDeposit as BridgeHubWestendExistentialDeposit,
};

Expand Down
25 changes: 13 additions & 12 deletions cumulus/parachains/integration-tests/emulated/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use polkadot_primitives::{AssignmentId, ValidatorId};
pub const XCM_V2: u32 = 2;
pub const XCM_V3: u32 = 3;
pub const XCM_V4: u32 = 4;
pub const XCM_V5: u32 = 5;
pub const REF_TIME_THRESHOLD: u64 = 33;
pub const PROOF_SIZE_THRESHOLD: u64 = 33;

Expand All @@ -55,26 +56,26 @@ pub const TELEPORTABLE_ASSET_ID: u32 = 2;
// USDT registered on AH as (trust-backed) Asset and reserve-transferred between Parachain and AH
pub const USDT_ID: u32 = 1984;

pub const PENPAL_ID: u32 = 2000;
pub const PENPAL_A_ID: u32 = 2000;
pub const PENPAL_B_ID: u32 = 2001;
pub const ASSETS_PALLET_ID: u8 = 50;

parameter_types! {
pub PenpalTeleportableAssetLocation: xcm::v4::Location
= xcm::v4::Location::new(1, [
xcm::v4::Junction::Parachain(PENPAL_ID),
xcm::v4::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v4::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
pub PenpalATeleportableAssetLocation: xcm::v5::Location
= xcm::v5::Location::new(1, [
xcm::v5::Junction::Parachain(PENPAL_A_ID),
xcm::v5::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v5::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
]
);
pub PenpalSiblingSovereignAccount: AccountId = Sibling::from(PENPAL_ID).into_account_truncating();
pub PenpalBTeleportableAssetLocation: xcm::v4::Location
= xcm::v4::Location::new(1, [
xcm::v4::Junction::Parachain(PENPAL_B_ID),
xcm::v4::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v4::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
pub PenpalBTeleportableAssetLocation: xcm::v5::Location
= xcm::v5::Location::new(1, [
xcm::v5::Junction::Parachain(PENPAL_B_ID),
xcm::v5::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v5::Junction::GeneralIndex(TELEPORTABLE_ASSET_ID.into()),
]
);
pub PenpalASiblingSovereignAccount: AccountId = Sibling::from(PENPAL_A_ID).into_account_truncating();
pub PenpalBSiblingSovereignAccount: AccountId = Sibling::from(PENPAL_B_ID).into_account_truncating();
}

Expand Down
Loading
Loading