1. Jan 26, 2024
  2. Jan 24, 2024
  3. Jan 23, 2024
    • Niklas Adolfsson's avatar
      rpc: backpressured RPC server (bump jsonrpsee 0.20) (#1313) · e16ef086
      Niklas Adolfsson authored
      This is a rather big change in jsonrpsee, the major things in this bump
      are:
      - Server backpressure (the subscription impls are modified to deal with
      that)
      - Allow custom error types / return types (remove jsonrpsee::core::Error
      and jsonrpee::core::CallError)
      - Bug fixes (graceful shutdown in particular not used by substrate
      anyway)
         - Less dependencies for the clients in particular
         - Return type requires Clone in method call responses
         - Moved to tokio channels
         - Async subscription API (not used in this PR)
      
      Major changes in this PR:
      - The subscriptions are now bounded and if subscription can't keep up
      with the server it is dropped
      - CLI: add parameter to configure the jsonrpc server bounded message
      buffer (default is 64)
      - Add our own subscription helper to deal with the unbounded streams in
      substrate
      
      The most important things in this PR to review is the added helpers
      functions in `substrate/client/rpc/src/utils.rs` and the rest is pretty
      much chore.
      
      Regarding the "bounded buffer limit" it may cause the server to handle
      the JSON-RPC calls
      slower than before.
      
      The message size limit is bounded by "--rpc-response-size" thus "by
      default 10MB * 64 = 640MB"
      but the subscription message size is not covered by this limit and could
      be capped as well.
      
      Hopefully the last release prior to 1.0, sorry in advance for a big PR
      
      Previous attempt: https://github.com/paritytech/substrate/pull/13992
      
      Resolves https://github.com/paritytech/polkadot-sdk/issues/748, resolves
      https://github.com/paritytech/polkadot-sdk/issues/627
      e16ef086
  4. Jan 22, 2024
  5. Jan 19, 2024
  6. Jan 18, 2024
  7. Jan 16, 2024
    • Francisco Aguirre's avatar
      XCMv4 (#1230) · 8428f678
      Francisco Aguirre authored
      
      
      # Note for reviewer
      
      Most changes are just syntax changes necessary for the new version.
      Most important files should be the ones under the `xcm` folder.
      
      # Description 
      
      Added XCMv4.
      
      ## Removed `Multi` prefix
      The following types have been renamed:
      - MultiLocation -> Location
      - MultiAsset -> Asset
      - MultiAssets -> Assets
      - InteriorMultiLocation -> InteriorLocation
      - MultiAssetFilter -> AssetFilter
      - VersionedMultiAsset -> VersionedAsset
      - WildMultiAsset -> WildAsset
      - VersionedMultiLocation -> VersionedLocation
      
      In order to fix a name conflict, the `Assets` in `xcm-executor` were
      renamed to `HoldingAssets`, as they represent assets in holding.
      
      ## Removed `Abstract` asset id
      
      It was not being used anywhere and this simplifies the code.
      
      Now assets are just constructed as follows:
      
      ```rust
      let asset: Asset = (AssetId(Location::new(1, Here)), 100u128).into();
      ```
      
      No need for specifying `Concrete` anymore.
      
      ## Outcome is now a named fields struct
      
      Instead of
      
      ```rust
      pub enum Outcome {
        Complete(Weight),
        Incomplete(Weight, Error),
        Error(Error),
      }
      ```
      
      we now have
      
      ```rust
      pub enum Outcome {
        Complete { used: Weight },
        Incomplete { used: Weight, error: Error },
        Error { error: Error },
      }
      ```
      
      ## Added Reanchorable trait
      
      Now both locations and assets implement this trait, making it easier to
      reanchor both.
      
      ## New syntax for building locations and junctions
      
      Now junctions are built using the following methods:
      
      ```rust
      let location = Location {
          parents: 1,
          interior: [Parachain(1000), PalletInstance(50), GeneralIndex(1984)].into()
      };
      ```
      
      or
      
      ```rust
      let location = Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(1984)]);
      ```
      
      And they are matched like so:
      
      ```rust
      match location.unpack() {
        (1, [Parachain(id)]) => ...
        (0, Here) => ...,
        (1, [_]) => ...,
      }
      ```
      
      This syntax is mandatory in v4, and has been also implemented for v2 and
      v3 for easier migration.
      
      This was needed to make all sizes smaller.
      
      # TODO
      - [x] Scaffold v4
      - [x] Port github.com/paritytech/polkadot/pull/7236
      - [x] Remove `Multi` prefix
      - [x] Remove `Abstract` asset id
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      8428f678
    • Xavier Lau's avatar
      CI check features (#1708) · 05cfb02b
      Xavier Lau authored
      To resolve issue #1136.
      
      This is a cross verification against zepter.
      
      - [cargo-featalign](https://github.com/hack-ink/cargo-featalign):
      Verifies the proper propagation of all features.
      - [zepter](https://github.com/ggwpez/zepter): Checks for accidentally
      enabled features.
      
      cc @ggwpez
      
       
      
      ---
      Switch to a new branch. Original PR #1537.
      
      ---------
      
      Signed-off-by: default avatarXavier Lau <[email protected]>
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarChevdor <[email protected]>
      05cfb02b
  8. Jan 15, 2024
    • Liam Aharon's avatar
      Unbalanced and Balanced fungible conformance tests, and fungible fixes (#1296) · 46090ff1
      Liam Aharon authored
      Original PR https://github.com/paritytech/substrate/pull/14655
      
      ---
      
      Partial https://github.com/paritytech/polkadot-sdk/issues/225
      
      - [x] Adds conformance tests for Unbalanced
      - [x] Adds conformance tests for Balanced
      - Several minor fixes to fungible default implementations and the
      Balances pallet
      - [x] `Unbalanced::decrease_balance` can reap account when
      `Preservation` is `Preserve`
      - [x] `Balanced::pair` can return pairs of imbalances which do not
      cancel each other out
         - [x] Balances pallet `active_issuance` 'underflow'
      - [x] Refactors the conformance test file structure to match the
      fungible file structure: tests for traits in regular.rs go into a test
      file named regular.rs, tests for traits in freezes.rs go into a test
      file named freezes.rs, etc.
       - [x] Improve doc comments
       - [x] Simplify macros
      
      ## Fixes
      
      ### `Unbalanced::decrease_balance` can reap account when called with
      `Preservation::Preserve`
      There is a potential issue in the default implementation of
      `Unbalanced::decrease_balance`. The implementation can delete an account
      even when it is called with `preservation: Preservation::Preserve`. This
      seems to contradict the documentation of `Preservation::Preserve`:
      
      ```rust
      	/// The account may not be killed and our provider reference must remain (in the context of
      	/// tokens, this means that the account may not be dusted).
      	Preserve,
      ```
      
      I updated `Unbalanced::decrease_balance` to return
      `Err(TokenError::BelowMinimum)` when a withdrawal would cause the
      account to be reaped and `preservation: Preservation::Preserve`.
      
      - [ ] TODO Confirm with @gavofyork that this is correct behavior
      
      Test for this behavior:
      
      
      https://github.com/paritytech/polkadot-sdk/blob/e5c876dd6b59e2b7dbacaa4538cb42c802db3730/substrate/frame/support/src/traits/tokens/fungible/conformance_tests/regular.rs#L912-L937
      
      ### `Balanced::pair` returning non-canceling pairs
      
      `Balanced::pair` is supposed to create a pair of imbalances that cancel
      each other out. However this is not the case when the method is called
      with an amount greater than the total supply.
      
      In the existing default implementation, `Balanced::pair` creates a pair
      by first rescinding the balance, creating `Debt`, and then issuing the
      balance, creating `Credit`.
      
      When creating `Debt`, if the amount to create exceeds the
      `total_supply`, `total_supply` units of `Debt` are created *instead* of
      `amount` units of `Debt`. This can lead to non-canceling amount of
      `Credit` and `Debt` being created.
      
      To address this, I create the credit and debt directly in the method
      instead of calling `issue` and `rescind`.
      
      Test for this behavior:
      
      
      https://github.com/paritytech/polkadot-sdk/blob/e5c876dd6b59e2b7dbacaa4538cb42c802db3730/substrate/frame/support/src/traits/tokens/fungible/conformance_tests/regular.rs#L1323-L1346
      
      ### `Balances` pallet `active_issuance` 'underflow'
      
      This PR resolves an issue in the `Balances` pallet that can lead to odd
      behavior of `active_issuance`.
      
      Currently, the Balances pallet doesn't check if `InactiveIssuance`
      remains less than or equal to `TotalIssuance` when supply is
      deactivated. This allows `InactiveIssuance` to be greater than
      `TotalIssuance`, which can result in unexpected behavior from the
      perspective of the fungible API.
      
      `active_issuance` is derived from
      `TotalIssuance.saturating_sub(InactiveIssuance)`.
      
      If an `amount` is deactivated that causes `InactiveIssuance` to become
      greater TotalIssuance, `active_issuance` will return 0. However once in
      that state, reactivating an amount will not increase `active_issuance`
      by the reactivated `amount` as expected.
      
      Consider this test where the last assertion would fail due to this
      issue:
      
      
      https://github.com/paritytech/polkadot-sdk/blob/e5c876dd6b59e2b7dbacaa4538cb42c802db3730/substrate/frame/support/src/traits/tokens/fungible/conformance_tests/regular.rs#L1036-L1071
      
      
      
      To address this, I've modified the `deactivate` function to ensure
      `InactiveIssuance` never surpasses `TotalIssuance`.
      
      ---------
      
      Co-authored-by: default avatarMuharem <[email protected]>
      46090ff1
  9. Jan 13, 2024
  10. Jan 11, 2024
    • Michal Kucharczyk's avatar
      frame-support: sp-runtime dependency updated (serde) (#2907) · c8112e2c
      Michal Kucharczyk authored
      `frame-support` crate compilation fails (reported by @koute):
      
      ```
      $ cargo check --no-default-features --target=wasm32-unknown-unknown
      
      error[E0277]: the trait bound `GC: Serialize` is not satisfied
          --> substrate/frame/support/src/genesis_builder_helper.rs:32:24
           |
      32   |     serde_json::to_string(&GC::default())
           |     --------------------- ^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `GC`
           |     |
           |     required by a bound introduced by this call
           |
      note: required by a bound in `serde_json::to_string`
          --> /home/kou/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.111/src/ser.rs:2209:17
           |
      2207 | pub fn to_string<T>(value: &T) -> Result<String>
           |        --------- required by a bound in this function
      2208 | where
      2209 |     T: ?Sized + Serialize,
           |                 ^^^^^^^^^ required by this bound in `to_string`
      help: consider further restricting this bound
           |
      30   |     GC: BuildGenesisConfig + Default + serde::Serialize,
           |                                      ++++++++++++++++++
      ```
      
      This PR should fix this.
      
      For all runtimes `sp-runtime/serde` feature was likely enabled by this
      (and few other pallets):
      
      https://github.com/paritytech/polkadot-sdk/blob/f2a750ee86e72c9ab677aaf588d0a33ee8446bef/substrate/frame/system/Cargo.toml#L27
      c8112e2c
  11. Jan 10, 2024
  12. Jan 09, 2024
  13. Jan 08, 2024
  14. Jan 07, 2024
  15. Jan 05, 2024
  16. Jan 04, 2024
  17. Dec 28, 2023
  18. Dec 23, 2023
  19. Dec 22, 2023
  20. Dec 20, 2023
    • joe petrowski's avatar
      Add Authorize Upgrade Pattern to Frame System (#2682) · 280aa0b5
      joe petrowski authored
      Adds the `authorize_upgrade` -> `enact_authorized_upgrade` pattern to
      `frame-system`. This will be useful for upgrading bridged chains that
      are under the governance of Polkadot without passing entire runtime Wasm
      blobs over a bridge.
      
      Notes:
      
      - Changed `enact_authorized_upgrade` to `apply_authorized_upgrade`.
      Personal opinion, "apply" more accurately expresses what it's doing. Can
      change back if outvoted.
      - Remove `check_version` in favor of two extrinsics, so as to make
      _checked_ the default.
      - Left calls in `parachain-system` and marked as deprecated to prevent
      breaking the API. They just call into the `frame-system` functions.
      - Updated `frame-system` benchmarks to v2 syntax.
      
      ---------
      
      Co-authored-by: command-bot <>
      280aa0b5
  21. Dec 19, 2023
  22. Dec 18, 2023
  23. Dec 15, 2023
  24. Dec 14, 2023
  25. Dec 13, 2023
  26. Dec 11, 2023
  27. Dec 10, 2023
  28. Dec 08, 2023
    • Bastian Köcher's avatar
      Update proc-macro-crate (#2660) · f6ae1458
      Bastian Köcher authored
      f6ae1458
    • Sam Johnson's avatar
      Tasks: general system for recognizing and executing service work (#1343) · ac3f14d2
      Sam Johnson authored
      `polkadot-sdk` version of original tasks PR located here:
      https://github.com/paritytech/substrate/pull/14329
      
      Fixes #206
      
      ## Status
      - [x] Generic `Task` trait
      - [x] `RuntimeTask` aggregated enum, compatible with
      `construct_runtime!`
      - [x] Casting between `Task` and `RuntimeTask` without needing `dyn` or
      `Box`
      - [x] Tasks Example pallet
      - [x] Runtime tests for Tasks example pallet
      - [x] Parsing for task-related macros
      - [x] Retrofit parsing to make macros optional
      - [x] Expansion for task-related macros
      - [x] Adds support for args in tasks
      - [x] Retrofit tasks example pallet to use macros instead of manual
      syntax
      - [x] Weights
      - [x] Cleanup
      - [x] UI tests
      - [x] Docs
      
      ## Target Syntax
      Adapted from
      https://github.com/paritytech/polkadot-sdk/issues/206#issue-1865172283
      
      
      
      ```rust
      // NOTE: this enum is optional and is auto-generated by the other macros if not present
      #[pallet::task]
      pub enum Task<T: Config> {
          AddNumberIntoTotal {
              i: u32,
          }
      }
      
      /// Some running total.
      #[pallet::storage]
      pub(super) type Total<T: Config<I>, I: 'static = ()> =
      StorageValue<_, (u32, u32), ValueQuery>;
      
      /// Numbers to be added into the total.
      #[pallet::storage]
      pub(super) type Numbers<T: Config<I>, I: 'static = ()> =
      StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
      
      #[pallet::tasks_experimental]
      impl<T: Config<I>, I: 'static> Pallet<T, I> {
      	/// Add a pair of numbers into the totals and remove them.
      	#[pallet::task_list(Numbers::<T, I>::iter_keys())]
      	#[pallet::task_condition(|i| Numbers::<T, I>::contains_key(i))]
      	#[pallet::task_index(0)]
      	pub fn add_number_into_total(i: u32) -> DispatchResult {
      		let v = Numbers::<T, I>::take(i).ok_or(Error::<T, I>::NotFound)?;
      		Total::<T, I>::mutate(|(total_keys, total_values)| {
      			*total_keys += i;
      			*total_values += v;
      		});
      		Ok(())
      	}
      }
      ```
      
      ---------
      
      Co-authored-by: default avatarNikhil Gupta <[email protected]>
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: Nikhil Gupta <>
      Co-authored-by: default avatarGavin Wood <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatargupnik <[email protected]>
      ac3f14d2
  29. Dec 07, 2023
  30. Dec 04, 2023
  31. Dec 01, 2023