Skip to content
Snippets Groups Projects
  1. Feb 04, 2025
    • Iulian Barbu's avatar
      Align omni-node and polkadot-parachain versions (#7367) · 3fb7c8c6
      Iulian Barbu authored
      
      # Description
      
      Aligned `polkadot-omni-node` & `polkadot-parachain` versions. There is
      one `NODE_VERSION` constant, in `polkadot-omni-node-lib`, used by both
      binaries.
      
      Closes #7276 .
      
      ## Integration
      
      Node operators will know what versions of `polkadot-omni-node` &
      `polkadot-parachain` they use since their versions will be kept in sync
      with the stable release `polkadot` SemVer version.
      
      ## Review Notes
      
      TODO:
      - [x] update NODE_VERSION of `polkadot-omni-node-lib` when running
      branch off workflow
      
      ---------
      
      Signed-off-by: default avatarIulian Barbu <iulian.barbu@parity.io>
  2. Feb 03, 2025
    • xermicus's avatar
      [pallet-revive] do not trap the caller on instantiations with duplicate contracts (#7414) · 274a781e
      xermicus authored
      
      This PR changes the behavior of `instantiate` when the resulting
      contract address already exists (because the caller tried to instantiate
      the same contract with the same salt multiple times): Instead of
      trapping the caller, return an error code.
      
      Solidity allows `catch`ing this, which doesn't work if we are trapping
      the caller. For example, the change makes the following snippet work:
      
      ```Solidity
      try new Foo{salt: hex"00"}() returns (Foo) {
          // Instantiation was successful (contract address was free and constructor did not revert)
      } catch {
          // This branch is expected to be taken if the instantiation failed because of a duplicate salt
      }
      ```
      
      `revive` PR: https://github.com/paritytech/revive/pull/188
      
      ---------
      
      Signed-off-by: default avatarCyrill Leutwiler <bigcyrill@hotmail.com>
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Maksym H's avatar
      add allow(dead_code) to substrate weight templates (#7408) · 4f4f6f82
      Maksym H authored
      address failed CI after full regeneration
      
      Example https://github.com/paritytech/polkadot-sdk/pull/7406
      Failed CI
      https://github.com/paritytech/polkadot-sdk/actions/runs/13070646240
      
      Monkey-patched weights which have been overridden by automation
      
      ![image](https://github.com/user-attachments/assets/ecf69173-f4dd-4113-a319-4f29d779ecae)
    • 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 sen...
    • Iulian Barbu's avatar
      fix(sync-templates): empty matrix strategy expansion (#7415) · d283ad0c
      Iulian Barbu authored
      
      # Description
      
      There is a small error (which slipped through reviews) in matrix
      strategy expansion which results in errors like this:
      https://github.com/paritytech/polkadot-sdk/actions/runs/13079943579/job/36501002368.
      
      ## Integration
      
      N/A
      
      ## Review Notes
      
      Need to fix this in master and then rerun it manually against
      `stable2412-1`.
      
      Signed-off-by: default avatarIulian Barbu <iulian.barbu@parity.io>
  3. Jan 31, 2025
  4. 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>
    • Stephane Gurgenidze's avatar
      malus-collator: implement malicious collator submitting same collation to all... · 48f69cca
      Stephane Gurgenidze authored
      malus-collator: implement malicious collator submitting same collation to all backing groups (#6924)
      
      ## Issues
      - [[#5049] Elastic scaling: zombienet
      tests](https://github.com/paritytech/polkadot-sdk/issues/5049)
      - [[#4526] Add zombienet tests for malicious
      collators](https://github.com/paritytech/polkadot-sdk/issues/4526)
      
      ## Description
      Modified the undying collator to include a malus mode, in which it
      submits the same collation to all assigned backing groups.
      
      ## TODO
      * [X] Implement malicious collator that submits the same collation to
      all backing groups;
      * [X] Avoid the core index check in the collation generation subsystem:
      https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/node/collation-generation/src/lib.rs#L552-L553;
      * [X] Resolve the mismatch between the descriptor and the commitments
      core index: https://github.com/paritytech/polkadot-sdk/pull/7104
      * [X] Implement `duplicate_collations` test with zombienet-sdk;
      * [X] Add PRdoc.
    • dharjeezy's avatar
      `fatxpool`: use tracing for logging (#6897) · 07d4b466
      dharjeezy authored
      
      This PR modifies the fatxpool to use tracing instead of log for logging.
      
      closes #5490
      
      Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW
      
      ---------
      
      Co-authored-by: default avatarMichal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
    • Maksym H's avatar
      Improvements for Weekly bench (#7390) · e9e42517
      Maksym H authored
      - added 3 links for subweight comparison - now, ~1 month ago release, ~3
      month ago release tag
      - added `--3way --ours` flags for `git apply` to resolve potential
      conflict
      - stick to the weekly branch from the start until the end, to prevent
      race condition with conflicts
    • Jeeyong Um's avatar
      Replace derivative dependency with derive-where (#7324) · 0d644ca0
      Jeeyong Um authored
      
      # Description
      
      Close #7122.
      
      This PR replaces the unmaintained `derivative` dependency with
      `derive-where`.
      
      ## Integration
      
      This PR doesn't change the public interfaces.
      
      ## Review Notes
      
      The `derivative` crate, previously used to derive basic traits for
      structs with generics or enums, is no longer actively maintained. It has
      been replaced with the `derive-where` crate, which offers a more
      straightforward syntax while providing the same features as
      `derivative`.
      
      ---------
      
      Co-authored-by: default avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>
  5. Jan 29, 2025
  6. Jan 28, 2025
    • Maksym H's avatar
    • Maksym H's avatar
      remove old bench & revert the frame-weight-template (#7362) · 9ab00b15
      Maksym H authored
      
      - remove old bench from cmd.py and left alias for backward compatibility
      - reverted the frame-wight-template as the problem was that it umbrella
      template wasn't picked correctly in the old benchmarks, in
      frame-omni-bench it correctly identifies the dependencies and uses
      correct template
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Alexander Samusev's avatar
      ci: fix workflow permissions (#7366) · 0dcb580e
      Alexander Samusev authored
      cc https://github.com/paritytech/ci_cd/issues/1101
    • Dmitry Markin's avatar
      [net/libp2p] Use raw `Identify` observed addresses to discover external addresses (#7338) · 758db43c
      Dmitry Markin authored
      
      Instead of using libp2p-provided external address candidates,
      susceptible to address translation issues, use litep2p-backend approach
      based on confirming addresses observed by multiple peers as external.
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/7207.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • Sebastian Kunert's avatar
      Improve `set_validation_data` error message. (#7359) · 29eb5333
      Sebastian Kunert authored
      
      The old error message was often confusing, because the real reason for
      the error will be printed during inherent execution.
      
      ---------
      
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    • 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>
    • xermicus's avatar
      [pallet-revive] pack exceeding syscall arguments into registers (#7319) · 4302f74f
      xermicus authored
      
      This PR changes how we call runtime API methods with more than 6
      arguments: They are no longer spilled to the stack but packed into
      registers instead. Pointers are 32 bit wide so we can pack two of them
      into a single 64 bit register. Since we mostly pass pointers, this
      technique effectively increases the number of arguments we can pass
      using the available registers.
      
      To make this work for `instantiate` too we now pass the code hash and
      the call data in the same buffer, akin to how the `create` family
      opcodes work in the EVM. The code hash is fixed in size, implying the
      start of the constructor call data.
      
      ---------
      
      Signed-off-by: default avatarxermicus <cyrill@parity.io>
      Signed-off-by: default avatarCyrill Leutwiler <bigcyrill@hotmail.com>
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarcmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
      Co-authored-by: default avatarAlexander Theißen <alex.theissen@me.com>
    • Alin Dima's avatar
      cumulus: bump PARENT_SEARCH_DEPTH and add test for 12-core elastic scaling (#6983) · e6aad5b0
      Alin Dima authored
      On top of https://github.com/paritytech/polkadot-sdk/pull/6757
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/6858 by bumping
      the `PARENT_SEARCH_DEPTH` constant to a larger value (30) and adds a
      zombienet-sdk test that exercises the 12-core scenario.
      
      This is a node-side limit that restricts the number of allowed pending
      availability candidates when choosing the parent parablock during
      authoring.
      This limit is rather redundant, as the parachain runtime already
      restricts the unincluded segment length to the configured value in the
      [FixedVelocityConsensusHook](https://github.com/paritytech/polkadot-sdk/blob/88d900af
      
      /cumulus/pallets/aura-ext/src/consensus_hook.rs#L35)
      (which ideally should be equal to this `PARENT_SEARCH_DEPTH`).
      
      For 12 cores, a value of 24 should be enough, but I bumped it to 30 to
      have some extra buffer.
      
      There are two other potential ways of fixing this:
      - remove this constant altogether, as the parachain runtime already
      makes those guarantees. Chose not to do this, as it can't hurt to have
      an extra safeguard
      - set this value to be equal to the uninlcuded segment size. This value
      however is not exposed to the node-side and would require a new runtime
      API, which seems overkill for a redundant check.
      
      ---------
      
      Co-authored-by: default avatarJavier Viola <javier@parity.io>
  7. Jan 27, 2025
  8. Jan 26, 2025
  9. Jan 25, 2025
    • thiolliere's avatar
      Improve debugging by using `#[track_caller]` in system `assert_last_event` and... · 17ae0627
      thiolliere authored
      Improve debugging by using `#[track_caller]` in system `assert_last_event` and `assert_has_event` (#7142)
      
      Without track caller the error message of the assert points to the
      `assert_last_event` function, which is not useful.
      ```
      thread 'tests::set_metadata_works' panicked at /home/gui/Developpement/polkadot-sdk/substrate/frame/system/src/lib.rs:2034:9:
      assertion `left == right` failed: expected event RuntimeEvent::Referenda(Event::MetadataSet { index: 0, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa }) is not equal to the last event RuntimeEvent::Referenda(Event::MetadataSet { index: 1, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa })
        left: RuntimeEvent::Referenda(Event::MetadataSet { index: 1, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa })
       right: RuntimeEvent::Referenda(Event::MetadataSet { index: 0, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa })
      ```
      
      With the track caller the error message points to the caller, showing
      the source of the error:
      ```
      thread 'tests::set_metadata_works' panicked at substrate/frame/referenda/src/tests.rs:639:9:
      assertion `left == right` failed: expected event RuntimeEvent::Referenda(Event::MetadataSet { index: 0, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa }) is not equal to the last event RuntimeEvent::Referenda(Event::MetadataSet { index: 1, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa })
        left: RuntimeEvent::Referenda(Event::MetadataSet { index: 1, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa })
       right: RuntimeEvent::Referenda(Event::MetadataSet { index: 0, hash: 0xbb30a42c1e62f0afda5f0a4e8a562f7a13a24cea00ee81917b86b89e801314aa })
      ```
      
      I also improved the error message to include a warning when checking
      events on block number zero.
    • thiolliere's avatar
      `set_validation_data` register weight manually, do not use refund when the pre... · 682f8cd2
      thiolliere authored
      `set_validation_data` register weight manually, do not use refund when the pre dispatch is zero. (#7327)
      
      Related https://github.com/paritytech/polkadot-sdk/issues/6772
      
      For an extrinsic, in the post dispatch info, the actual weight is only
      used to reclaim unused weight. If the actual weight is more than the pre
      dispatch weight, then the extrinsic is using the minimum, e.g., the
      weight used registered in pre dispatch.
      
      In parachain-system pallet one call is `set_validation_data`. This call
      is returning an actual weight, but the pre-dispatch weight is 0.
      
      This PR fix the disregard of actual weight of `set_validation_data` by
      registering it manually.
  10. Jan 24, 2025