Skip to content

Commit 6ccf27f

Browse files
tiagobndrgithub-actions[bot]sphamjoliatheifranciscoaguirre
authored andcommitted
Add XCM Precompile to pallet-xcm (#8693)
This PR adds the XCM precompile (with `xcmSend`, `xcmExecute` and `weightMessage` functionalities) to `pallet-xcm`. This follows the discussion we had on the now closed [PR](#8471), which attempted to add the precompile to `pallet-revive`, but that approach would have introduced unwanted cyclic dependencies. That's why we decided to migrate the precompile to `pallet-xcm`, avoiding adding unnecessary dependencies to `pallet-revive`. This PR should also encapsulate unit tests in `precompiles.rs` as well as integration tests under `cumulus/parachains/integration-tests/emulated/tests`. See tracking parent [issue](#6718) --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Siphamandla Mjoli <brianm445@yahoo.com> Co-authored-by: Siphamandla Mjoli <siphamandla@parity.io> Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: PG Herveou <pgherveou@gmail.com>
1 parent 79e113c commit 6ccf27f

24 files changed

Lines changed: 876 additions & 97 deletions

File tree

Cargo.lock

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

cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
399399
.saturating_add(T::DbWeight::get().reads(4))
400400
.saturating_add(T::DbWeight::get().writes(3))
401401
}
402+
403+
fn weigh_message() -> Weight {
404+
// Proof Size summary in bytes:
405+
// Measured: `0`
406+
// Estimated: `0`
407+
// Minimum execution time: 7_785_000 picoseconds.
408+
Weight::from_parts(8_077_000, 0)
409+
.saturating_add(Weight::from_parts(0, 0))
410+
}
402411
}

cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
6464
use pallet_assets::precompiles::{InlineIdConfig, ERC20};
6565
use pallet_nfts::{DestroyWitness, PalletFeatures};
6666
use pallet_revive::evm::runtime::EthExtra;
67-
use pallet_xcm::EnsureXcm;
67+
use pallet_xcm::{precompiles::XcmPrecompile, EnsureXcm};
6868
use parachains_common::{
6969
impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
7070
BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
@@ -1080,6 +1080,7 @@ impl pallet_revive::Config for Runtime {
10801080
type Precompiles = (
10811081
ERC20<Self, InlineIdConfig<0x120>, TrustBackedAssetsInstance>,
10821082
ERC20<Self, InlineIdConfig<0x320>, PoolAssetsInstance>,
1083+
XcmPrecompile<Self>,
10831084
);
10841085
type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
10851086
type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;

cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs

Lines changed: 98 additions & 88 deletions
Large diffs are not rendered by default.

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
373373
.saturating_add(T::DbWeight::get().reads(2))
374374
.saturating_add(T::DbWeight::get().writes(1))
375375
}
376+
377+
fn weigh_message() -> Weight {
378+
// Proof Size summary in bytes:
379+
// Measured: `0`
380+
// Estimated: `0`
381+
// Minimum execution time: 7_785_000 picoseconds.
382+
Weight::from_parts(8_077_000, 0)
383+
.saturating_add(Weight::from_parts(0, 0))
384+
}
376385
}

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
373373
.saturating_add(T::DbWeight::get().reads(2))
374374
.saturating_add(T::DbWeight::get().writes(1))
375375
}
376+
377+
fn weigh_message() -> Weight {
378+
// Proof Size summary in bytes:
379+
// Measured: `0`
380+
// Estimated: `0`
381+
// Minimum execution time: 7_785_000 picoseconds.
382+
Weight::from_parts(8_077_000, 0)
383+
.saturating_add(Weight::from_parts(0, 0))
384+
}
376385
}

cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
375375
.saturating_add(T::DbWeight::get().reads(2))
376376
.saturating_add(T::DbWeight::get().writes(1))
377377
}
378+
379+
fn weigh_message() -> Weight {
380+
// Proof Size summary in bytes:
381+
// Measured: `0`
382+
// Estimated: `0`
383+
// Minimum execution time: 7_785_000 picoseconds.
384+
Weight::from_parts(8_077_000, 0)
385+
.saturating_add(Weight::from_parts(0, 0))
386+
}
378387
}

cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
363363
.saturating_add(T::DbWeight::get().reads(2))
364364
.saturating_add(T::DbWeight::get().writes(1))
365365
}
366+
367+
fn weigh_message() -> Weight {
368+
// Proof Size summary in bytes:
369+
// Measured: `0`
370+
// Estimated: `0`
371+
// Minimum execution time: 7_785_000 picoseconds.
372+
Weight::from_parts(8_077_000, 0)
373+
.saturating_add(Weight::from_parts(0, 0))
374+
}
366375
}

cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
363363
.saturating_add(T::DbWeight::get().reads(2))
364364
.saturating_add(T::DbWeight::get().writes(1))
365365
}
366+
367+
fn weigh_message() -> Weight {
368+
// Proof Size summary in bytes:
369+
// Measured: `0`
370+
// Estimated: `0`
371+
// Minimum execution time: 7_785_000 picoseconds.
372+
Weight::from_parts(8_077_000, 0)
373+
.saturating_add(Weight::from_parts(0, 0))
374+
}
366375
}

cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
351351
Weight::from_parts(18_446_744_073_709_551_000, 0)
352352
.saturating_add(Weight::from_parts(0, 0))
353353
}
354+
355+
fn weigh_message() -> Weight {
356+
// Proof Size summary in bytes:
357+
// Measured: `0`
358+
// Estimated: `0`
359+
// Minimum execution time: 7_785_000 picoseconds.
360+
Weight::from_parts(8_077_000, 0)
361+
.saturating_add(Weight::from_parts(0, 0))
362+
}
354363
}

0 commit comments

Comments
 (0)