1. Nov 29, 2023
  2. Nov 28, 2023
  3. 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
  4. Nov 23, 2023
  5. Nov 19, 2023
  6. Nov 13, 2023
  7. Nov 06, 2023
  8. 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
  9. Oct 29, 2023
  10. 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
  11. Oct 24, 2023
  12. 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
  13. 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
  14. Oct 11, 2023
  15. Oct 10, 2023
    • Liam Aharon's avatar
      remote-ext: fix state download stall on slow connections and reduce memory usage (#1295) · 55f35442
      Liam Aharon authored
      Original PR https://github.com/paritytech/substrate/pull/14746
      
      ---
      
      ## Fixing stall
      
      ### Introduction
      I experienced an apparent stall downloading state from
      `https://rococo-try-runtime-node.parity-chains.parity.io:443` which was
      having networking difficulties only responding to my JSONRPC requests
      with 50-200KB/s of bandwidth.
      
      This PR fixes the issue causing the stall, and generally improves
      performance remote-ext when it downloads state by greatly reducing the
      chances of a timeout occuring.
      
      ### Description
      Introduces a new `REQUEST_DURATION_TARGET` constant and modifies
      `get_storage_data_dynamic_batch_size` to
      
      - Increase or decrease the batch size of the next request depending on
      whether the elapsed time of the last request was gt or lt the target
      - Reset the batch size to 1 if the request times out
      
      This fixes an issue on slow connections that can otherwise cause
      multiple timeouts and a stalled download when:
      
      1. The batch size increases rapidly as remote-ext downloads keys with
      small associated storage values
      2. remote-ext tries to process a large series of subsequent keys all
      with extremely large associated storage values (Rococo has a series of
      keys 1-5MB large)
      3. The huge storage values download for 5 minutes until the request
      times out
      4. The partially downloaded keys are thrown out and remote-ext tries
      again with a smaller batch size, but the batch size is still far too
      large and takes 5 minutes to be reduced again
      5. The download will be essentially stalled for many hours while the
      above step cycles
      
      
      After this PR, the request size will
      
      - Not grow as large to begin with, as it is regulated downwards as the
      request duration exceeds the target
      - Drop immediately to 1 if the request times out. A timeout indicates
      the keys next in line to download have extremely large storage values
      compared to previously downloaded keys, and we need to reset the batch
      size to figure out what our new ideal batch size is. By not resetting
      down to 1, we risk the next request timing out again.
      
      ## Reducing memory
      
      As suggested by @bkchr, I adjusted `get_storage_data_dynamic_batch_size`
      from being recursive to a loop which allows removing a bunch of clones
      that were chewing through a lot of memory. I noticed actually it was
      using up to 50GB swap previously when downloading Polkadot keys on a
      slow connection, because it needed to recurse and clone a lot.
      
      After this change it uses only ~1.5GB memory.
      55f35442
  16. Oct 05, 2023
  17. Sep 27, 2023
    • Michal Kucharczyk's avatar
      `BlockId` removal: `tx-pool` refactor (#1678) · ab3a3bc2
      Michal Kucharczyk authored
      
      
      It changes following APIs:
      - trait `ChainApi`
      -- `validate_transaction`
      
      - trait `TransactionPool` 
      --`submit_at`
      --`submit_one`
      --`submit_and_watch`
      
      and some implementation details, in particular:
      - impl `Pool` 
      --`submit_at`
      --`resubmit_at`
      --`submit_one`
      --`submit_and_watch`
      --`prune_known`
      --`prune`
      --`prune_tags`
      --`resolve_block_number`
      --`verify`
      --`verify_one`
      
      - revalidation queue
      
      All tests are also adjusted.
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      ab3a3bc2
  18. Sep 21, 2023
  19. Sep 20, 2023
  20. Sep 15, 2023
  21. Sep 13, 2023
  22. Sep 12, 2023
  23. Sep 11, 2023
  24. Sep 05, 2023
  25. Sep 04, 2023
  26. Sep 01, 2023
  27. Aug 31, 2023
  28. Aug 30, 2023
  29. Aug 29, 2023
  30. Aug 25, 2023
  31. Aug 23, 2023
  32. Aug 22, 2023
  33. Aug 17, 2023