1. Apr 24, 2024
  2. Mar 27, 2024
  3. Mar 01, 2024
  4. Jan 16, 2024
  5. Dec 19, 2023
  6. Dec 06, 2023
    • Adrian Catangiu's avatar
      pallet-xcm: add new flexible `transfer_assets()` call/extrinsic (#2388) · e7651cf4
      Adrian Catangiu authored
      # Motivation (+testing)
      
      ### Enable easy `ForeignAssets` transfers using `pallet-xcm` 
      
      We had just previously added capabilities to teleport fees during
      reserve-based transfers, but what about reserve-transferring fees when
      needing to teleport some non-fee asset?
      
      This PR aligns everything under either explicit reserve-transfer,
      explicit teleport, or this new flexible `transfer_assets()` which can
      mix and match as needed with fewer artificial constraints imposed to the
      user.
      
      This will enable, for example, a (non-system) parachain to teleport
      their `ForeignAssets` assets to AssetHub while using DOT to pay fees.
      (the assets are teleported - as foreign assets should from their owner
      chain - while DOT used for fees can only be reserve-based transferred
      between said parachain and AssetHub).
      
      Added `xcm-emulator` tests for this scenario ^.
      
      # Description
      
      Reverts `(limited_)reserve_transfer_assets` to only allow reserve-based
      transfers for all `assets` including fees.
      
      Similarly `(limited_)teleport_assets` only allows teleports for all
      `assets` including fees.
          
      For complex combinations of asset transfers where assets and fees may
      have different reserves or different reserve/teleport trust
      configurations, users can use the newly added `transfer_assets()`
      extrinsic which is more flexible in allowing more complex scenarios.
      
      `assets` (excluding `fees`) must have same reserve location or otherwise
      be teleportable to `dest`.
      No limitations imposed on `fees`.
      
      - for local reserve: transfer assets to sovereign account of destination
      chain and forward a notification XCM to `dest` to mint and deposit
      reserve-based assets to `beneficiary`.
      - for destination reserve: burn local assets and forward a notification
      to `dest` chain to withdraw the reserve assets from this chain's
      sovereign account and deposit them to `beneficiary`.
      - for remote reserve: burn local assets, forward XCM to reserve chain to
      move reserves from this chain's SA to `dest` chain's SA, and forward
      another XCM to `dest` to mint and deposit reserve-based assets to
      `beneficiary`.
      - for teleports: burn local assets and forward XCM to `dest` chain to
      mint/teleport assets and deposit them to `beneficiary`.
      
      ## Review notes
      
      Only around 500 lines are prod code (see `pallet_xcm/src/lib.rs`), the
      rest of the PR is new tests and improving existing tests.
      
      ---------
      
      Co-authored-by: command-bot <>
      e7651cf4
  7. Nov 10, 2023
    • PG Herveou's avatar
      Contracts: Add XCM traits to interface with contracts (#2086) · 6b7be115
      PG Herveou authored
      We are introducing a new set of `XcmController` traits (final name yet
      to be determined).
      These traits are implemented by `pallet-xcm` and allows other pallets,
      such as `pallet_contracts`, to rely on these traits instead of tight
      coupling them to `pallet-xcm`.
      
      Using only the existing Xcm traits would mean duplicating the logic from
      `pallet-xcm` in these other pallets, which we aim to avoid. Our
      objective is to ensure that when these APIs are called from
      `pallet-contracts`, they produce the exact same outcomes as if called
      directly from `pallet-xcm`.
      
      The other benefits is that we can also expose return values to
      `pallet-contracts` instead of just calling `pallet-xcm` dispatchable and
      getting a `DispatchResult` back.
      
      See traits integration in this PR
      https://github.com/paritytech/polkadot-sdk/pull/1248
      
      , where the traits
      are used as follow to define and implement `pallet-contracts` Config.
      ```rs
      // Contracts config:
      pub trait Config: frame_system::Config {
        // ...
      
        /// A type that exposes XCM APIs, allowing contracts to interact with other parachains, and
        /// execute XCM programs.
        type Xcm: xcm_executor::traits::Controller<
      	  OriginFor<Self>,
      	  <Self as frame_system::Config>::RuntimeCall,
      	  BlockNumberFor<Self>,
        >;
      }
      
      // implementation
      impl pallet_contracts::Config for Runtime {
              // ...
      
      	type Xcm = pallet_xcm::Pallet<Self>;
      }
      ```
      
      ---------
      
      Co-authored-by: default avatarAlexander Theißen <[email protected]>
      Co-authored-by: command-bot <>
      6b7be115
  8. Nov 02, 2023
    • Oliver Tale-Yazdi's avatar
      Use `Message Queue` as DMP and XCMP dispatch queue (#1246) · e1c033eb
      Oliver Tale-Yazdi authored
      (imported from https://github.com/paritytech/cumulus/pull/2157)
      
      ## Changes
      
      This MR refactores the XCMP, Parachains System and DMP pallets to use
      the [MessageQueue](https://github.com/paritytech/substrate/pull/12485)
      for delayed execution of incoming messages. The DMP pallet is entirely
      replaced by the MQ and thereby removed. This allows for PoV-bounded
      execution and resolves a number of issues that stem from the current
      work-around.
      
      All System Parachains adopt this change.  
      The most important changes are in `primitives/core/src/lib.rs`,
      `parachains/common/src/process_xcm_message.rs`,
      `pallets/parachain-system/src/lib.rs`, `pallets/xcmp-queue/src/lib.rs`
      and the runtime configs.
      
      ### DMP Queue Pallet
      
      The pallet got removed and its logic refactored into parachain-system.
      Overweight message management can be done directly through the MQ
      pallet.
      
      Final undeployment migrations are provided by
      `cumulus_pallet_dmp_queue::UndeployDmpQueue` and `DeleteDmpQueue` that
      can be configured with an aux config trait like:
      
      ```rust
      parameter_types! {
      	pub const DmpQueuePalletName: &'static str = \"DmpQueue\" < CHANGE ME;
      	pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
      }
      
      impl cumulus_pallet_dmp_queue::MigrationConfig for Runtime {
      	type PalletName = DmpQueuePalletName;
      	type DmpHandler = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
      	type DbWeight = <Runtime as frame_system::Config>::DbWeight;
      }
      
      // And adding them to your Migrations tuple:
      pub type Migrations = (
      	...
      	cumulus_pallet_dmp_queue::UndeployDmpQueue<Runtime>,
      	cumulus_pallet_dmp_queue::DeleteDmpQueue<Runtime>,
      );
      ```
      
      ### XCMP Queue pallet
      
      Removed all dispatch queue functionality. Incoming XCMP messages are now
      either: Immediately handled if they are Signals, enqueued into the MQ
      pallet otherwise.
      
      New config items for the XCMP queue pallet:
      ```rust
      /// The actual queue implementation that retains the messages for later processing.
      type XcmpQueue: EnqueueMessage<ParaId>;
      
      /// How a XCM over HRMP from a sibling parachain should be processed.
      type XcmpProcessor: ProcessMessage<Origin = ParaId>;
      
      /// The maximal number of suspended XCMP channels at the same time.
      #[pallet::constant]
      type MaxInboundSuspended: Get<u32>;
      ```
      
      How to configure those:
      
      ```rust
      // Use the MessageQueue pallet to store messages for later processing. The `TransformOrigin` is needed since
      // the MQ pallet itself operators on `AggregateMessageOrigin` but we want to enqueue `ParaId`s.
      type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
      
      // Process XCMP messages from siblings. This is type-safe to only accept `ParaId`s. They will be dispatched
      // with origin `Junction::Sibling(…)`.
      type XcmpProcessor = ProcessFromSibling<
      	ProcessXcmMessage<
      		AggregateMessageOrigin,
      		xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
      		RuntimeCall,
      	>,
      >;
      
      // Not really important what to choose here. Just something larger than the maximal number of channels.
      type MaxInboundSuspended = sp_core::ConstU32<1_000>;
      ```
      
      The `InboundXcmpStatus` storage item was replaced by
      `InboundXcmpSuspended` since it now only tracks inbound queue suspension
      and no message indices anymore.
      
      Now only sends the most recent channel `Signals`, as all prio ones are
      out-dated anyway.
      
      ### Parachain System pallet
      
      For `DMP` messages instead of forwarding them to the `DMP` pallet, it
      now pushes them to the configured `DmpQueue`. The message processing
      which was triggered in `set_validation_data` is now being done by the MQ
      pallet `on_initialize`.
      
      XCMP messages are still handed off to the `XcmpMessageHandler`
      (XCMP-Queue pallet) - no change here.
      
      New config items for the parachain system pallet:
      ```rust
      /// Queues inbound downward messages for delayed processing. 
      ///
      /// Analogous to the `XcmpQueue` of the XCMP queue pallet.
      type DmpQueue: EnqueueMessage<AggregateMessageOrigin>;
      ``` 
      
      How to configure:
      ```rust
      /// Use the MQ pallet to store DMP messages for delayed processing.
      type DmpQueue = MessageQueue;
      ``` 
      
      ## Message Flow
      
      The flow of messages on the parachain side. Messages come in from the
      left via the `Validation Data` and finally end up at the `Xcm Executor`
      on the right.
      
      ![Untitled
      (1)](https://github.com/paritytech/cumulus/assets/10380170/6cf8b377-88c9-4aed-96df-baace266e04d)
      
      ## Further changes
      
      - Bumped the default suspension, drop and resume thresholds in
      `QueueConfigData::default()`.
      - `XcmpQueue::{suspend_xcm_execution, resume_xcm_execution}` errors when
      they would be a noop.
      - Properly validate the `QueueConfigData` before setting it.
      - Marked weight files as auto-generated so they wont auto-expand in the
      MR files view.
      - Move the `hypothetical` asserts to `frame_support` under the name
      `experimental_hypothetically`
      
      Questions:
      - [ ] What about the ugly `#[cfg(feature = \"runtime-benchmarks\")]` in
      the runtimes? Not sure how to best fix. Just having them like this makes
      tests fail that rely on the real message processor when the feature is
      enabled.
      - [ ] Need a good weight for `MessageQueueServiceWeight`. The scheduler
      already takes 80% so I put it to 10% but that is quite low.
      
      TODO:
      - [x] Remove c&p code after
      https://github.com/paritytech/polkadot/pull/6271
      - [x] Use `HandleMessage` once it is public in Substrate
      - [x] fix `runtime-benchmarks` feature
      https://github.com/paritytech/polkadot/pull/6966
      
      
      - [x] Benchmarks
      - [x] Tests
      - [ ] Migrate `InboundXcmpStatus` to `InboundXcmpSuspended`
      - [x] Possibly cleanup Migrations (DMP+XCMP)
      - [x] optional: create `TransformProcessMessageOrigin` in Substrate and
      replace `ProcessFromSibling`
      - [ ] Rerun weights on ref HW
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: command-bot <>
      e1c033eb
  9. Aug 30, 2023
  10. Aug 01, 2023
    • Oleg Plakida's avatar
      Update weights with VM runners (#2712) · fc83800e
      Oleg Plakida authored
      
      
      * paritytech/ci-cd#697: Update weights with VM runners
      
       - Update weights using VM instances
       - Change runner tag for weights ci job to weights-vm
      
      * ".git/.scripts/commands/bench/bench.sh" all
      
      * ".git/.scripts/commands/bench-all/bench-all.sh" --target_dir=cumulus
      
      ---------
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      fc83800e
  11. Jun 08, 2023
  12. May 11, 2023
  13. Apr 27, 2023
    • Keith Yeung's avatar
      Companion for paritytech/polkadot#7098 (#2469) · b441d05d
      Keith Yeung authored
      * Companion for paritytech/polkadot#7098
      
      * Fixes
      
      * Add missing benchmarked function
      
      * Fix typo
      
      * update lockfile for {"polkadot", "substrate"}
      
      ---------
      
      Co-authored-by: parity-processbot <>
      b441d05d
  14. Apr 04, 2023
  15. Mar 03, 2023
  16. Feb 23, 2023
  17. Jan 17, 2023
    • Gavin Wood's avatar
      XCM v3 Companion (#697) · 3a459e8f
      Gavin Wood authored
      * Fixes
      
      * Undiener
      
      * Undiener
      
      * Undiener
      
      * Lockfile
      
      * Changes for send returning hash
      
      * Include message ID as params to execute_xcm
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Companion fixes
      
      * Formatting
      
      * Fixes
      
      * Formatting
      
      * Bump
      
      * Bump
      
      * Fixes
      
      * Formatting
      
      * Make the price of UMP/XCMP message sending configurable
      
      * cargo fmt
      
      * Remove InvertLocation
      
      * Formatting
      
      * Use ConstantPrice from polkadot-runtime-common
      
      * Fix naming
      
      * cargo fmt
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Add CallDispatcher
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Remove unused import
      
      * Remove unused import
      
      * XCMv3 fixes (#1710)
      
      * Fixes XCMv3 related
      Fixes XCMv3 (removed query_holding)
      Fixes XCMv3 - should use _depositable_count?
      Fixes XCMv3 - removed TrustedReserve
      Fixes - missing weights for statemine/statemint/westmint
      [DO-NOT-CHERRY-PICK] tmp return query_holding to aviod conficts to master
      Fixes - missing functions for pallet_xcm_benchmarks::generic::Config
      Fixes for XCMv3 benchmarking
      Fix xcm - removed query_holding
      
      * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic
      
      * Fix imports
      
      * Avoid consuming XCM message for NotApplicable scenario (#1787)
      
      * Avoid consuming message for NotApplicable scenario
      
      * Avoid consuming message for NotApplicable scenario tests
      
      * Add 10 message processing limit to DMP queue
      
      * Add 10 message limit to XCMP queue
      
      * Always increment the message_processed count whenever a message is processed
      
      * Fix formatting
      
      * Set an upper limit to the overweight message DMP queue
      
      * Add upper limit to XCMP overweight message queue
      
      * Fix for missing weight for `fn unpaid_execution()`
      
      * Fix - usage of `messages_processed`
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * cargo fmt
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Remove unused import
      
      * Fixes for gav-xcm-v3 (#1835)
      
      * Fix for FungiblesAdapter - trait changes: Contains -> AssetChecking
      
      * Fix for missing weight for `fn unpaid_execution()`
      
      * Used NonLocalMint for all NonZeroIssuance
      
      * Fix
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fix tests
      
      * Fixes
      
      * Add SafeCallFilter
      
      * Add missing config items
      
      * Add TODO
      
      * Use () as the PriceForParentDelivery
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Update transact_origin to transact_origin_and_runtime_call
      
      * Add ReachableDest config item to XCM pallet
      
      * Update SafeCallFilter to allow remark_with_event in runtime benchmarks
      
      * cargo fmt
      
      * Update substrate
      
      * Fix worst_case_holding
      
      * Fix DMQ queue unit tests
      
      * Remove unused label
      
      * cargo fmt
      
      * Actually process incoming XCMs
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes - return back Weightless
      
      * Added measured benchmarks for `pallet_xcm` (#1968)
      
      * Fix
      
      Fix
      
      Fix
      
      * Fix
      
      * Fixes for transact benchmark
      
      * Fixes add pallet_xcm to benchmarks
      
      * Revert remark_with_event
      
      * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic
      
      * Fixes
      
      * TMP
      
      * Fix for reserve_asset_deposited
      
      * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm
      
      * Fix
      
      * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm
      
      * Fix
      
      * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm
      
      * Fix westmint
      
      * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic
      
      * Fix
      
      * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm
      
      * Fix for collectives
      
      * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm
      
      * Fixes for bridge-hubs
      
      * Fixes - return back Weightless
      
      * Fix - removed MigrateToTrackInactive for contracts-rococo
      
      Co-authored-by: command-bot <>
      
      * cargo fmt
      
      * Fix benchmarks
      
      * Bko gav xcm v3 (#1993)
      
      * Fix
      
      * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::fungible
      
      * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::fungible
      
      * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::fungible
      
      * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm
      
      Co-authored-by: command-bot <>
      
      * Change AllowUnpaidExecutionFrom to be explicit
      
      * xcm-v3 benchmarks, weights, fixes for bridge-hubs (#2035)
      
      * Dumy weights to get compile
      
      * Change UniversalLocation according to https://github.com/paritytech/polkadot/pull/4097
      
       (Location Inversion Removed)
      
      * Fix bridge-hubs weights
      
      * ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::generic
      
      * ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::fungible
      
      * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm
      
      * ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::fungible
      
      * ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::generic
      
      * Change NetworkId to Option<NetworkId>
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * Add event for showing the hash of an UMP sent message (#1228)
      
      * Add UpwardMessageSent event in parachain-system
      
      * additional fixes
      
      * Message Id
      
      * Fix errors from merge
      
      * fmt
      
      * more fmt
      
      * Remove todo
      
      * more formatting
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Fixes
      
      * Allow explicit unpaid executions from the relay chains for system parachains (#2060)
      
      * Allow explicit unpaid executions from the relay chains for system parachains
      
      * Put origin-filtering barriers into WithComputedOrigin
      
      * Use ConstU32<8>
      
      * Small nits
      
      * formatting
      
      * cargo fmt
      
      * Allow receiving XCMs from any relay chain plurality
      
      * Fixes
      
      * update lockfile for {"polkadot", "substrate"}
      
      * Update polkadot
      
      * Add runtime-benchmarks feature
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      Co-authored-by: default avatargirazoki <[email protected]>
      Co-authored-by: parity-processbot <>
      3a459e8f