Skip to content
Snippets Groups Projects
  1. Feb 18, 2025
  2. Feb 17, 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>
    • 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 12, 2025
  5. Feb 03, 2025
    • Alin Dima's avatar
      deprecate AsyncBackingParams (#7254) · 4cd07c56
      Alin Dima authored
      
      Part of https://github.com/paritytech/polkadot-sdk/issues/5079.
      
      Removes all usage of the static async backing params, replacing them
      with dynamically computed equivalent values (based on the claim queue
      and scheduling lookahead).
      
      Adds a new runtime API for querying the scheduling lookahead value. If
      not present, falls back to 3 (the default value that is backwards
      compatible with values we have on production networks for
      allowed_ancestry_len)
      
      Also resolves most of
      https://github.com/paritytech/polkadot-sdk/issues/4447, removing code
      that handles async backing not yet being enabled.
      While doing this, I removed the support for collation protocol version 1
      on collators, as it only worked for leaves not supporting async backing
      (which are none).
      I also unhooked the legacy v1 statement-distribution (for the same
      reason as above). That subsystem is basically dead code now, so I had to
      remove some of its tests as they would no longer pass (since the
      subsystem no longer sends messages to the legacy variant). I did not
      remove the entire legacy subsystem yet, as that would pollute this PR
      too much. We can remove the entire v1 and v2 validation protocols in a
      follow up PR.
      
      In another PR: remove test files with names `prospective_parachains`
      (it'd pollute this PR if we do now)
      
      TODO:
      - [x] add deprecation warnings
      - [x] prdoc
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  6. Jan 30, 2025
    • ordian's avatar
      fix pre-dispatch PoV underweight for ParasInherent (#7378) · 0d35be7b
      ordian authored
      
      This should fix the error log related to PoV pre-dispatch weight being
      lower than post-dispatch for `ParasInherent`:
      ```
      ERROR tokio-runtime-worker runtime::frame-support: Post dispatch weight is greater than pre dispatch weight. Pre dispatch weight may underestimating the actual weight. Greater post dispatch weight components are ignored.
                                              Pre dispatch weight: Weight { ref_time: 47793353978, proof_size: 1019 },
                                              Post dispatch weight: Weight { ref_time: 5030321719, proof_size: 135395 }
      ```
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  7. Jan 26, 2025
  8. Jan 23, 2025
    • Andrei Sandu's avatar
      Deprecate ParaBackingState API (#6867) · e9393a9a
      Andrei Sandu authored
      
      Currently the `para_backing_state` API is used only by the prospective
      parachains subsystems and returns 2 things: the constraints for
      parachain blocks and the candidates pending availability.
      
      This PR deprecates `para_backing_state` and introduces a new
      `backing_constraints` API that can be used together with
      `candidates_pending_availability` to get the same information provided
      by `para_backing_state`.
      
      TODO:
      - [x] PRDoc
      
      ---------
      
      Signed-off-by: default avatarAndrei Sandu <andrei-mihail@parity.io>
      Co-authored-by: command-bot <>
  9. Dec 29, 2024
  10. Dec 20, 2024
    • Xavier Lau's avatar
      Reorder dependencies' keys (#6967) · a843d15e
      Xavier Lau authored
      
      It doesn't make sense to only reorder the features array.
      
      For example:
      
      This makes it hard for me to compare the dependencies and features,
      especially some crates have a really really long dependencies list.
      ```toml​
      [dependencies]
      c = "*"
      a = "*"
      b = "*"
      
      [features]
      std = [
        "a",
        "b",
        "c",
      ]
      ```
      
      This makes my life easier.
      ```toml​
      [dependencies]
      a = "*"
      b = "*"
      c = "*"
      
      [features]
      std = [
        "a",
        "b",
        "c",
      ]
      ```
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: command-bot <>
  11. Dec 19, 2024
  12. Dec 12, 2024
  13. Dec 05, 2024
    • Francisco Aguirre's avatar
      Added fallback_max_weight to Transact for sending messages to V4 chains (#6643) · f31c70aa
      Francisco Aguirre authored
      
      Closes: https://github.com/paritytech/polkadot-sdk/issues/6585
      
      Removing the `require_weight_at_most` parameter in V5 Transact had only
      one problem. Converting a message from V5 to V4 to send to chains that
      didn't upgrade yet. The conversion would not know what weight to give to
      the Transact, since V4 and below require it.
      
      To fix this, I added back the weight in the form of an `Option<Weight>`
      called `fallback_max_weight`. This can be set to `None` if you don't
      intend to deal with a chain that hasn't upgraded yet. If you set it to
      `Some(_)`, the behaviour is the same. The plan is to totally remove this
      in V6 since there will be a good conversion path from V6 to V5.
      
      ---------
      
      Co-authored-by: default avatarGitHub Action <action@github.com>
      Co-authored-by: default avatarAdrian Catangiu <adrian@parity.io>
  14. Dec 03, 2024
  15. Nov 06, 2024
  16. Nov 05, 2024
  17. Nov 04, 2024
    • Alin Dima's avatar
      fix claim queue size (#6257) · f4133b08
      Alin Dima authored
      Reported in
      https://github.com/paritytech/polkadot-sdk/issues/6161#issuecomment-2432097120
      
      Fixes a bug introduced in
      https://github.com/paritytech/polkadot-sdk/pull/5461, where the claim
      queue would contain entries even if the validator groups storage is
      empty (which happens during the first session).
      
      This PR sets the claim queue core count to be the minimum between the
      num_cores param and the number of validator groups
      
      TODO:
      - [x] prdoc
      - [x] unit test
  18. Oct 28, 2024
    • Alin Dima's avatar
      remove parachains_assigner code (#6171) · 85901220
      Alin Dima authored
      Resolves https://github.com/paritytech/polkadot-sdk/issues/5970
      
      Removes the code of the legacy parachains assigner, which was used prior
      to coretime. Now that all networks are upgraded to use the coretime
      assigner, we can remove it.
  19. Oct 25, 2024
  20. Oct 21, 2024
    • Alin Dima's avatar
      runtime: remove ttl (#5461) · ee803b74
      Alin Dima authored
      
      Resolves https://github.com/paritytech/polkadot-sdk/issues/4776
      
      This will enable proper core-sharing between paras, even if one of them
      is not producing blocks.
      
      TODO:
      - [x] duplicate first entry in the claim queue if the queue used to be
      empty
      - [x] don't back anything if at the end of the block there'll be a
      session change
      - [x] write migration for removing the availability core storage
      - [x] update and write unit tests
      - [x] prdoc
      - [x] add zombienet test for synchronous backing
      - [x] add zombienet test for core-sharing paras where one of them is not
      producing any blocks
      
      _Important note:_
      The `ttl` and `max_availability_timeouts` fields of the
      HostConfiguration are not removed in this PR, due to #64.
      Adding the workaround with the storage version check for every use of
      the active HostConfiguration in all runtime APIs would be insane, as
      it's used in almost all runtime APIs.
      
      So even though the ttl and max_availability_timeouts fields will now be
      unused, they will remain part of the host configuration.
      
      These will be removed in a separate PR once #64 is fixed. Tracked by
      https://github.com/paritytech/polkadot-sdk/issues/6067
      
      ---------
      
      Signed-off-by: default avatarAndrei Sandu <andrei-mihail@parity.io>
      Co-authored-by: default avatarAndrei Sandu <andrei-mihail@parity.io>
      Co-authored-by: default avatarAndrei Sandu <54316454+sandreim@users.noreply.github.com>
      Co-authored-by: command-bot <>
  21. Oct 18, 2024
    • georgepisaltu's avatar
      FRAME: Reintroduce `TransactionExtension` as a replacement for `SignedExtension` (#3685) · b76e91ac
      georgepisaltu authored
      Original PR https://github.com/paritytech/polkadot-sdk/pull/2280
      reverted in https://github.com/paritytech/polkadot-sdk/pull/3665
      
      This PR reintroduces the reverted functionality with additional changes,
      related effort
      [here](https://github.com/paritytech/polkadot-sdk/pull/3623).
      Description is copied over from the original PR
      
      First part of [Extrinsic
      Horizon](https://github.com/paritytech/polkadot-sdk/issues/2415)
      
      Introduces a new trait `TransactionExtension` to replace
      `SignedExtension`. Introduce the idea of transactions which obey the
      runtime's extensions and have according Extension data (né Extra data)
      yet do not have hard-coded signatures.
      
      Deprecate the terminology of "Unsigned" when used for
      transactions/extrinsics owing to there now being "proper" unsigned
      transactions which obey the extension framework and "old-style" unsigned
      which do not. Instead we have __*General*__ for the former and
      __*Bare*__ for ...
  22. Oct 07, 2024
    • Andrei Sandu's avatar
      Elastic scaling: runtime v2 descriptor support (#5423) · 4b356c4b
      Andrei Sandu authored
      
      Closes https://github.com/paritytech/polkadot-sdk/issues/5045 and
      https://github.com/paritytech/polkadot-sdk/issues/5046
      
      <del>On top of
      https://github.com/paritytech/polkadot-sdk/pull/5362</del>
      
      TODO:
      - [x] storage migration for allowed relay parents tracker 
      - [x] check session index
      - [x] PRdoc
      - [x] tests
      - [x] ensure UMP queue cannot be abused with this change
      - [x] Zombienet runtime upgrade test
      
      ---------
      
      Signed-off-by: default avatarAndrei Sandu <andrei-mihail@parity.io>
  23. Oct 02, 2024
    • s0me0ne-unkn0wn's avatar
      Do not enforce PoV size hard limit in config (#5887) · 087ea035
      s0me0ne-unkn0wn authored
      Quoting @bkchr (from
      [here](https://github.com/paritytech/polkadot-sdk/issues/5334#issuecomment-2383815078)):
      
      > That the hardcoded limit is used there again, is IMO not correct. The
      `max_pov_size` should be controlled by the `HostConfiguration` and not
      limited by some "random" constant.
      
      This PR aims to change the hard limit to a not-so-random constant,
      allowing more room for maneuvering in the future.
  24. Sep 26, 2024
  25. Sep 16, 2024
  26. Sep 04, 2024
    • ordian's avatar
      try making bench numbers make sense (#5526) · de0b6f25
      ordian authored
      Follow-up to #5270. The baseline numbers for Westend were too high to be
      representative of the reality as it seemed to do with how multi-variate
      linear regression is calculated.
      
      ---------
      
      Co-authored-by: command-bot <>
  27. Sep 02, 2024
    • Andrei Sandu's avatar
      Elastic scaling: introduce new candidate receipt primitive (#5322) · ad2ac0db
      Andrei Sandu authored
      
      closes https://github.com/paritytech/polkadot-sdk/issues/5044
      
      This PR switches the runtime to the new receipts format (vstaging
      primitives). I've implemented `From` to convert from new primitives to
      `v7` primitives and used them in the node runtime api client
      implementation. Until we implement the support in the node, it will
      continue e to use the v7 primitives but the runtime apis already use the
      new primitives.
      
      
      An expected downside of RFC103 is decoding V2 receipts shows garbage
      values if the input is V1:
      
      _![ima_9ce77de](https://github.com/user-attachments/assets/71d80e78-e238-4518-8cd1-548ae0d74b70)_
      
      TODO:
      - [x] fix tests
      - [x] A few more tests for the new primitives
      - [x] PRDoc
      
      ---------
      
      Signed-off-by: default avatarAndrei Sandu <andrei-mihail@parity.io>
  28. Aug 30, 2024
    • zjb0807's avatar
      Add more logs for AcceptanceCheckErr (#5513) · 9cdf3d99
      zjb0807 authored
      # Description
      
      The error message should be logged out when the check method returns an
      error.
      
      Because specific information is lost when `UmpAcceptanceCheckErr`,
      `ProcessedDownwardMessagesAcceptanceErr`, `HrmpWatermarkAcceptanceErr`,
      `OutboundHrmpAcceptanceErr` are converted to `AcceptanceCheckErr`, a log
      is added to each check.
      
      ## Integration
      
      ## Review Notes
      
      # Checklist
      
      * [ ] My PR includes a detailed description as outlined in the
      "Description" and its two subsections above.
      * [ ] My PR follows the [labeling requirements](
      
      https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process
      ) of this project (at minimum one label for `T` required)
      * External contributors: ask maintainers to put the right label on your
      PR.
      * [ ] 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)
    • Andrei Sandu's avatar
      Polkadot Primitives v8 (#5525) · 09035a7d
      Andrei Sandu authored
      
      As Runtime release 1.3.0 includes all of the remaining staging
      primitives and APIs we can now release primitives version 8.
      No other changes other than renaming/moving done here.
      
      ---------
      
      Signed-off-by: default avatarAndrei Sandu <andrei-mihail@parity.io>
  29. Aug 29, 2024
    • ordian's avatar
      inclusion: bench `enact_candidate` weight (#5270) · ddd58c15
      ordian authored
      On top of #5082.
      
      ## Background
      
      Previously, before #3479, we would
      [include](https://github.com/paritytech/polkadot-sdk/blame/75074952/polkadot/runtime/parachains/src/builder.rs#L508C12-L508C44)
      the cost enacting the candidate into the cost of processing a single
      bitfield.
      [Now](https://github.com/paritytech/polkadot-sdk/blame/dd48544a/polkadot/runtime/parachains/src/builder.rs#L529)
      it is different, although the benchmarks seems to be not-up-to date.
      Including the cost of enacting a candidate into a processing a single
      bitfield cost was incorrect, since we multiple that by the number of
      bitfields we have. Instead, we should separate calculate the cost of
      processing a single bitfield without enactment, and multiple the cost of
      enactment by the actual number of processed candidates (which is limited
      by the number cores, not validators).
      
      ## Bench
      
      Previously, the weight of `enact_candidate` was calculated manually
      (without a benchmark) and then neglected:
      https://github.com/paritytech/polkadot-sdk/blob/dd48544a
      
      /polkadot/runtime/parachains/src/inclusion/mod.rs#L584
      
      In this PR, we have a benchmark for it and it's based on the number of
      ump and sent hrmp messages as well as whether the candidate has a
      runtime upgrade (new_validation_code).
      The differences from the previous attempt
      https://github.com/paritytech/polkadot/pull/6929 are that
      * we don't include the cost of enactment into the cost of processing a
      backed candidate.
      The reason for it is that enactment happens not in the same block as
      backing (typically the next one), since we process bitfields before
      backing votes.
      * we don't take into account the size of the runtime upgrade, the
      benchmark weight doesn't seem to depend much on it, but rather whether
      there was one or not.
      
      Similarly to the previous attempt, we don't account for dmp messages
      (fixed cost). Also we don't account properly for received hrmp messages
      (hrmp_watermark) because the cost of it depends on the runtime state and
      can't be statically deduced in the benchmark (unless we pass the
      information about channels as benchmark u32 arguments).
      
      The total weight cost of processing a parainherent now includes the cost
      of enactment of each candidate, but we don't do filtering based on that
      (because we enact after processing bitfields and making other changes to
      the storage).
      
      ## Numbers
      
      ```
      Reads = 7 + (0 * u) + (3 * h) + (8 * c)
      Writes = 10 + (1 * u) + (3 * h) + (7 * c)
      ```
      In addition, there is a fixed cost of a few of ms (!) per candidate. 
      
      This might result a full block slightly overflowing its weight with 200
      enacted candidates, which in turn could prevent non-mandatory
      transactions from being included in a block.
      
      Given our modest limits on max ump and hrmp messages:
      ```
        maxUpwardMessageNumPerCandidate: 16
        hrmpMaxMessageNumPerCandidate: 10
      ```
      and the fact that runtime upgrades are can't happen very frequently
      (`validation_upgrade_cooldown`), we might only go over the limits in
      case of many disputes.
      
      TODOs:
      - [x] Fix the overweight test
      - [x] Generate the weights for Westend and Rococo
      - [x] PRDoc
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarAlin Dima <alin@parity.io>
    • ordian's avatar
      short-term fix for para inherent weight overestimation (#5082) · cc7ebe05
      ordian authored
      closes #849
      
      ## Context
      
      For the background on this and the long-term fix, see
      https://github.com/paritytech/polkadot-sdk/issues/849#issuecomment-2247895862.
      
      ## Changes
      
      * The weigh files are renamed from `runtime_(parachains|common).*` to
      `polkadot_runtime_(parachains|common).*`. The reason for it is the
      renaming introduced in #4633. The new weight command and files are
      generated now include `polkadot_` prefix.
      * The WeightInfo for `paras_inherent` now includes `enter_empty` which
      calculates the cost of processing an empty parachains inherent. This
      cost is subtracted dynamically when calculating other weights (so the
      other weights remain the same)
      
      ## Benefits
      
      See
      https://github.com/paritytech/polkadot-sdk/issues/849#issuecomment-2247895862,
      but TL;DR is that we are not blocked on weights for scaling the number
      of validators and cores further.
      
      Resolved questions:
      - [x] why new benchmarks for westend are doing fewer db IOPS?
      Is it due polkadot-sdk update (db IOPS diff)?
      or the bench setup is no longer valid?
      
      https://github.com/polkadot-fellows/runtimes/blob/7723274a2c5cbb10213379271094d5180716ca7d/relay/polkadot/src/weights/runtime_parachains_paras_inherent.rs#L131-L196
      Answer: see background section of #5270 
      
      TODOs:
      - [x] Rerun benchmarks for Rococo and Westend
      - [x] PRDoc
      
      ---------
      
      Co-authored-by: command-bot <>
  30. Aug 27, 2024