Skip to content
Snippets Groups Projects
  1. Mar 11, 2025
    • Sebastian Kunert's avatar
      slot-based-collator: Allow multiple blocks per slot (#7569) · 8ddb0714
      Sebastian Kunert authored
      **Summary:** This PR enables authoring of multiple blocks in one AURA
      slot in the slot-based collator and stabilizes the slot-based collator.
      
      ## CLI Changes
      The flag `--experimental-use-slot-based` is now marked as deprecated. I
      opted to introduce `--authoring slot-based` instead of just removing the
      `experimental` prefix. By introducing the `authoring` variant, we get
      some future-proofing in case we want to introduce further options.
      
      ## Change Description
      With elastic-scaling, we are able to author multiple blocks with a
      single relay-chain parent. In the initial iteration, the interval
      between two blocks was determined by the `slot_duration` of the
      parachain. This PR introduces a more flexible model, where we try to
      author multiple blocks in a single slot if the runtime allows it.
      
      The block authoring loop is largely the same. The
      [`SlotTimer`](https://github.com/paritytech/polkadot-sdk/blob/f1935bd9/cumulus/client/consensus/aura/src/collators/slot_based/slot_timer.rs#L48-L48)
      now lives in a separate module and is updated with the last seen [core
      count](https://github.com/paritytech/polkadot-sdk/blob/f1935bd9
      
      /cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs#L231-L231).
      It will then trigger rounds in the block-building loop based on the core
      count.
      
      This allows some flexibility where elastic-scaling chains can run on a
      single core in quiet times. Previously, running on 1 core with a 3-core
      elastic-scaling chain would result in authors getting skipped because
      the `slot_duration` was too low.
      
      ## Parameter Considerations
      The core logic does not change, so there are a few things to consider:
      - The `ConsensusHook` implementation still determines how many blocks
      are allowed per relay-chain block. So if you add arbitrary cores to an
      async-backing, 6-second parachain, `can_build_upon` in the runtime will
      deny block-building of additional blocks.
      - The `MINIMUM_PERIOD` in the runtime needs to be configured to allow
      enough blocks in the slot. A "classic" configuration of
      `SLOT_DURATION/2` will lead to slot mismatches when running with 3
      cores.
      - We fetch available cores at least once every relay chain block. So if
      a parachain runs with a 12-second slot duration and 1 fixed core, we
      would still author 2 blocks if the parachain runtime allows it.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarMichal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
      Co-authored-by: default avatarJavier Viola <javier@parity.io>
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      8ddb0714
  2. Mar 05, 2025
    • Oliver Tale-Yazdi's avatar
      pallet revive: rpc build script should not panic (#7786) · 9100d249
      Oliver Tale-Yazdi authored
      
      This can error when you use `cargo remote` and probably also with `cargo
      vendor`.
      Still seeing two more build errors, but at least this one is fixed.
      
      Other one:
      ```pre
      error: set `DATABASE_URL` to use query macros online, or run `cargo sqlx prepare` to update the query cache
         --> substrate/frame/revive/rpc/src/receipt_provider/db.rs:123:17
          |
      123 |               let result = query!(
          |  __________________________^
      124 | |                 r#"
      125 | |                 INSERT OR REPLACE INTO transaction_hashes (transaction_hash, block_hash, transaction_index)
      126 | |                 VALUES ($1, $2, $3)
      ...   |
      130 | |                 transaction_index
      131 | |             )
      ```
      
      and (maybe Rust version related, this is 1.84.1)
      ```pre
      error[E0282]: type annotations needed
         --> substrate/frame/revive/rpc/src/receipt_provider/db.rs:102:34
          |
      102 |         let (tx_result, logs_result) = tokio::join!(delete_transaction_hashes, delete_logs);
          |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
          |
          = note: this error originates in the macro `$crate::join` which comes from the expansion of the macro `tokio::join` (in Nightly builds, run with -Z macro-backtrace for more info)
      ```
      
      ---------
      
      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 avatarBastian Köcher <git@kchr.de>
      9100d249
  3. Feb 28, 2025
    • Serban Iorga's avatar
      Derive `DecodeWithMemTracking` for `Block` (#7655) · c11b1f85
      Serban Iorga authored
      Related to https://github.com/paritytech/polkadot-sdk/issues/7360
      
      This PR adds `DecodeWithMemTracking` as a trait bound for `Header`,
      `Block` and `TransactionExtension` and
      derives it for all the types that implement these traits in
      `polkadot-sdk`.
      c11b1f85
  4. Feb 20, 2025
    • Alexander Theißen's avatar
      Update to Rust stable 1.84.1 (#7625) · e2d3da61
      Alexander Theißen authored
      
      Ref https://github.com/paritytech/ci_cd/issues/1107
      
      We mainly need that so that we can finally compile the `pallet_revive`
      fixtures on stable. I did my best to keep the commits focused on one
      thing to make review easier.
      
      All the changes are needed because rustc introduced more warnings or is
      more strict about existing ones. Most of the stuff could just be fixed
      and the commits should be pretty self explanatory. However, there are a
      few this that are notable:
      
      ## `non_local_definitions `
      
      A lot of runtimes to write `impl` blocks inside functions. This makes
      sense to reduce the amount of conditional compilation. I guess I could
      have moved them into a module instead. But I think allowing it here
      makes sense to avoid the code churn.
      
      ## `unexpected_cfgs`
      
      The FRAME macros emit code that references various features like `std`,
      `runtime-benchmarks` or `try-runtime`. If a create that uses those
      macros does not have those features we get this warning. Those were
      mostly when defining a `mock` runtime. I opted for silencing the warning
      in this case rather than adding not needed features.
      
      For the benchmarking ui tests I opted for adding the `runtime-benchmark`
      feature to the `Cargo.toml`.
      
      ## Failing UI test
      
      I am bumping the `trybuild` version and regenerating the ui tests. The
      old version seems to be incompatible. This requires us to pass
      `deny_warnings` in `CARGO_ENCODED_RUSTFLAGS` as `RUSTFLAGS` is ignored
      in the new version.
      
      ## Removing toolchain file from the pallet revive fixtures
      
      This is no longer needed since the latest stable will compile them fine
      using the `RUSTC_BOOTSTRAP=1`.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      e2d3da61
  5. Feb 19, 2025
    • Serban Iorga's avatar
      Derive `DecodeWithMemTracking` for cumulus pallets and for `polkadot-sdk` runtimes (#7627) · d60afc9f
      Serban Iorga authored
      Related to https://github.com/paritytech/polkadot-sdk/issues/7360
      
      Derive `DecodeWithMemTracking` for the structures in the cumulus pallets
      and for the structures in the `polkadot-sdk` runtimes.
      
      The PR contains no functional changes and no manual implementation. Just
      deriving `DecodeWithMemTracking`.
      d60afc9f
    • castillax's avatar
      Add note for organization contributors about creating branches directly (#7611) · a48b3894
      castillax authored
      # Description
      
      * This PR adds a note to the CONTRIBUTING.md file to inform contributors
      who are part of the organization that they do not need to fork the
      repository. Instead, they can create a branch directly in the repository
      to send a pull request.
      
      ## Changes
      
      Added a note under the "What?" section in CONTRIBUTING.md to clarify
      that organization contributors can create branches directly in the
      repository.
      a48b3894
  6. Feb 18, 2025
  7. Feb 12, 2025
  8. Feb 10, 2025
  9. Jan 28, 2025
    • Andrew Jones's avatar
      Implement pallet view function queries (#4722) · 0b8d7441
      Andrew Jones authored
      
      Closes #216.
      
      This PR allows pallets to define a `view_functions` impl like so:
      
      ```rust
      #[pallet::view_functions]
      impl<T: Config> Pallet<T>
      where
      	T::AccountId: From<SomeType1> + SomeAssociation1,
      {
      	/// Query value no args.
      	pub fn get_value() -> Option<u32> {
      		SomeValue::<T>::get()
      	}
      
      	/// Query value with args.
      	pub fn get_value_with_arg(key: u32) -> Option<u32> {
      		SomeMap::<T>::get(key)
      	}
      }
      ```
      ### `QueryId`
      
      Each view function is uniquely identified by a `QueryId`, which for this
      implementation is generated by:
      
      ```twox_128(pallet_name) ++ twox_128("fn_name(fnarg_types) -> return_ty")```
      
      The prefix `twox_128(pallet_name)` is the same as the storage prefix for pallets and take into account multiple instances of the same pallet.
      
      The suffix is generated from the fn type signature so is guaranteed to be unique for that pallet impl. For one of the view fns in the example above it would be `twox_128("get_value_with_arg(u32) -> Option<u32>")`. It is a known limitation that only the type names themselves are taken into account: in the case of type aliases the signature may have the same underlying types but a different id; for generics the concrete types may be different but the signatures will remain the same.
      
      The existing Runtime `Call` dispatchables are addressed by their concatenated indices `pallet_index ++ call_index`, and the dispatching is handled by the SCALE decoding of the `RuntimeCallEnum::PalletVariant(PalletCallEnum::dispatchable_variant(payload))`. For `view_functions` the runtime/pallet generated enum structure is replaced by implementing the `DispatchQuery` trait on the outer (runtime) scope, dispatching to a pallet based on the id prefix, and the inner (pallet) scope dispatching to the specific function based on the id suffix.
      
      Future implementations could also modify/extend this scheme and routing to pallet agnostic queries.
      
      ### Executing externally
      
      These view functions can be executed externally via the system runtime api:
      
      ```rust
      pub trait ViewFunctionsApi<QueryId, Query, QueryResult, Error> where
      	QueryId: codec::Codec,
      	Query: codec::Codec,
      	QueryResult: codec::Codec,
      	Error: codec::Codec,
      {
      	/// Execute a view function query.
      fn execute_query(query_id: QueryId, query: Query) -> Result<QueryResult,
      Error>;
      }
      ```
      ### `XCQ`
      Currently there is work going on by @xlc to implement [`XCQ`](https://github.com/open-web3-stack/XCQ/) which may eventually supersede this work.
      
      It may be that we still need the fixed function local query dispatching in addition to XCQ, in the same way that we have chain specific runtime dispatchables and XCM.
      
      I have kept this in mind and the high level query API is agnostic to the underlying query dispatch and execution. I am just providing the implementation for the `view_function` definition.
      
      ### Metadata
      Currently I am utilizing the `custom` section of the frame metadata, to avoid modifying the official metadata format until this is standardized.
      
      ### vs `runtime_api`
      There are similarities with `runtime_apis`, some differences being:
      - queries can be defined directly on pallets, so no need for boilerplate declarations and implementations
      - no versioning, the `QueryId` will change if the signature changes. 
      - possibility for queries to be executed from smart contracts (see below)
      
      ### Calling from contracts
      Future work would be to add `weight` annotations to the view function queries, and a host function to `pallet_contracts` to allow executing these queries from contracts.
      
      ### TODO
      
      - [x] Consistent naming (view functions pallet impl, queries, high level api?)
      - [ ] End to end tests via `runtime_api`
      - [ ] UI tests
      - [x] Mertadata tests
      - [ ] Docs
      
      ---------
      
      Co-authored-by: default avatarkianenigma <kian@parity.io>
      Co-authored-by: default avatarJames Wilson <james@jsdw.me>
      Co-authored-by: default avatarGiuseppe Re <giuseppe.re@parity.io>
      Co-authored-by: default avatarGuillaume Thiolliere <guillaume.thiolliere@parity.io>
      0b8d7441
  10. Jan 17, 2025
    • thiolliere's avatar
      Make frame crate not use the feature experimental (#7177) · 4b2febe1
      thiolliere authored
      We already use it for lots of pallet.
      
      Keeping it feature gated by experimental means we lose the information
      of which pallet was using experimental before the migration to frame
      crate usage.
      
      We can consider `polkadot-sdk-frame` crate unstable but let's not use
      the feature `experimental`.
      
      ---------
      
      Co-authored-by: command-bot <>
      4b2febe1
  11. Jan 14, 2025
  12. Jan 13, 2025
  13. Jan 07, 2025
  14. Jan 05, 2025
    • thiolliere's avatar
      Implement cumulus StorageWeightReclaim as wrapping transaction extension +... · 63c73bf6
      thiolliere authored
      Implement cumulus StorageWeightReclaim as wrapping transaction extension + frame system ReclaimWeight (#6140)
      
      (rebasing of https://github.com/paritytech/polkadot-sdk/pull/5234)
      
      ## Issues:
      
      * Transaction extensions have weights and refund weight. So the
      reclaiming of unused weight must happen last in the transaction
      extension pipeline. Currently it is inside `CheckWeight`.
      * cumulus storage weight reclaim transaction extension misses the proof
      size of logic happening prior to itself.
      
      ## Done:
      
      * a new storage `ExtrinsicWeightReclaimed` in frame-system. Any logic
      which attempts to do some reclaim must use this storage to avoid double
      reclaim.
      * a new function `reclaim_weight` in frame-system pallet: info and post
      info in arguments, read the already reclaimed weight, calculate the new
      unused weight from info and post info. do the more accurate reclaim if
      higher.
      * `CheckWeight` is unchanged and still reclaim the weight in post
      dispatch
      * `ReclaimWeight` is a new transaction extension in frame system. For
      solo chains it must be used last in the transactino extension pipeline.
      It does the final most accurate reclaim
      * `StorageWeightReclaim` is moved from cumulus primitives into its own
      pallet (in order to define benchmark) and is changed into a wrapping
      transaction extension.
      It does the recording of proof size and does the reclaim using this
      recording and the info and post info. So parachains don't need to use
      `ReclaimWeight`. But also if they use it, there is no bug.
      
          ```rust
        /// The TransactionExtension to the basic transaction logic.
      pub type TxExtension =
      cumulus_pallet_weight_reclaim::StorageWeightReclaim<
               Runtime,
               (
                       frame_system::CheckNonZeroSender<Runtime>,
                       frame_system::CheckSpecVersion<Runtime>,
                       frame_system::CheckTxVersion<Runtime>,
                       frame_system::CheckGenesis<Runtime>,
                       frame_system::CheckEra<Runtime>,
                       frame_system::CheckNonce<Runtime>,
                       frame_system::CheckWeight<Runtime>,
      pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
                       BridgeRejectObsoleteHeadersAndMessages,
      
      (bridge_to_rococo_config::OnBridgeHubWestendRefundBridgeHubRococoMessages,),
      frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
               ),
        >;
        ```
      
      ---------
      
      Co-authored-by: default avatarGitHub Action <action@github.com>
      Co-authored-by: default avatargeorgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
      Co-authored-by: command-bot <>
      63c73bf6
  15. Jan 03, 2025
  16. Jan 02, 2025
    • thiolliere's avatar
      Fix polkadot sdk doc. (#7022) · 47294570
      thiolliere authored
      
      If you see the doc
      https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html
      The runtime part introduction is missing.
      
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      47294570
    • Oliver Tale-Yazdi's avatar
      [CI] Skip SemVer on R0-silent and update docs (#6285) · 9d760a9f
      Oliver Tale-Yazdi authored
      
      Changes:
      - Make R0-silent not run the semver check again. Originally I thought
      this would be good to have a bullet-proof check, but it now often
      triggers when CI or unrelated files are changed. In the end, the
      developer has to make the right choice here - and always will need to.
      So bringing back the R0 label gives more power to the devs and should
      increase dev velocity. We still need to ensure that every use of this
      label is well understood, and not just used out of lazyness.
      - Fix `/cmd prdoc` bump levels
      - Update docs
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      9d760a9f
  17. 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 <>
      a843d15e
  18. Dec 12, 2024
    • Iulian Barbu's avatar
      omni-node: add metadata checks for runtime/parachain compatibility (#6450) · 7cc5cdd0
      Iulian Barbu authored
      
      # Description
      
      Get runtime's metadata, parse it and verify pallets list for a pallet
      named `ParachainSystem` (for now), and block number to be the same for
      both node and runtime. Ideally we'll add other pallets checks too, at
      least a small set of pallets we think right away as mandatory for
      parachain compatibility.
      Closes: #5565 
      
      ## Integration
      
      Runtime devs must be made aware that to be fully compatible with Omni
      Node, certain naming conventions should be respected when defining
      pallets (e.g we verify parachain-system pallet existence by searching
      for a pallet with `name` `ParachainSystem` in runtime's metadata). Not
      finding such a pallet will not influence the functionality yet, but by
      doing these checks we could provide useful feedback for runtimes that
      are clearly not implementing what's required for full parachain
      compatibility with Omni Node.
      
      ## Review Notes
      
      - [x] parachain system check
      - [x] check frame_system's metadata to ensure the block number in there
      is the same as the one in the node side
      - [x] add tests for the previous checking logic
      - [x] update omni node polkadot-sdk docs to make these conventions
      visible.
      - [ ] add more pallets checks?
      
      ---------
      
      Signed-off-by: default avatarIulian Barbu <iulian.barbu@parity.io>
      Co-authored-by: default avatarAlexandru Vasile <60601340+lexnv@users.noreply.github.com>
      Co-authored-by: default avatarMichal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
      7cc5cdd0
  19. Dec 10, 2024
  20. Nov 29, 2024
  21. Nov 27, 2024
  22. Nov 08, 2024
    • Michal Kucharczyk's avatar
      runtimes: presets are provided as config patches (#6349) · 8c8f3390
      Michal Kucharczyk authored
      This PR introduces usage of `build_struct_json_patch` macro in all
      runtimes (also guides) within the code base.
      
      It also fixes macro to support _field init shorthand_, and _Struct
      Update_ syntax which were missing in original implementation.
      
      Follow up of #5700 and #5813
      8c8f3390
  23. Nov 05, 2024
    • Nazar Mokrynskyi's avatar
      Remove `sp_runtime::RuntimeString` and replace with `Cow<'static, str>` or... · c5444f38
      Nazar Mokrynskyi authored
      Remove `sp_runtime::RuntimeString` and replace with `Cow<'static, str>` or `String` depending on use case (#5693)
      
      # Description
      
      As described in https://github.com/paritytech/polkadot-sdk/issues/4001
      `RuntimeVersion` was not encoded consistently using serde. Turned out it
      was a remnant of old times and no longer actually needed. As such I
      removed it completely in this PR and replaced with `Cow<'static, str>`
      for spec/impl names and `String` for error cases.
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/4001.
      
      ## Integration
      
      For downstream projects the upgrade will primarily consist of following
      two changes:
      ```diff
      #[sp_version::runtime_version]
      pub const VERSION: RuntimeVersion = RuntimeVersion {
      -	spec_name: create_runtime_str!("statemine"),
      -	impl_name: create_runtime_str!("statemine"),
      +	spec_name: alloc::borrow::Cow::Borrowed("statemine"),
      +	impl_name: alloc::borrow::Cow::Borrowed("statemine"),
      ```
      ```diff
      		fn dispatch_benchmark(
      			config: frame_benchmarking::BenchmarkConfig
      -		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
      +		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
      ```
      
      SCALE encoding/decoding remains the same as before, but serde encoding
      in runtime has changed from bytes to string (it was like this in `std`
      environment already), which most projects shouldn't have issues with. I
      consider the impact of serde encoding here low due to the type only
      being used in runtime version struct and mostly limited to runtime
      internals, where serde encoding/decoding of this data structure is quite
      unlikely (though we did hit exactly this edge-case ourselves
      :sweat_smile:
      
      ).
      
      ## Review Notes
      
      Most of the changes are trivial and mechanical, the only non-trivial
      change is in
      `substrate/primitives/version/proc-macro/src/decl_runtime_version.rs`
      where macro call expectation in `sp_version::runtime_version`
      implementation was replaced with function call expectation.
      
      # Checklist
      
      * [x] 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)
      
      ---------
      
      Co-authored-by: default avatarGitHub Action <action@github.com>
      Co-authored-by: default avatarGuillaume Thiolliere <guillaume.thiolliere@parity.io>
      Co-authored-by: default avatarBastian Köcher <info@kchr.de>
      c5444f38
  24. Oct 25, 2024
    • Michal Kucharczyk's avatar
      `RuntimeGenesiConfig`: json macro added (#5813) · 7e996211
      Michal Kucharczyk authored
      This PR adds `build_struct_json_patch` which helps to generate a JSON
      used for preset.
      
      Here is doc and example:
      
      https://github.com/paritytech/polkadot-sdk/blob/d868b858/substrate/frame/support/src/generate_genesis_config.rs#L168-L266
      
      And real-world usage:
      
      https://github.com/paritytech/polkadot-sdk/blob/d868b858
      
      /cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs#L37-L61
      
      Closes #5700
      
      ---------
      
      Co-authored-by: default avatarSebastian Kunert <skunert49@gmail.com>
      7e996211
  25. Oct 23, 2024
    • Kian Paimani's avatar
      Polkadot OmniNode Docs (#6094) · fc486e55
      Kian Paimani authored
      provides low-level documentation on how the omni-node is meant to work.
      This is meant to act as reusable material for other teams (e.g.
      Papermoon and W3F) to use and integrate into the high level Polkadot
      documentation.
      
      Broadly speaking, for omni-node to have great rust-docs, we need to
      focus on the following crates, all of which got a bit of love in this
      PR:
      
      1. `sp-genesis-builder`
      2. `polkadot-omni-node`
      3. `polkadot-omni-node-lib`
      4. `frame-omni-bencher`
      
      On top of this, we have now: 
      
      * `polkadot_sdk_docs::guides` contains two new steps demonstrating the
      most basic version of composing your pallet, putting it into a runtime,
      and putting that runtime into omni-node
      * `polkadot_sdk_docs::reference_docs::omni_node` to explain in more
      detail how omni-node differs from the old-school node.
      * `polkadot_sdk_docs::reference_docs::frame_weight_benchmarking` to
      finally have a minimal reference about weights and benchmarking.
      * It provides tests for some of the steps in
      https://g...
      fc486e55
  26. Oct 21, 2024
  27. 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 the latter. (Ultimately, the latter will be phased out as
      a type of transaction, and Bare will only be used for Inherents.)
      
      Types of extrinsic are now therefore:
      - Bare (no hardcoded signature, no Extra data; used to be known as
      "Unsigned")
      - Bare transactions (deprecated): Gossiped, validated with
      `ValidateUnsigned` (deprecated) and the `_bare_compat` bits of
      `TransactionExtension` (deprecated).
        - Inherents: Not gossiped, validated with `ProvideInherent`.
      - Extended (Extra data): Gossiped, validated via `TransactionExtension`.
        - Signed transactions (with a hardcoded signature) in extrinsic v4.
      - General transactions (without a hardcoded signature) in extrinsic v5.
      
      `TransactionExtension` differs from `SignedExtension` because:
      - A signature on the underlying transaction may validly not be present.
      - It may alter the origin during validation.
      - `pre_dispatch` is renamed to `prepare` and need not contain the checks
      present in `validate`.
      - `validate` and `prepare` is passed an `Origin` rather than a
      `AccountId`.
      - `validate` may pass arbitrary information into `prepare` via a new
      user-specifiable type `Val`.
      - `AdditionalSigned`/`additional_signed` is renamed to
      `Implicit`/`implicit`. It is encoded *for the entire transaction* and
      passed in to each extension as a new argument to `validate`. This
      facilitates the ability of extensions to acts as underlying crypto.
      
      There is a new `DispatchTransaction` trait which contains only default
      function impls and is impl'ed for any `TransactionExtension` impler. It
      provides several utility functions which reduce some of the tedium from
      using `TransactionExtension` (indeed, none of its regular functions
      should now need to be called directly).
      
      Three transaction version discriminator ("versions") are now permissible
      (RFC [here](https://github.com/polkadot-fellows/RFCs/pull/84)) in
      extrinsic version 5:
      - 0b00000100 or 0b00000101: Bare (used to be called "Unsigned"):
      contains Signature or Extra (extension data). After bare transactions
      are no longer supported, this will strictly identify an Inherents only.
      Available in both extrinsic versions 4 and 5.
      - 0b10000100: Old-school "Signed" Transaction: contains Signature, Extra
      (extension data) and an extension version byte, introduced as part of
      [RFC99](https://github.com/polkadot-fellows/RFCs/blob/main/text/0099-transaction-extension-version.md).
      Still available as part of extrinsic v4.
      - 0b01000101: New-school "General" Transaction: contains Extra
      (extension data) and an extension version byte, as per RFC99, but no
      Signature. Only available in extrinsic v5.
      
      For the New-school General Transaction, it becomes trivial for authors
      to publish extensions to the mechanism for authorizing an Origin, e.g.
      through new kinds of key-signing schemes, ZK proofs, pallet state,
      mutations over pre-authenticated origins or any combination of the
      above.
      
      `UncheckedExtrinsic` still maintains encode/decode backwards
      compatibility with extrinsic version 4, where the first byte was encoded
      as:
      - 0b00000100 - Unsigned transactions
      - 0b10000100 - Old-school Signed transactions, without the extension
      version byte
      
      Now, `UncheckedExtrinsic` contains a `Preamble` and the actual call. The
      `Preamble` describes the type of extrinsic as follows:
      ```rust
      /// A "header" for extrinsics leading up to the call itself. Determines the type of extrinsic and
      /// holds any necessary specialized data.
      #[derive(Eq, PartialEq, Clone)]
      pub enum Preamble<Address, Signature, Extension> {
      	/// An extrinsic without a signature or any extension. This means it's either an inherent or
      	/// an old-school "Unsigned" (we don't use that terminology any more since it's confusable with
      	/// the general transaction which is without a signature but does have an extension).
      	///
      	/// NOTE: In the future, once we remove `ValidateUnsigned`, this will only serve Inherent
      	/// extrinsics and thus can be renamed to `Inherent`.
      	Bare(ExtrinsicVersion),
      	/// An old-school transaction extrinsic which includes a signature of some hard-coded crypto.
      	/// Available only on extrinsic version 4.
      	Signed(Address, Signature, ExtensionVersion, Extension),
      	/// A new-school transaction extrinsic which does not include a signature by default. The
      	/// origin authorization, through signatures or other means, is performed by the transaction
      	/// extension in this extrinsic. Available starting with extrinsic version 5.
      	General(ExtensionVersion, Extension),
      }
      ```
      
      ## Code Migration
      
      ### NOW: Getting it to build
      
      Wrap your `SignedExtension`s in `AsTransactionExtension`. This should be
      accompanied by renaming your aggregate type in line with the new
      terminology. E.g. Before:
      
      ```rust
      /// The SignedExtension to the basic transaction logic.
      pub type SignedExtra = (
      	/* snip */
      	MySpecialSignedExtension,
      );
      /// Unchecked extrinsic type as expected by this runtime.
      pub type UncheckedExtrinsic =
      	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
      ```
      
      After:
      
      ```rust
      /// The extension to the basic transaction logic.
      pub type TxExtension = (
      	/* snip */
      	AsTransactionExtension<MySpecialSignedExtension>,
      );
      /// Unchecked extrinsic type as expected by this runtime.
      pub type UncheckedExtrinsic =
      	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
      ```
      
      You'll also need to alter any transaction building logic to add a
      `.into()` to make the conversion happen. E.g. Before:
      
      ```rust
      fn construct_extrinsic(
      		/* snip */
      ) -> UncheckedExtrinsic {
      	let extra: SignedExtra = (
      		/* snip */
      		MySpecialSignedExtension::new(/* snip */),
      	);
      	let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
      	let signature = payload.using_encoded(|e| sender.sign(e));
      	UncheckedExtrinsic::new_signed(
      		/* snip */
      		Signature::Sr25519(signature),
      		extra,
      	)
      }
      ```
      
      After:
      
      ```rust
      fn construct_extrinsic(
      		/* snip */
      ) -> UncheckedExtrinsic {
      	let tx_ext: TxExtension = (
      		/* snip */
      		MySpecialSignedExtension::new(/* snip */).into(),
      	);
      	let payload = SignedPayload::new(call.clone(), tx_ext.clone()).unwrap();
      	let signature = payload.using_encoded(|e| sender.sign(e));
      	UncheckedExtrinsic::new_signed(
      		/* snip */
      		Signature::Sr25519(signature),
      		tx_ext,
      	)
      }
      ```
      
      ### SOON: Migrating to `TransactionExtension`
      
      Most `SignedExtension`s can be trivially converted to become a
      `TransactionExtension`. There are a few things to know.
      
      - Instead of a single trait like `SignedExtension`, you should now
      implement two traits individually: `TransactionExtensionBase` and
      `TransactionExtension`.
      - Weights are now a thing and must be provided via the new function `fn
      weight`.
      
      #### `TransactionExtensionBase`
      
      This trait takes care of anything which is not dependent on types
      specific to your runtime, most notably `Call`.
      
      - `AdditionalSigned`/`additional_signed` is renamed to
      `Implicit`/`implicit`.
      - Weight must be returned by implementing the `weight` function. If your
      extension is associated with a pallet, you'll probably want to do this
      via the pallet's existing benchmarking infrastructure.
      
      #### `TransactionExtension`
      
      Generally:
      - `pre_dispatch` is now `prepare` and you *should not reexecute the
      `validate` functionality in there*!
      - You don't get an account ID any more; you get an origin instead. If
      you need to presume an account ID, then you can use the trait function
      `AsSystemOriginSigner::as_system_origin_signer`.
      - You get an additional ticket, similar to `Pre`, called `Val`. This
      defines data which is passed from `validate` into `prepare`. This is
      important since you should not be duplicating logic from `validate` to
      `prepare`, you need a way of passing your working from the former into
      the latter. This is it.
      - This trait takes a `Call` type parameter. `Call` is the runtime call
      type which used to be an associated type; you can just move it to become
      a type parameter for your trait impl.
      - There's no `AccountId` associated type any more. Just remove it.
      
      Regarding `validate`:
      - You get three new parameters in `validate`; all can be ignored when
      migrating from `SignedExtension`.
      - `validate` returns a tuple on success; the second item in the tuple is
      the new ticket type `Self::Val` which gets passed in to `prepare`. If
      you use any information extracted during `validate` (off-chain and
      on-chain, non-mutating) in `prepare` (on-chain, mutating) then you can
      pass it through with this. For the tuple's last item, just return the
      `origin` argument.
      
      Regarding `prepare`:
      - This is renamed from `pre_dispatch`, but there is one change:
      - FUNCTIONALITY TO VALIDATE THE TRANSACTION NEED NOT BE DUPLICATED FROM
      `validate`!!
      - (This is different to `SignedExtension` which was required to run the
      same checks in `pre_dispatch` as in `validate`.)
      
      Regarding `post_dispatch`:
      - Since there are no unsigned transactions handled by
      `TransactionExtension`, `Pre` is always defined, so the first parameter
      is `Self::Pre` rather than `Option<Self::Pre>`.
      
      If you make use of `SignedExtension::validate_unsigned` or
      `SignedExtension::pre_dispatch_unsigned`, then:
      - Just use the regular versions of these functions instead.
      - Have your logic execute in the case that the `origin` is `None`.
      - Ensure your transaction creation logic creates a General Transaction
      rather than a Bare Transaction; this means having to include all
      `TransactionExtension`s' data.
      - `ValidateUnsigned` can still be used (for now) if you need to be able
      to construct transactions which contain none of the extension data,
      however these will be phased out in stage 2 of the Transactions Horizon,
      so you should consider moving to an extension-centric design.
      
      ---------
      
      Signed-off-by: default avatargeorgepisaltu <george.pisaltu@parity.io>
      Co-authored-by: default avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>
      Co-authored-by: default avatarBranislav Kontur <bkontur@gmail.com>
      b76e91ac
  28. Oct 11, 2024
    • Maksym H's avatar
      /cmd: Improved devx of benching many pallets simultaneously (#6007) · c0b73433
      Maksym H authored
      
      ### Improved devx of running many pallets simultaneously
      
      Changes to /cmd:
      - Replace (flip) `--continue-on-fail` with `--fail-fast`, but only for
      `bench`. This makes all pallets/runtimes run non-stop by default, as it
      was primary use-case during tests
      - The list of successful/failed pallets was hard to find within tons of
      logs, so decided to write only needed logs in a file, and output as a
      summary in the workflow and in the comment
      - Side fix: updated `tasks_example` to `pallet_example_tasks` to make
      compliant with standard naming
      
      <img width="1006" alt="image"
      src="https://github.com/user-attachments/assets/14896041-7018-4a0d-92b7-4508e81913c2">
      
      + added command results to workflow summary:
      <img width="1275" alt="image"
      src="https://github.com/user-attachments/assets/b4a8afdb-dc9f-4ff9-9720-28a88956035f">
      
      ---------
      
      Co-authored-by: default avatarGitHub Action <action@github.com>
      c0b73433
  29. Oct 08, 2024
    • Serban Iorga's avatar
      Omni-Node renamings (#5915) · a4dce869
      Serban Iorga authored
      - moved the omni-node lib from
        `cumulus/polkadot-parachain/polkadot-parachain-lib` to
        `cumulus/polkadot-omni-node/lib`
      - renamed `polkadot-parachain-lib` to `polkadot-omni-node-lib`
      - added `polkadot-omni-node` binary
      
      Related to https://github.com/paritytech/polkadot-sdk/issues/5566
      a4dce869
    • Maksym H's avatar
      improve prdoc generation (#5931) · 4b40e762
      Maksym H authored
      Related to
      https://github.com/paritytech/polkadot-sdk/pull/5924#issuecomment-2393558697
      
      improve prdoc arguments validation & help:
      - convert audiences options to snake_case. Fixes
      https://github.com/paritytech/polkadot-sdk/issues/5927
        - support more than one audiences
        - define allowed bump options
      - infer --pr from the actual PR (now it's optional, can still be
      overwritten)
      
      
      ![image](https://github.com/user-attachments/assets/24e18fe2-2f67-4ce0-90e4-34f6c2f860c9)
      
      Test evidence:
      https://github.com/paritytech-stg/polkadot-sdk/pull/52/commits/6dd274e3678d287c163cfa6cb696acee9852767d
      4b40e762
  30. Oct 07, 2024
  31. Oct 02, 2024
    • Serban Iorga's avatar
      `polkadot-parachain`: add manual seal support (#5586) · 3cf83ca8
      Serban Iorga authored
      Resolves https://github.com/paritytech/polkadot-sdk/issues/5026
      
      This PR adds support for starting a dev node with manual seal consensus.
      This can be done by using the `--dev-block-time` argument . For example:
      ```
      polkadot-parachain --chain asset-hub-rococo-dev --dev-block-time 5000 --tmp
      ```
      3cf83ca8
  32. Sep 23, 2024
    • Alin Dima's avatar
      elastic scaling: add core selector to cumulus (#5372) · b9eb68bc
      Alin Dima authored
      Partially implements
      https://github.com/paritytech/polkadot-sdk/issues/5048
      
      - adds a core selection runtime API to cumulus and a generic way of
      configuring it for a parachain
      - modifies the slot based collator to utilise the claim queue and the
      generic core selection
      
      What's left to be implemented (in a follow-up PR):
      - add the UMP signal for core selection into the parachain-system pallet
      
      View the RFC for more context:
      https://github.com/polkadot-fellows/RFCs/pull/103
      
      ---------
      
      Co-authored-by: command-bot <>
      b9eb68bc
  33. Sep 10, 2024
    • Maksym H's avatar
      Add prdoc command to /cmd (#5661) · f0e420a0
      Maksym H authored
      Fixes https://github.com/paritytech/polkadot-sdk/issues/5647
      
      - [x]  create new command (reusing original py module)
      - [x]  add unit-test cases (just the fact of proxy)
      - [x]  update docs
      f0e420a0
    • Vedhavyas Singareddi's avatar
      Update `RuntimeVerison` type and use `system_version` to derive extrinsics... · 9930d213
      Vedhavyas Singareddi authored
      Update `RuntimeVerison` type and use `system_version` to derive extrinsics root `StateVersion` instead of `V0` (#4257)
      
      This PR 
      - Renames `RuntimeVersion::state_version` to `system_version`
      - Uses `Runtime::system_version` to derive extrinsics root
      `StateVersion` instead of default `StateVersion::V0`
      
      This PR should not be breaking any existing chains so long as they use
      same `RuntimeVersion::state_version` for `Runtime::system_version`
      
      Using `RuntimeVersion::system_version = 2` will make the extrinsics root
      to use `StateVersion::V1` instead of `V0`
      
      RFC for this change - https://github.com/polkadot-fellows/RFCs/pull/42
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: default avatarKoute <koute@users.noreply.github.com>
      Co-authored-by: default avatarNazar Mokrynskyi <nazar@mokrynskyi.com>
      9930d213
  34. Sep 09, 2024
    • Oliver Tale-Yazdi's avatar
      Install prdoc from Parity fork (#5625) · d2e962fc
      Oliver Tale-Yazdi authored
      
      Prdoc is now published as a Parity fork under the
      [`parity-prdoc`](https://crates.io/crates/parity-prdoc) crate after the
      directions diverged from the ideas of the original creator (discussions
      [here](https://github.com/paritytech/prdoc/pull/40) and
      [here](https://github.com/paritytech/prdoc/issues/36)).
      Now updating the install instructions here.
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      d2e962fc
  35. Sep 05, 2024
    • Przemek Rzad's avatar
      Make the docs logo readable on light backgrounds (#5389) · f6fd5bc5
      Przemek Rzad authored
      
      Currently, the logo on the docs site blends into the background on the
      light theme:
      
      <img width="320px"
      src="https://github.com/user-attachments/assets/4cded445-d3af-4100-bd11-6a33da836cb1">
      
      
      [Here](https://internals.rust-lang.org/t/feedback-on-new-rust-documentation-logo-background/12787)
      is a discussion related to this. There doesn't seem to be a perfect way
      to handle this situation.
      
      ---
      
      Silent because the docs crate is not part of the regular release
      process.
      
      ---------
      
      Co-authored-by: default avatarordian <write@reusable.software>
      f6fd5bc5