Skip to content
Snippets Groups Projects
  1. Feb 17, 2025
  2. Feb 15, 2025
  3. Feb 14, 2025
    • Kian Paimani's avatar
      [AHM] Multi-block staking election pallet (#7282) · a025562b
      Kian Paimani authored
      ## Multi Block Election Pallet
      
      This PR adds the first iteration of the multi-block staking pallet. 
      
      From this point onwards, the staking and its election provider pallets
      are being customized to work in AssetHub. While usage in solo-chains is
      still possible, it is not longer the main focus of this pallet. For a
      safer usage, please fork and user an older version of this pallet.
      
      ---
      
      ## Replaces
      
      - [x] https://github.com/paritytech/polkadot-sdk/pull/6034 
      - [x] https://github.com/paritytech/polkadot-sdk/pull/5272
      
      ## Related PRs: 
      
      - [x] https://github.com/paritytech/polkadot-sdk/pull/7483
      - [ ] https://github.com/paritytech/polkadot-sdk/pull/7357
      - [ ] https://github.com/paritytech/polkadot-sdk/pull/7424
      - [ ] https://github.com/paritytech/polkadot-staking-miner/pull/955
      
      This branch can be periodically merged into
      https://github.com/paritytech/polkadot-sdk/pull/7358 ->
      https://github.com/paritytech/polkadot-sdk/pull/6996
      
      ## TODOs: 
      
      - [x] rebase to master 
      - Benchmarking for staking critical path
        - [x] snapshot
        - [x] election result
      - Benchmarking for EPMB critical path
        - [x] snapshot
        - [x] verification
        - [x] submission
        - [x] unsigned submission
        - [ ] election results fetching
      - [ ] Fix deletion weights. Either of
        - [ ] Garbage collector + lazy removal of all paged storage items
        - [ ] Confirm that deletion is small PoV footprint.
      - [ ] Move election prediction to be push based. @tdimitrov 
      - [ ] integrity checks for bounds 
      - [ ] Properly benchmark this as a part of CI -- for now I will remove
      them as they are too slow
      - [x] add try-state to all pallets
      - [x] Staking to allow genesis dev accounts to be created internally
      - [x] Decouple miner config so @niklasad1 can work on the miner
      72841b73
      - [x] duplicate snapshot page reported by @niklasad1
      
       
      - [ ] https://github.com/paritytech/polkadot-sdk/pull/6520 or equivalent
      -- during snapshot, `VoterList` must be locked
      - [ ] Move target snapshot to a separate block
      
      ---------
      
      Co-authored-by: default avatarGonçalo Pestana <g6pestana@gmail.com>
      Co-authored-by: default avatarAnkan <10196091+Ank4n@users.noreply.github.com>
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>
      Co-authored-by: default avatarGiuseppe Re <giuseppe.re@parity.io>
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Michal Kucharczyk's avatar
      `txpool api`: `remove_invalid` call improved (#6661) · c94df1bc
      Michal Kucharczyk authored
      #### Description 
      Currently the transaction which is reported as invalid by a block
      builder (or `removed_invalid` by other components) is silently skipped.
      
      This PR improves this behavior. The transaction pool `report_invalid`
      function now accepts optional error associated with every reported
      transaction, and also the optional block hash which provides hints how
      reported transaction shall be handled. The following API change is
      proposed:
      
      https://github.com/paritytech/polkadot-sdk/blob/8be5ef3e/substrate/client/transaction-pool/api/src/lib.rs#L297-L318
      Depending on error, the transaction pool can decide if transaction shall
      be removed from the view only or entirely from the pool. Invalid event
      will be dispatched if required.
      
      
      #### Notes for reviewers
      
      - Actual logic of removing invalid txs is implented in
      [`ViewStore::report_invalid`](https://github.com/paritytech/polkadot-sdk/blob/0fad26c4/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs#L657-L680).
      Method's doc explains the flow.
      - This PR changes `HashMap` to `IndexMap` in revalidation logic. This is
      to preserve the original order of transactions (mainly for purposes of
      unit tests).
      - This PR solves the problem mentioned in:
      https://github.com/paritytech/polkadot-sdk/issues/5477#issuecomment-2598809344
      (which can now be resolved). The invalid transactions found during
      mempool revalidation are now also removed from the `view_store`. No
      dangling invalid transaction shall be left in the pool.
      (https://github.com/paritytech/polkadot-sdk/pull/6661/commits/bfec2625)
      - The support for dropping invalid transactions reported from the views
      was also added. This should never happen, but if for any case all views
      will report invalid transcation (which previously was valid) the
      transaction will be dropped from the pool
      (https://github.com/paritytech/polkadot-sdk/pull/6661/commits/48214a38
      
      ).
      
      
      
      fixes: #6008, #5477
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
    • Alexander Theißen's avatar
      pallet-revive: Fix the contract size related benchmarks (#7568) · 60146ba5
      Alexander Theißen authored
      
      Partly addresses https://github.com/paritytech/polkadot-sdk/issues/6157
      
      The benchmarks measuring the impact of contract sizes on calling or
      instantiating a contract were bogus because they needed to be written in
      assembly in order to tightly control the basic block size.
      
      This fixes the benchmarks for:
      - call_with_code_per_byte
      - upload_code
      - instantiate_with_code
      
      And adds a new benchmark that accounts for the fact that the interpreter
      will always compile whole basic blocks:
      - basic_block_compilation
      
      After this PR only the weight we assign to instructions need to be
      addressed.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarPG Herveou <pgherveou@gmail.com>
    • Tomás Senovilla Polo's avatar
      refactor: Move `T:Config` into where clause in `#[benchmarks]` macro if needed (#7418) · 4b2ca118
      Tomás Senovilla Polo authored
      # Description
      
      Currently, the `#[benchmarks]` macro always add `<T:Config>` to the
      expanded code even if a where clause is used. Using a where clause which
      also includes a trait bound for the generic `T` is triggering [this
      clippy
      warning](https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations)
      from Rust 1.78 onwards. We've found that
      [here](https://github.com/freeverseio/laos/blob/main/pallets/precompiles-benchmark/src/precompiles/vesting/benchmarking.rs#L126-L132)
      in LAOS, as we need to include `T: pallet_vesting::Config` in the where
      clause, here's the outcome:
      
      ```rust
      error: bound is defined in more than one place
         --> pallets/precompiles-benchmark/src/precompiles/vesting/benchmarking.rs:130:1
          |
      130 | / #[benchmarks(
      131 | |     where
      132 | |         T: Config + pallet_vesting::Config,
          | |         ^
      133 | |         T::AccountIdToH160: ConvertBack<T::AccountId, H160>,
      134 | |         BalanceOf<T>: Into<U256>,
      135 | |         BlockNumberFor<T>: Into<U256>
      136 | | )]
          | |__^
          |
          = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
          = note: `-D clippy::multiple-bound-locations` implied by `-D warnings`
          = help: to override `-D warnings` add `#[allow(clippy::multiple_bound_locations)]`
          = note: this error originates in the attribute macro `benchmarks` (in Nightly builds, run with -Z macro-backtrace for more info)
      ```
      
      While this is a harmless warning, only thrown due to a trait bound for T
      is being defined twice in an expanded code that nobody will see, and
      while annotating the benchmarks module with
      `#[allow(clippy::multiple_bound_locations)]` is enough to get rid of it,
      it might cause unnecessary concerns.
      
      Hence, I think it's worth slightly modifying the macro to avoid this.
      
      ## Review Notes
      
      What I propose is to include `<T: Config>` (or its instance version) in
      the expanded code only if no where clause was specified, and include
      that trait bound in the where clause if one is present.
      
      I considered always creating a where clause which includes `<T: Config>`
      even if the macro doesn't specify a where clause and totally getting rid
      of `<T: Config>`, but discarded the idea for simplicity.
      
      I also considered checking if `T:Config` is present in the provided
      where clause (as it's the case in the LAOS example I provided) before
      adding it, but discarded the idea as well due to it implies a bit more
      computation and having `T:Config` defined twice in the where clause is
      harmless: the compiler will ignore the second occurrence and nobody will
      see it's there.
      
      If you think this change is worth it and one of the discarded ideas
      would be a better approach, I'm happy to push that code instead.
    • Bastian Köcher's avatar
    • Alexander Theißen's avatar
      pallet-revive: Add env var to allow skipping of validation for testing (#7562) · b44dc3a5
      Alexander Theißen authored
      
      When trying to reproduce bugs we sometimes need to deploy code that
      wouldn't pass validation. This PR adds a new environment variable
      `REVIVE_SKIP_VALIDATION` that when set will skip all validation except
      the contract blob size limit.
      
      Please note that this only applies to when the pallet is compiled for
      `std` and hence will never be part of on-chain.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Oliver Tale-Yazdi's avatar
      [mq pallet] Custom next queue selectors (#6059) · 7aac8861
      Oliver Tale-Yazdi authored
      
      Changes:
      - Expose a `force_set_head` function from the `MessageQueue` pallet via
      a new trait: `ForceSetHead`. This can be used to force the MQ pallet to
      process this queue next.
      - The change only exposes an internal function through a trait, no audit
      is required.
      
      ## Context
      
      For the Asset Hub Migration (AHM) we need a mechanism to prioritize the
      inbound upward messages and the inbound downward messages on the AH. To
      achieve this, a minimal (and no breaking) change is done to the MQ
      pallet in the form of adding the `force_set_head` function.
      
      An example use of how to achieve prioritization is then demonstrated in
      `integration_test.rs::AhmPrioritizer`. Normally, all queues are
      scheduled round-robin like this:
      
      `| Relay | Para(1) | Para(2) | ... | Relay | ... `
      
      The prioritizer listens to changes to its queue and triggers if either:
      - The queue processed in the last block (to keep the general round-robin
      scheduling)
      - The queue did not process since `n` blocks (to prevent starvation if
      there are too many other queues)
      
      In either situation, it schedules the queue for a streak of three
      consecutive blocks, such that it would become:
      
      `| Relay | Relay | Relay | Para(1) | Para(2) | ... | Relay | Relay |
      Relay | ... `
      
      It basically transforms the round-robin into an elongated round robin.
      Although different strategies can be injected into the pallet at
      runtime, this one seems to strike a good balance between general service
      level and prioritization.
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarmuharem <ismailov.m.h@gmail.com>
  4. Feb 13, 2025
    • PG Herveou's avatar
      [pallet-revive] fix subxt version (#7570) · d1140047
      PG Herveou authored
      
      Cargo.lock change to subxt were rolled back 
      Fixing it and updating it in Cargo.toml so it does not happen again
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • s0me0ne-unkn0wn's avatar
      Shorter availability data retention period for testnets (#7353) · 1866c3b4
      s0me0ne-unkn0wn authored
      Closes #3270
      
      ---------
      
      Co-authored-by: command-bot <>
    • Bastian Köcher's avatar
      sc-informant: Print full hash when debug logging is enabled (#7554) · 9d14b3b5
      Bastian Köcher authored
      
      When debugging stuff, it is useful to see the full hashes and not only
      the "short form". This makes it easier to read logs and follow blocks.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Michal Kucharczyk's avatar
      `fatxpool`: transaction statuses metrics added (#7505) · e5df3306
      Michal Kucharczyk authored
      #### Overview
      
      This PR introduces a new mechanism to capture and report metrics related
      to timings of transaction lifecycle events, which are currently not
      available. By exposing these timings, we aim to augment transaction-pool
      reliability dashboards and extend existing Grafana boards.
      
      A new `unknown_from_block_import_txs` metric is also introduced. It
      provides the number of transactions in imported block which are not
      known to the node's transaction pool. It allows to monitor alignment of
      transaction pools across the nodes in the network.
      
      #### Notes for reviewers
      - **[Per-event
      Metrics](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L84-L105)
      Collection**: implemented by[
      `EventsMetricsCollector`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L353-L358)
      which allows to capture both submission timestamps and transaction
      status updates. An asynchronous
      [`EventsMetricsCollectorTask`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L503-L526)
      processes the metrics-related messages sent by the
      `EventsMetricsCollector` and reports the timings of transaction statuses
      updates to Prometheus. This task implements event[
      de-duplication](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L458)
      using a `HashMap` of
      [`TransactionEventMetricsData`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L424-L435)
      entries which also holds transaction submission timestamps used to
      [compute
      timings](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L489-L495).
      Transaction-related items are removed when transaction's final status is
      [reported](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L496).
      - Transaction submission timestamp is reusing the timestamp of
      `TimedTransactionSource` kept in mempool. It is reported to
      `EventsMetricsCollector` in
      [`submit_at`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L735)
      and
      [`submit_and_watch`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L836)
      methods of `ForkAwareTxPool`.
      - Transaction updates are reported to `EventsMetricsCollector` from
      `MultiViewListener`
      [task](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs#L494).
      This allows to gather metrics for _watched_ and _non-watched_
      transactions (what enables metrics on non-rpc-enabled collators).
      - New metric
      ([`unknown_from_block_import_txs`](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/metrics.rs#L59-L60))
      allowing checking alignment of pools across the network is
      [reported](https://github.com/paritytech/polkadot-sdk/blob/8a53992e/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L1288-L1292)
      using new `TxMemPool`
      [method](https://github.com/paritytech/polkadot-sdk/blob/8a53992e
      
      /substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs#L605-L611).
      
      fixes: #7355, #7448
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
      Co-authored-by: default avatarIulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
    • seemantaggarwal's avatar
      Update Scheduler to have a configurable block provider #7434 (#7441) · 645a6f40
      seemantaggarwal authored
      
      Follow up from
      https://github.com/paritytech/polkadot-sdk/pull/6362#issuecomment-2629744365
      
      The goal of this PR is to have the scheduler pallet work on a parachain
      which does not produce blocks on a regular schedule, thus can use the
      relay chain as a block provider.
      
      Because blocks are not produced regularly, we cannot make the assumption
      that block number increases monotonically, and thus have new logic to
      handle multiple spend periods passing between blocks.
      
      Requirement: 
      
      instead of using the hard coded system block number. We add an
      associated type BlockNumberProvider
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  5. Feb 12, 2025
  6. Feb 10, 2025
  7. Feb 09, 2025
    • StackOverflowExcept1on's avatar
      feat(wasm-builder): add support for new `wasm32v1-none` target (#7008) · 2970ab15
      StackOverflowExcept1on authored
      
      # Description
      
      Resolves #5777
      
      Previously `wasm-builder` used hacks such as `-Zbuild-std` (required
      `rust-src` component) and `RUSTC_BOOTSTRAP=1` to build WASM runtime
      without WASM features: `sign-ext`, `multivalue` and `reference-types`,
      but since Rust 1.84 (will be stable on 9 January, 2025) the situation
      has improved as there is new
      [`wasm32v1-none`](https://doc.rust-lang.org/beta/rustc/platform-support/wasm32v1-none.html)
      target that disables all "post-MVP" WASM features except
      `mutable-globals`.
      
      Previously, your `rust-toolchain.toml` looked like this:
      
      ```toml
      [toolchain]
      channel = "stable"
      components = ["rust-src"]
      targets = ["wasm32-unknown-unknown"]
      profile = "default"
      ```
      
      It should now be updated to something like this:
      
      ```toml
      [toolchain]
      channel = "stable"
      targets = ["wasm32v1-none"]
      profile = "default"
      ```
      
      To build the runtime:
      
      ```bash
      cargo build --package minimal-template-runtime --release
      ```
      
      ## Integration
      
      If you are using Rust 1.84 and above, then install the `wasm32v1-none`
      target instead of `wasm32-unknown-unknown` as shown above. You can also
      remove the unnecessary `rust-src` component.
      
      Also note the slight differences in conditional compilation:
      - `wasm32-unknown-unknown`: `#[cfg(all(target_family = "wasm", target_os
      = "unknown"))]`
      - `wasm32v1-none`: `#[cfg(all(target_family = "wasm", target_os =
      "none"))]`
      
      Avoid using `target_os = "unknown"` in `#[cfg(...)]` or
      `#[cfg_attr(...)]` and instead use `target_family = "wasm"` or
      `target_arch = "wasm32"` in the runtime code.
      
      ## Review Notes
      
      Wasm builder requires the following prerequisites for building the WASM
      binary:
      - Rust >= 1.68 and Rust < 1.84:
        - `wasm32-unknown-unknown` target
        - `rust-src` component
      - Rust >= 1.84:
        - `wasm32v1-none` target
      - no more `-Zbuild-std` and `RUSTC_BOOTSTRAP=1` hacks and `rust-src`
      component requirements!
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: default avatarBastian Köcher <info@kchr.de>
  8. Feb 08, 2025
  9. Feb 07, 2025