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

XCMv5: add ExecuteWithOrigin instruction #6304

Merged
merged 77 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 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
4551714
feat(xcm): add ExecuteWithOrigin instruction
franciscoaguirre Oct 30, 2024
4c29910
Merge branch 'master' into xcm-v5
franciscoaguirre Oct 30, 2024
b2702bb
Merge branch 'xcm-v5' into execute-with-origin
franciscoaguirre Oct 30, 2024
d447db8
doc: add prdoc
franciscoaguirre Oct 31, 2024
01d9227
revert: small refactor in westend xcm config
franciscoaguirre Oct 31, 2024
30920c0
WIP
franciscoaguirre Oct 31, 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
f125031
Merge branch 'xcm-v5' into execute-with-origin
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
a503e9d
feat: modify WithComputedOrigin barrier to allow ExecuteWithOrigin
franciscoaguirre Nov 4, 2024
bd0ad18
test: add integration test for ExecuteWithOrigin
franciscoaguirre Nov 5, 2024
b160c34
fix: remove useless import
franciscoaguirre Nov 5, 2024
cfe404a
chore: add benchmark for ExecuteWithOrigin
franciscoaguirre Nov 5, 2024
00f2c0f
Merge branch 'master' into xcm-v5
franciscoaguirre Nov 5, 2024
68462d7
Merge branch 'xcm-v5' into execute-with-origin
franciscoaguirre Nov 5, 2024
ae85ee4
".git/.scripts/commands/fmt/fmt.sh"
Nov 5, 2024
355366f
".git/.scripts/commands/fmt/fmt.sh"
Nov 5, 2024
2c073ea
fix: rococo benchmarks
franciscoaguirre Nov 5, 2024
b07e2f2
Merge branch 'xcm-v5' of https://github.com/paritytech/polkadot-sdk i…
Nov 5, 2024
8163663
".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=we…
Nov 5, 2024
b4eeb08
".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=ro…
Nov 5, 2024
9025ee3
chore: feedback
franciscoaguirre Nov 7, 2024
6ab6a57
revert: modify WithComputedOrigin barrier
franciscoaguirre Nov 7, 2024
2734976
Merge branch 'master' into execute-with-origin
franciscoaguirre Nov 7, 2024
51244b1
fix: ci
franciscoaguirre Nov 8, 2024
1a9f4d1
fix: ci
franciscoaguirre Nov 8, 2024
808adff
fix: ci
franciscoaguirre Nov 8, 2024
2e1588a
".git/.scripts/commands/fmt/fmt.sh"
Nov 8, 2024
c385bed
Merge branch 'master' into execute-with-origin
franciscoaguirre Nov 12, 2024
37f9da7
Merge branch 'master' into execute-with-origin
franciscoaguirre Nov 12, 2024
19c6838
Update polkadot/xcm/xcm-executor/src/lib.rs
franciscoaguirre Nov 12, 2024
178805d
fix: syntax error
franciscoaguirre Nov 12, 2024
4053f11
Merge branch 'master' into execute-with-origin
franciscoaguirre Nov 12, 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
11 changes: 6 additions & 5 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pallet-xcm = { workspace = true }
xcm-runtime-apis = { workspace = true }

# Cumulus
assets-common = { workspace = true }
parachains-common = { workspace = true, default-features = true }
asset-test-utils = { workspace = true, default-features = true }
cumulus-pallet-xcmp-queue = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

use crate::imports::*;

use assets_common::runtime_api::runtime_decl_for_fungibles_api::FungiblesApiV2;
use emulated_integration_tests_common::test_chain_can_claim_assets;
use frame_support::traits::fungible::Mutate;
use xcm_executor::traits::DropAssets;

#[test]
Expand All @@ -33,3 +35,83 @@ fn assets_can_be_claimed() {
amount
);
}

#[test]
fn chain_can_claim_assets_for_its_users() {
// Many Penpal users have assets trapped in AssetHubWestend.
let beneficiaries: Vec<(Location, Assets)> = vec![
// Some WND.
(
Location::new(1, [Parachain(2000), AccountId32 { id: [0u8; 32], network: None }]),
(Parent, 10_000_000_000_000u128).into(),
),
// Some USDT.
(
Location::new(1, [Parachain(2000), AccountId32 { id: [1u8; 32], network: None }]),
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(USDT_ID.into())], 100_000_000u128)
.into(),
),
];

// Start with those assets trapped.
AssetHubWestend::execute_with(|| {
for (location, assets) in &beneficiaries {
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::drop_assets(
location,
assets.clone().into(),
&XcmContext { origin: None, message_id: [0u8; 32], topic: None },
);
}
});

let penpal_to_asset_hub = PenpalA::sibling_location_of(AssetHubWestend::para_id());
let mut builder = Xcm::<()>::builder()
.withdraw_asset((Parent, 1_000_000_000_000u128))
.pay_fees((Parent, 100_000_000_000u128));

// Loop through all beneficiaries.
for (location, assets) in &beneficiaries {
builder = builder.execute_with_origin(
// We take only the last part, the `AccountId32` junction.
Some((*location.interior().last().unwrap()).into()),
Xcm::<()>::builder_unsafe()
.claim_asset(assets.clone(), Location::new(0, [GeneralIndex(5)])) // Means lost assets were version 5.
.deposit_asset(assets.clone(), location.clone())
.build(),
)
}

// Finish assembling the message.
let message = builder.build();

// Fund PenpalA's sovereign account on AssetHubWestend so it can pay for fees.
AssetHubWestend::execute_with(|| {
let penpal_as_seen_by_asset_hub = AssetHubWestend::sibling_location_of(PenpalA::para_id());
let penpal_sov_account_on_asset_hub =
AssetHubWestend::sovereign_account_id_of(penpal_as_seen_by_asset_hub);
type Balances = <AssetHubWestend as AssetHubWestendPallet>::Balances;
assert_ok!(<Balances as Mutate<_>>::mint_into(
&penpal_sov_account_on_asset_hub,
2_000_000_000_000u128,
));
});

// We can send a message from Penpal root that claims all those assets for each beneficiary.
PenpalA::execute_with(|| {
assert_ok!(<PenpalA as PenpalAPallet>::PolkadotXcm::send(
<PenpalA as Chain>::RuntimeOrigin::root(),
bx!(penpal_to_asset_hub.into()),
bx!(VersionedXcm::from(message)),
));
});

// We assert beneficiaries have received their funds.
AssetHubWestend::execute_with(|| {
for (location, expected_assets) in &beneficiaries {
let sov_account = AssetHubWestend::sovereign_account_id_of(location.clone());
let actual_assets =
<AssetHubWestend as Chain>::Runtime::query_account_balances(sov_account).unwrap();
assert_eq!(VersionedAssets::from(expected_assets.clone()), actual_assets);
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
XcmGeneric::<Runtime>::unpaid_execution()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 668_000 picoseconds.
Weight::from_parts(726_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
XcmGeneric::<Runtime>::unpaid_execution()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 638_000 picoseconds.
Weight::from_parts(708_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
fn set_asset_claimer(_location: &Location) -> Weight {
XcmGeneric::<Runtime>::set_asset_claimer()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 707_000 picoseconds.
Weight::from_parts(749_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
XcmGeneric::<Runtime>::unpaid_execution()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 707_000 picoseconds.
Weight::from_parts(749_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,7 @@ impl<Call> XcmWeightInfo<Call> for CoretimeRococoXcmWeight<Call> {
fn set_asset_claimer(_location: &Location) -> Weight {
XcmGeneric::<Runtime>::set_asset_claimer()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 707_000 picoseconds.
Weight::from_parts(749_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,7 @@ impl<Call> XcmWeightInfo<Call> for CoretimeWestendXcmWeight<Call> {
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
XcmGeneric::<Runtime>::unpaid_execution()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 707_000 picoseconds.
Weight::from_parts(749_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,7 @@ impl<Call> XcmWeightInfo<Call> for PeopleRococoXcmWeight<Call> {
fn set_asset_claimer(_location: &Location) -> Weight {
XcmGeneric::<Runtime>::set_asset_claimer()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 707_000 picoseconds.
Weight::from_parts(749_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,7 @@ impl<Call> XcmWeightInfo<Call> for PeopleWestendXcmWeight<Call> {
fn set_asset_claimer(_location: &Location) -> Weight {
XcmGeneric::<Runtime>::set_asset_claimer()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Minimum execution time: 707_000 picoseconds.
Weight::from_parts(749_000, 0)
}
pub fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,11 @@ impl<T: frame_system::Config> pallet_xcm_benchmarks::generic::WeightInfo for Wei
Weight::from_parts(1_354_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
3 changes: 3 additions & 0 deletions polkadot/runtime/rococo/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
fn set_asset_claimer(_location: &Location) -> Weight {
XcmGeneric::<Runtime>::set_asset_claimer()
}
fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<RuntimeCall>) -> Weight {
XcmGeneric::<Runtime>::execute_with_origin()
}
}

#[test]
Expand Down
Loading
Loading