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

Merged
merged 72 commits into from
Nov 6, 2024
Merged

XCM v5 #4826

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 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
c7f8cba
fix(xcm-executor): mock was using wrong UniversalLocation
franciscoaguirre Nov 1, 2024
8aeb508
fix: remove mention of require_weight_at_most
franciscoaguirre Nov 1, 2024
582d4c5
doc: add PRDoc
franciscoaguirre Nov 1, 2024
0eb726d
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 1, 2024
e21773a
[XCMv5]Remove XCM testnet NetworkIds (#5390)
programskillforverification Nov 1, 2024
de9b7c6
fix: removing more instances of old network ids
franciscoaguirre Nov 1, 2024
2892aac
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 4, 2024
fd2d39a
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 4, 2024
00f2c0f
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 5, 2024
355366f
".git/.scripts/commands/fmt/fmt.sh"
Nov 5, 2024
a80f49b
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 5, 2024
abb8142
fix: remove nonexistent imports
franciscoaguirre Nov 5, 2024
20db7f8
fix: missing networkid changes
franciscoaguirre Nov 5, 2024
6b8b1cd
fix: feedback
franciscoaguirre Nov 5, 2024
9c20658
chore: nit feedback
franciscoaguirre Nov 5, 2024
fcb5e73
fix: add missing import
franciscoaguirre Nov 5, 2024
c2706e6
Small nits for XCMv5 (#6383)
bkontur Nov 6, 2024
d5639cc
Apply suggestions from code review
acatangiu Nov 6, 2024
87380c5
Merge branch 'master' of github.com:paritytech/polkadot-sdk into xcm-v5
acatangiu Nov 6, 2024
e3b9af8
remove xcm V2 files
acatangiu Nov 6, 2024
f29852f
Update from acatangiu running command 'fmt'
actions-user Nov 6, 2024
81c420d
use dummy genesis hash for defunct Wococo
acatangiu Nov 6, 2024
aa28c7a
fix: clippy
franciscoaguirre Nov 6, 2024
4f032f0
fix asset hub rococo tests
acatangiu Nov 6, 2024
70c10b4
fix bridge hub tests
acatangiu Nov 6, 2024
ea4516d
fix snowbridge-pallet-inbound-queue test
acatangiu Nov 6, 2024
738eeb2
fix: make pay_fees benchmark the same as buy_execution
franciscoaguirre Nov 6, 2024
b320ec0
fix: add default
franciscoaguirre Nov 6, 2024
603db91
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 6, 2024
407383f
fix: pay fees benchmark
franciscoaguirre Nov 6, 2024
a978d60
Xcm v5 migration for bhw (#6391)
bkontur Nov 6, 2024
93db9a9
".git/.scripts/commands/fmt/fmt.sh"
Nov 6, 2024
6f24a09
fix: delete failing tests
franciscoaguirre Nov 6, 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
4 changes: 2 additions & 2 deletions bridges/modules/xcm-bridge-hub/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sp_runtime::{
AccountId32, BuildStorage, StateVersion,
};
use sp_std::cell::RefCell;
use xcm::prelude::*;
use xcm::{latest::ROCOCO_GENESIS_HASH, prelude::*};
use xcm_builder::{
AllowUnpaidExecutionFrom, DispatchBlob, DispatchBlobError, FixedWeightBounds,
InspectMessageQueues, NetworkExportTable, NetworkExportTableItem, ParentIsPreset,
Expand Down Expand Up @@ -160,7 +160,7 @@ parameter_types! {
pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into();
pub BridgedRelativeDestination: InteriorLocation = [Parachain(BRIDGED_ASSET_HUB_ID)].into();
pub BridgedUniversalDestination: InteriorLocation = [GlobalConsensus(BridgedRelayNetwork::get()), Parachain(BRIDGED_ASSET_HUB_ID)].into();
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo;
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);

pub const BridgeDeposit: Balance = 100_000;

Expand Down
3 changes: 2 additions & 1 deletion bridges/primitives/xcm-bridge-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,11 @@ impl BridgeLocations {
#[cfg(test)]
mod tests {
use super::*;
use xcm::latest::ROCOCO_GENESIS_HASH;

const LOCAL_NETWORK: NetworkId = Kusama;
const REMOTE_NETWORK: NetworkId = Polkadot;
const UNREACHABLE_NETWORK: NetworkId = Rococo;
const UNREACHABLE_NETWORK: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
const SIBLING_PARACHAIN: u32 = 1000;
const LOCAL_BRIDGE_HUB: u32 = 1001;
const REMOTE_PARACHAIN: u32 = 2000;
Expand Down
9 changes: 6 additions & 3 deletions bridges/snowbridge/pallets/inbound-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ use sp_runtime::{
BuildStorage, FixedU128, MultiSignature,
};
use sp_std::{convert::From, default::Default};
use xcm::{latest::SendXcm, prelude::*};
use xcm::{
latest::{SendXcm, WESTEND_GENESIS_HASH},
prelude::*,
};
use xcm_executor::AssetsInHolding;

use crate::{self as inbound_queue};
Expand Down Expand Up @@ -113,8 +116,8 @@ parameter_types! {
pub const InitialFund: u128 = 1_000_000_000_000;
pub const InboundQueuePalletInstance: u8 = 80;
pub UniversalLocation: InteriorLocation =
[GlobalConsensus(Westend), Parachain(1002)].into();
pub AssetHubFromEthereum: Location = Location::new(1,[GlobalConsensus(Westend),Parachain(1000)]);
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(1002)].into();
pub AssetHubFromEthereum: Location = Location::new(1,[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),Parachain(1000)]);
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
4 changes: 2 additions & 2 deletions bridges/snowbridge/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ fn test_submit_happy_path() {
.into(),
nonce: 1,
message_id: [
255, 125, 48, 71, 174, 185, 100, 26, 159, 43, 108, 6, 116, 218, 55, 155, 223, 143,
141, 22, 124, 110, 241, 18, 122, 217, 130, 29, 139, 76, 97, 201,
11, 25, 133, 51, 23, 68, 111, 211, 132, 94, 254, 17, 194, 252, 198, 233, 10, 193,
156, 93, 72, 140, 65, 69, 79, 155, 154, 28, 141, 166, 171, 255,
],
fee_burned: 110000000000,
}
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
50 changes: 36 additions & 14 deletions bridges/snowbridge/primitives/core/src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ impl DescribeLocation for DescribeTokenTerminal {
#[cfg(test)]
mod tests {
use crate::TokenIdOf;
use xcm::prelude::{
GeneralIndex, GeneralKey, GlobalConsensus, Junction::*, Location, NetworkId::*,
PalletInstance, Parachain,
use xcm::{
latest::WESTEND_GENESIS_HASH,
prelude::{
GeneralIndex, GeneralKey, GlobalConsensus, Junction::*, Location, NetworkId::ByGenesis,
PalletInstance, Parachain,
},
};
use xcm_executor::traits::ConvertLocation;

Expand All @@ -108,17 +111,24 @@ mod tests {
let token_locations = [
// Relay Chain cases
// Relay Chain relative to Ethereum
Location::new(1, [GlobalConsensus(Westend)]),
Copy link
Contributor

@yrong yrong Nov 4, 2024

Choose a reason for hiding this comment

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

Just curious why we remove Westend from NetworkId Enum?

It will impact the tokenId generated here on Westend<->Sepolia bridge and it's a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious why we remove Westend from NetworkId Enum?

Discussed and decided here: polkadot-fellows/RFCs#108

I suggest you hit "watch" on that repo so you get github notifications for new proposals and you stay in the loop.

It will impact the tokenId generated here on Westend<->Sepolia bridge and it's a breaking change.

Should be fine to make breaking changes to Westend, you can just register a new token, right?

Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]),
// Parachain cases
// Parachain relative to Ethereum
Location::new(1, [GlobalConsensus(Westend), Parachain(2000)]),
Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(2000)]),
// Parachain general index
Location::new(1, [GlobalConsensus(Westend), Parachain(2000), GeneralIndex(1)]),
Location::new(
1,
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
GeneralIndex(1),
],
),
// Parachain general key
Location::new(
1,
[
GlobalConsensus(Westend),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
GeneralKey { length: 32, data: [0; 32] },
],
Expand All @@ -127,7 +137,7 @@ mod tests {
Location::new(
1,
[
GlobalConsensus(Westend),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
AccountKey20 { network: None, key: [0; 20] },
],
Expand All @@ -136,24 +146,36 @@ mod tests {
Location::new(
1,
[
GlobalConsensus(Westend),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
AccountId32 { network: None, id: [0; 32] },
],
),
// Parchain Pallet instance cases
// Parachain pallet instance
Location::new(1, [GlobalConsensus(Westend), Parachain(2000), PalletInstance(8)]),
Location::new(
1,
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
PalletInstance(8),
],
),
// Parachain Pallet general index
Location::new(
1,
[GlobalConsensus(Westend), Parachain(2000), PalletInstance(8), GeneralIndex(1)],
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
PalletInstance(8),
GeneralIndex(1),
],
),
// Parachain Pallet general key
Location::new(
1,
[
GlobalConsensus(Westend),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
PalletInstance(8),
GeneralKey { length: 32, data: [0; 32] },
Expand All @@ -163,7 +185,7 @@ mod tests {
Location::new(
1,
[
GlobalConsensus(Westend),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
PalletInstance(8),
AccountKey20 { network: None, key: [0; 20] },
Expand All @@ -173,7 +195,7 @@ mod tests {
Location::new(
1,
[
GlobalConsensus(Westend),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(2000),
PalletInstance(8),
AccountId32 { network: None, id: [0; 32] },
Expand Down
3 changes: 1 addition & 2 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
15 changes: 10 additions & 5 deletions bridges/snowbridge/primitives/router/src/outbound/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use snowbridge_core::{
AgentIdOf,
};
use sp_std::default::Default;
use xcm::prelude::SendError as XcmSendError;
use xcm::{
latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::SendError as XcmSendError,
};

use super::*;

Expand Down Expand Up @@ -61,7 +64,7 @@ impl SendMessageFeeProvider for MockErrOutboundQueue {
pub struct MockTokenIdConvert;
impl MaybeEquivalence<TokenId, Location> for MockTokenIdConvert {
fn convert(_id: &TokenId) -> Option<Location> {
Some(Location::new(1, [GlobalConsensus(Westend)]))
Some(Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]))
}
fn convert_back(_loc: &Location) -> Option<TokenId> {
None
Expand Down Expand Up @@ -1109,7 +1112,7 @@ fn xcm_converter_transfer_native_token_success() {
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");

let amount = 1000000;
let asset_location = Location::new(1, [GlobalConsensus(Westend)]);
let asset_location = Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))]);
let token_id = TokenIdOf::convert_location(&asset_location).unwrap();

let assets: Assets = vec![Asset { id: AssetId(asset_location), fun: Fungible(amount) }].into();
Expand Down Expand Up @@ -1142,7 +1145,8 @@ fn xcm_converter_transfer_native_token_with_invalid_location_will_fail() {

let amount = 1000000;
// Invalid asset location from a different consensus
let asset_location = Location { parents: 2, interior: [GlobalConsensus(Rococo)].into() };
let asset_location =
Location { parents: 2, interior: [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH))].into() };

let assets: Assets = vec![Asset { id: AssetId(asset_location), fun: Fungible(amount) }].into();
let filter: AssetFilter = assets.clone().into();
Expand Down Expand Up @@ -1221,7 +1225,8 @@ fn exporter_validate_with_invalid_universal_source_does_not_alter_universal_sour
let network = BridgedNetwork::get();
let destination: InteriorLocation = Here.into();

let universal_source: InteriorLocation = [GlobalConsensus(Westend), Parachain(1000)].into();
let universal_source: InteriorLocation =
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(1000)].into();

let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
Expand Down
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
Loading
Loading