1. Nov 13, 2023
    • Adrian Catangiu's avatar
      pallet-xcm: enhance `reserve_transfer_assets` to support remote reserves (#1672) · 18257373
      Adrian Catangiu authored
      ## Motivation
      
      `pallet-xcm` is the main user-facing interface for XCM functionality,
      including assets manipulation functions like `teleportAssets()` and
      `reserve_transfer_assets()` calls.
      
      While `teleportAsset()` works both ways, `reserve_transfer_assets()`
      works only for sending reserve-based assets to a remote destination and
      beneficiary when the reserve is the _local chain_.
      
      ## Solution
      
      This PR enhances `pallet_xcm::(limited_)reserve_withdraw_assets` to
      support transfers when reserves are other chains.
      This will allow complete, **bi-directional** reserve-based asset
      transfers user stories using `pallet-xcm`.
      
      Enables following scenarios:
      - transferring assets with local reserve (was previously supported iff
      asset used as fee also had local reserve - now it works in all cases),
      - transferring assets with reserve on destination,
      - transferring assets with reserve on remote/third-party chain (iff
      assets and fees have same remote reserve),
      - transferring assets with reserve different than the reserve of the
      asset to be used as fees - meaning can be used to transfer random asset
      with local/dest reserve while using DOT for fees on all involved chains,
      even if DOT local/dest reserve doesn't match asset reserve,
      - transferring assets with any type of local/dest reserve while using
      fees which can be teleported between involved chains.
      
      All of the above is done by pallet inner logic without the user having
      to specify which scenario/reserves/teleports/etc. The correct scenario
      and corresponding XCM programs are identified, and respectively, built
      automatically based on runtime configuration of trusted teleporters and
      trusted reserves.
      
      #### Current limitations:
      - while `fees` and "non-fee" `assets` CAN have different reserves (or
      fees CAN be teleported), the remaining "non-fee" `assets` CANNOT, among
      themselves, have different reserve locations (this is also implicitly
      enforced by `MAX_ASSETS_FOR_TRANSFER=2`, but this can be safely
      increased in the future).
      - `fees` and "non-fee" `assets` CANNOT have **different remote**
      reserves (this could also be supported in the future, but adds even more
      complexity while possibly not being worth it - we'll see what the future
      holds).
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/1584
      Fixes https://github.com/paritytech/polkadot-sdk/issues/2055
      
      
      
      ---------
      
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      18257373
    • gupnik's avatar
    • gupnik's avatar
      Adds syntax for marking calls feeless (#1926) · 60c77a2e
      gupnik authored
      Fixes https://github.com/paritytech/polkadot-sdk/issues/1725
      
      
      
      This PR adds the following changes:
      1. An attribute `pallet::feeless_if` that can be optionally attached to
      a call like so:
      ```rust
      #[pallet::feeless_if(|_origin: &OriginFor<T>, something: &u32| -> bool {
      	*something == 0
      })]
      pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
           ....
      }
      ```
      The closure passed accepts references to arguments as specified in the
      call fn. It returns a boolean that denotes the conditions required for
      this call to be "feeless".
      
      2. A signed extension `SkipCheckIfFeeless<T: SignedExtension>` that
      wraps a transaction payment processor such as
      `pallet_transaction_payment::ChargeTransactionPayment`. It checks for
      all calls annotated with `pallet::feeless_if` to see if the conditions
      are met. If so, the wrapped signed extension is not called, essentially
      making the call feeless.
      
      In order to use this, you can simply replace your existing signed
      extension that manages transaction payment like so:
      ```diff
      - pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
      + pallet_skip_feeless_payment::SkipCheckIfFeeless<
      +	Runtime,
      +	pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
      + >,
      ```
      
      ### Todo
      - [x] Tests
      - [x] Docs
      - [x] Prdoc
      
      ---------
      
      Co-authored-by: Nikhil Gupta <>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      60c77a2e
    • Bastian Köcher's avatar
      pallet-grandpa: Remove `GRANDPA_AUTHORITIES_KEY` (#2181) · ebcf0a0f
      Bastian Köcher authored
      
      
      Remove the `GRANDPA_AUTHORITIES_KEY` key and its usage. Apparently this
      was used in the early days to communicate the grandpa authorities to the
      node. However, we have now a runtime api that does this for us. So, this
      pull request is moving from the custom managed storage item to a FRAME
      managed storage item.
      
      This pr also includes a migration for doing the switch on a running
      chain.
      
      ---------
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      ebcf0a0f
    • Bastian Köcher's avatar
      wasm-builder: Optimize `rerun-if-changed` logic (#2282) · 604704a8
      Bastian Köcher authored
      Optimizes the `rerun-if-changed` logic by ignoring `dev-dependencies`
      and also not outputting paths. Because outputting paths could lead to
      include unwanted crates in the rerun checks.
      604704a8
    • Marcin S.'s avatar
    • Dmitry Markin's avatar
      Unify `ChainSync` actions under one enum (#2180) · 951bcceb
      Dmitry Markin authored
      All `ChainSync` actions that `SyncingEngine` should perform are unified
      under one `ChainSyncAction`. Processing of these actions put into a
      single place after `select!` in `SyncingEngine::run` instead of multiple
      places where calling `ChainSync` methods.
      951bcceb
  2. Nov 11, 2023
  3. 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
    • Liam Aharon's avatar
      Improve `VersionedMigration` naming conventions (#2264) · 84ddbaf6
      Liam Aharon authored
      As suggested by @ggwpez
      (https://github.com/paritytech/polkadot-sdk/pull/2142#discussion_r1388145872),
      remove the `VersionChecked` prefix from version checked migrations (but
      leave `VersionUnchecked` prefixes)
      
      ---------
      
      Co-authored-by: command-bot <>
      84ddbaf6
    • Vincent Geddes's avatar
      [pallet-message-queue] Implement impl_trait_for_tuples for QueuePausedQuery (#2227) · 3f0383a5
      Vincent Geddes authored
      These changes are required so that the bridgehub system runtimes can
      more easily be configured with multiple message processors
      
      Example usage:
      
      ```rust
      use frame_support::traits::QueuePausedQuery;
      
      impl pallet_message_queue::Config for Runtime {
          type QueuePausedQuery = (A, B, C)
      }
      3f0383a5
    • PG Herveou's avatar
      Contracts move fixtures to new crate (#2246) · 64effd0e
      PG Herveou authored
      Small PR that introduce a new crate that will host RISC-V & wasm
      fixtures for testing pallet-contracts
      64effd0e
  4. Nov 09, 2023
    • Lulu's avatar
      Add license to tracking-allocator and add staging-prefix (#2261) · 03ee44d9
      Lulu authored
      The staging- rename commit was missing from the last PR for some reason.
      03ee44d9
    • Bastian Köcher's avatar
      sc-state-db: Keep track of `LAST_PRUNED` after warp syncing (#2228) · b0d0fb31
      Bastian Köcher authored
      When warp syncing we import the target block with all its state.
      However, we didn't store the `LAST_PRUNED` block which would then lead
      to `pruning` to forget about the imported block after a restart of the
      node. We just set `LAST_PRUNED` to the parent block of the warp sync
      target block to fix this issue.
      b0d0fb31
    • Lulu's avatar
      Don't publish frame and deps (#2260) · e8029a77
      Lulu authored
      e8029a77
    • Lulu's avatar
    • Oliver Tale-Yazdi's avatar
      Add descriptions to all published crates (#2029) · 48ea86f0
      Oliver Tale-Yazdi authored
      
      
      Missing descriptions (47):  
      
      - [x] `cumulus/client/collator/Cargo.toml`
      - [x] `cumulus/client/relay-chain-inprocess-interface/Cargo.toml`
      - [x] `cumulus/client/cli/Cargo.toml`
      - [x] `cumulus/client/service/Cargo.toml`
      - [x] `cumulus/client/relay-chain-rpc-interface/Cargo.toml`
      - [x] `cumulus/client/relay-chain-interface/Cargo.toml`
      - [x] `cumulus/client/relay-chain-minimal-node/Cargo.toml`
      - [x] `cumulus/parachains/pallets/parachain-info/Cargo.toml`
      - [x] `cumulus/parachains/pallets/ping/Cargo.toml`
      - [x] `cumulus/primitives/utility/Cargo.toml`
      - [x] `cumulus/primitives/aura/Cargo.toml`
      - [x] `cumulus/primitives/core/Cargo.toml`
      - [x] `cumulus/primitives/parachain-inherent/Cargo.toml`
      - [x] `cumulus/test/relay-sproof-builder/Cargo.toml`
      - [x] `cumulus/pallets/xcmp-queue/Cargo.toml`
      - [x] `cumulus/pallets/dmp-queue/Cargo.toml`
      - [x] `cumulus/pallets/xcm/Cargo.toml`
      - [x] `polkadot/erasure-coding/Cargo.toml`
      - [x] `polkadot/statement-table/Cargo.toml`
      - [x] `polkadot/primitives/Cargo.toml`
      - [x] `polkadot/rpc/Cargo.toml`
      - [x] `polkadot/node/service/Cargo.toml`
      - [x] `polkadot/node/core/parachains-inherent/Cargo.toml`
      - [x] `polkadot/node/core/approval-voting/Cargo.toml`
      - [x] `polkadot/node/core/dispute-coordinator/Cargo.toml`
      - [x] `polkadot/node/core/av-store/Cargo.toml`
      - [x] `polkadot/node/core/chain-api/Cargo.toml`
      - [x] `polkadot/node/core/prospective-parachains/Cargo.toml`
      - [x] `polkadot/node/core/backing/Cargo.toml`
      - [x] `polkadot/node/core/provisioner/Cargo.toml`
      - [x] `polkadot/node/core/runtime-api/Cargo.toml`
      - [x] `polkadot/node/core/bitfield-signing/Cargo.toml`
      - [x] `polkadot/node/network/dispute-distribution/Cargo.toml`
      - [x] `polkadot/node/network/bridge/Cargo.toml`
      - [x] `polkadot/node/network/collator-protocol/Cargo.toml`
      - [x] `polkadot/node/network/approval-distribution/Cargo.toml`
      - [x] `polkadot/node/network/availability-distribution/Cargo.toml`
      - [x] `polkadot/node/network/bitfield-distribution/Cargo.toml`
      - [x] `polkadot/node/network/gossip-support/Cargo.toml`
      - [x] `polkadot/node/network/availability-recovery/Cargo.toml`
      - [x] `polkadot/node/collation-generation/Cargo.toml`
      - [x] `polkadot/node/overseer/Cargo.toml`
      - [x] `polkadot/runtime/parachains/Cargo.toml`
      - [x] `polkadot/runtime/common/slot_range_helper/Cargo.toml`
      - [x] `polkadot/runtime/metrics/Cargo.toml`
      - [x] `polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml`
      - [x] `polkadot/utils/generate-bags/Cargo.toml`
      - [x]  `substrate/bin/minimal/runtime/Cargo.toml`
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Signed-off-by: default avataralindima <[email protected]>
      Co-authored-by: default avatarordian <[email protected]>
      Co-authored-by: default avatarTsvetomir Dimitrov <[email protected]>
      Co-authored-by: default avatarMarcin S <[email protected]>
      Co-authored-by: default avataralindima <[email protected]>
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      48ea86f0
    • Keith Yeung's avatar
      Remove unnecessary map_error (#2239) · d347d688
      Keith Yeung authored
      This was discovered during a debugging session, and it only served to
      mask the underlying error, which was not great.
      d347d688
  5. Nov 08, 2023
  6. Nov 07, 2023
    • Sebastian Kunert's avatar
      Disable incoming light-client connections for minimal relay node (#2202) · 8ebb5c33
      Sebastian Kunert authored
      When running with `--relay-chain-rpc-url` we received multiple reports
      of high traffic that disappears when `--in-peers-light 0` is set. Indeed
      it does not make much sense for light clients to connect to the minimal
      node since it is not running the block announce protocol and the
      request/response protocol for light clients.
      
      This is intended to alleviate the traffic issues for now.
      
      closes #1896
      probably related https://github.com/paritytech/cumulus/issues/2563
      8ebb5c33
    • Bill Laboon's avatar
      Fix "slashaed" typo (#2205) · 44c7a5eb
      Bill Laboon authored
      # Description
      
      This merely fixes a typo in the documentation, replacing the typo
      "slashaed" with "slashed". Since external entities use the comments for
      explanations of events, this will then be shown externally. I noticed
      this when reviewing [this
      event](https://polkadot.subscan.io/extrinsic/0xb6bc1e3abde0c2ed9c500c74cfc64cdb8179e5d9af97f4bf53242ce4cdd15a1d?event=18064194-6)
      on Subscan.
      
      This is not related to any other issues or PRs.
      44c7a5eb
    • vuittont60's avatar
      docs: fix typos (#2193) · 4caa3d8d
      vuittont60 authored
      4caa3d8d
    • Xiliang Chen's avatar
      mark pallet-asset-rate optional in polkadot-runtime-common (#2187) · 295a8483
      Xiliang Chen authored
      Part of #2186
      
      The only usage of pallet-asset-rate is guarded by `runtime-benchmarks`
      feature. I don't want ORML to be forced to include this pallet in deps
      for no good reason.
      295a8483
    • Alexandru Gheorghe's avatar
      zombienet_tests: Fix genesis error in 0006-parachains-max-tranche0.toml (#2191) · f5e9827f
      Alexandru Gheorghe authored
      There was a race in merging between
      https://github.com/paritytech/polkadot-sdk/pull/1256 and
      https://github.com/paritytech/polkadot-sdk/pull/1178
      
      , so this newly
      added tests wasn't updated with the new path for the configuration, so
      fix that.
      
      Signed-off-by: default avatarAlexandru Gheorghe <[email protected]>
      f5e9827f
    • Liam Aharon's avatar
      Initialise on-chain `StorageVersion` for pallets added after genesis (#1297) · c4211b65
      Liam Aharon authored
      Original PR https://github.com/paritytech/substrate/pull/14641
      
      ---
      
      Closes https://github.com/paritytech/polkadot-sdk/issues/109
      
      
      
      ### Problem
      Quoting from the above issue:
      
      > When adding a pallet to chain after genesis we currently don't set the
      StorageVersion. So, when calling on_chain_storage_version it returns 0
      while the pallet is maybe already at storage version 9 when it was added
      to the chain. This could lead to issues when running migrations.
      
      ### Solution
      
      - Create a new trait `BeforeAllRuntimeMigrations` with a single method
      `fn before_all_runtime_migrations() -> Weight` trait with a noop default
      implementation
      - Modify `Executive` to call
      `BeforeAllRuntimeMigrations::before_all_runtime_migrations` for all
      pallets before running any other hooks
      - Implement `BeforeAllRuntimeMigrations` in the pallet proc macro to
      initialize the on-chain version to the current pallet version if the
      pallet has no storage set (indicating it has been recently added to the
      runtime and needs to have its version initialised).
      
      ### Other changes in this PR
      
      - Abstracted repeated boilerplate to access the `pallet_name` in the
      pallet expand proc macro.
      
      ### FAQ
      
      #### Why create a new hook instead of adding this logic to the pallet
      `pre_upgrade`?
      
      `Executive` currently runs `COnRuntimeUpgrade` (custom migrations)
      before `AllPalletsWithSystem` migrations. We need versions to be
      initialized before the `COnRuntimeUpgrade` migrations are run, because
      `COnRuntimeUpgrade` migrations may use the on-chain version for critical
      logic. e.g. `VersionedRuntimeUpgrade` uses it to decide whether or not
      to execute.
      
      We cannot reorder `COnRuntimeUpgrade` and `AllPalletsWithSystem` so
      `AllPalletsWithSystem` runs first, because `AllPalletsWithSystem` have
      some logic in their `post_upgrade` hooks to verify that the on-chain
      version and current pallet version match. A common use case of
      `COnRuntimeUpgrade` migrations is to perform a migration which will
      result in the versions matching, so if they were reordered these
      `post_upgrade` checks would fail.
      
      #### Why init the on-chain version for pallets without a current storage
      version?
      
      We must init the on-chain version for pallets even if they don't have a
      defined storage version so if there is a future version bump, the
      on-chain version is not automatically set to that new version without a
      proper migration.
      
      e.g. bad scenario:
      
      1. A pallet with no 'current version' is added to the runtime
      2. Later, the pallet is upgraded with the 'current version' getting set
      to 1 and a migration is added to Executive Migrations to migrate the
      storage from 0 to 1
          a. Runtime upgrade occurs
          b. `before_all` hook initializes the on-chain version to 1
      c. `on_runtime_upgrade` of the migration executes, and sees the on-chain
      version is already 1 therefore think storage is already migrated and
      does not execute the storage migration
      Now, on-chain version is 1 but storage is still at version 0.
      
      By always initializing the on-chain version when the pallet is added to
      the runtime we avoid that scenario.
      
      ---------
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      c4211b65
  7. Nov 06, 2023