1. 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
  2. Jan 22, 2024
  3. Jan 20, 2024
  4. Jan 18, 2024
  5. Jan 16, 2024
  6. Jan 15, 2024
  7. Jan 13, 2024
  8. Jan 10, 2024
  9. Jan 09, 2024
  10. Jan 08, 2024
  11. Jan 07, 2024
  12. Jan 04, 2024
  13. Dec 20, 2023
  14. Dec 18, 2023
  15. Dec 13, 2023
  16. Dec 11, 2023
  17. Dec 08, 2023
    • 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
  18. Dec 07, 2023
  19. Dec 01, 2023
  20. Nov 30, 2023
  21. Nov 29, 2023
  22. Nov 28, 2023
  23. Nov 27, 2023
    • Koute's avatar
      Build the standard library crates when building the runtimes (#2217) · 2610450a
      Koute authored
      Our executor currently only supports the WASM MVP feature set, however
      nowadays when compiling WASM the Rust compiler has more features enabled
      by default.
      
      We do set the `-C target-cpu=mvp` flag to make sure that *our* code gets
      compiled in a way that is compatible with our executor, however this
      doesn't affect Rust's standard library crates (`std`, `core` and
      `alloc`) which are by default precompiled and still can make use of
      these extra features.
      
      So in this PR we force the compiler to also compile the standard library
      crates for us to make sure that they also only use the MVP features.
      
      I've added the `WASM_BUILD_STD` environment variable which can be used
      to disable this behavior if set to `0`.
      
      Unfortunately this *will* slow down the compile times when building
      runtimes, but there isn't much that we can do about that.
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/1755
      
      
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      2610450a
  24. Nov 23, 2023
  25. Nov 19, 2023
  26. Nov 13, 2023
  27. Nov 06, 2023
  28. Nov 03, 2023
    • Bastian Köcher's avatar
      `sc-block-builder`: Remove `BlockBuilderProvider` (#2099) · ca5f1056
      Bastian Köcher authored
      The `BlockBuilderProvider` was a trait that was defined in
      `sc-block-builder`. The trait was implemented for `Client`. This
      basically meant that you needed to import `sc-block-builder` any way to
      have access to the block builder. So, this trait was not providing any
      real value. This pull request is removing the said trait. Instead of the
      trait it introduces a builder for creating a `BlockBuilder`. The builder
      currently has the quite fabulous name `BlockBuilderBuilder` (I'm open to
      any better name 😅
      
      ). The rest of the pull request is about
      replacing the old trait with the new builder.
      
      # Downstream code changes
      
      If you used `new_block` or `new_block_at` before you now need to switch
      it over to the new `BlockBuilderBuilder` pattern:
      
      ```rust
      // `new` requires a type that implements `CallApiAt`. 
      let mut block_builder = BlockBuilderBuilder::new(client)
                      // Then you need to specify the hash of the parent block the block will be build on top of
      		.on_parent_block(at)
                      // The block builder also needs the block number of the parent block. 
                      // Here it is fetched from the given `client` using the `HeaderBackend`
                      // However, there also exists `with_parent_block_number` for directly passing the number
      		.fetch_parent_block_number(client)
      		.unwrap()
                      // Enable proof recording if required. This call is optional.
      		.enable_proof_recording()
                      // Pass the digests. This call is optional.
                      .with_inherent_digests(digests)
      		.build()
      		.expect("Creates new block builder");
      ```
      
      ---------
      
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      Co-authored-by: command-bot <>
      ca5f1056
  29. Oct 29, 2023
  30. Oct 25, 2023
    • Oliver Tale-Yazdi's avatar
    • Liam Aharon's avatar
      Small optimisation to `--profile dev` wasm builds (#1851) · ff3a3bca
      Liam Aharon authored
      `wasm-builder` was adjusted to default to building wasm blobs in
      `release` mode even when cargo is in `debug` because `debug` wasm is too
      slow.
      
      A side effect of this was `.compact` and `.compact.compressed` getting
      built when the dev is running build in `debug`, adding ~5s to the build
      time of every wasm runtime.
      
      I think it's reasonable to assume if the dev is running `debug` build
      they want to optimise speed and do not care about the size of the wasm
      binary. Compacting a blob has negligible impact on its actual
      performance.
      
      In this PR, I adjusted the behavior of the wasm builder so it does not
      produce `.compact` or `.compact.compressed` wasm when the user is
      running in `debug`. The builder will continue to produce the bloaty wasm
      in release mode unless it is overriden with an env var.
      
      As suggested by @koute in review, also refactored the
      `maybe_compact_wasm_and_copy_blobs` into multiple funuctions, and
      renamed things to better support RISC-V in the future.
      
      ---
      
      There is no `T-runtime` label so @KiChjang
      
       told me to put `T1-FRAME` :)
      
      ---------
      
      Co-authored-by: default avatarKoute <[email protected]>
      ff3a3bca
  31. Oct 24, 2023
  32. Oct 23, 2023
    • aj3n's avatar
      wasm-builder: manually set CARGO_TARGET_DIR (#1951) · 38c3c625
      aj3n authored
      ✄
      -----------------------------------------------------------------------------
      
      Thank you for your Pull Request! 🙏 Please make sure it follows the
      contribution guidelines outlined in
      [this
      document](https://github.com/paritytech/polkadot-sdk/blob/master/docs/CONTRIBUTING.md)
      and fill
      out the sections below. Once you're ready to submit your PR for review,
      please
      delete this section and leave only the text under the "Description"
      heading.
      
      # Description
      
      *Please include a summary of the changes and the related issue. Please
      also include relevant motivation and context,
      including:*
      
      - What does this PR do?
      
      make 'substrate-wasm-builder' manually set 'CARGO_TARGET_DIR' to
      '$project_dir/target' while building instead of unset
      'CARGO_TARGET_DIR';
      
      - Why are these changes needed?
      
      If you using this in the `build.rs` with following content in your
      `~/.cargo/config.toml':
      
          [build]
          target-dir = "target"
      
      the build process will stuck because of dead lock -- two `cargo build`
      on same target directory in the same time.
      There is already an attempt to avoid such dead lock by unset the
      `CARGO_TARGET_DIR`, but for users with config above in his build
      enviroment (like me), this workaround won't work.
      
      - How were these changes implemented and what do they affect?
      
      Instead of unset 'CARGO_TARGET_DIR', we set 'CARGO_TARGET_DIR' to
      '$project/target/', which is already assumed to be true by rest of the
      code.
      
      *Use [Github semantic
      
      linking](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)
      to address any open issues this PR relates to or closes.*
      
      Fixes # (issue number, *if applicable*)
      
      Closes # (issue number, *if applicable*)
      
      # Checklist
      
      - [x] My PR includes a detailed description as outlined in the
      "Description" section above
      - [ ] My PR follows the [labeling requirements](CONTRIBUTING.md#Process)
      of this project (at minimum one label for `T`
        required)
      - [ ] I have made corresponding changes to the documentation (if
      applicable)
      - [ ] I have added tests that prove my fix is effective or that my
      feature works (if applicable)
      
      You can remove the "Checklist" section once all have been checked. Thank
      you for your contribution!
      
      ✄
      -----------------------------------------------------------------------------
      
      I have built my project with this fix, there's still some warnings with
      `build.target-dir` set but the building process won't hang.
      I haven't found related issue in this repo. But I did find one issue
      [here](https://github.com/substrate-developer-hub/substrate-node-template/issues/116).
      38c3c625
  33. Oct 20, 2023
    • Bastian Köcher's avatar
      `xcm`: Change `TypeInfo::path` to not include `staging` (#1948) · f3bf5c1a
      Bastian Köcher authored
      The `xcm` crate was renamed to `staging-xcm` to be able to publish it to
      crates.io as someone as squatted `xcm`. The problem with this rename is
      that the `TypeInfo` includes the crate name which ultimately lands in
      the metadata. The metadata is consumed by downstream users like
      `polkadot-js` or people building on top of `polkadot-js`. These people
      are using the entire `path` to find the type in the type registry. Thus,
      their code would break as the type path would now be [`staging_xcm`,
      `VersionedXcm`] instead of [`xcm`, `VersionedXcm`]. This pull request
      fixes this by renaming the path segment `staging_xcm` to `xcm`.
      
      This requires: https://github.com/paritytech/scale-info/pull/197
      
      
      
      ---------
      
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      f3bf5c1a
  34. Oct 11, 2023