1. Jan 31, 2024
    • Branislav Kontur's avatar
      [xcm] Fix `SovereignPaidRemoteExporter` and `DepositAsset` handling (#3157) · 6ea472ad
      Branislav Kontur authored
      This PR addresses two issues:
      - It modifies `DepositAsset`'s asset filter from `All` to
      `AllCounted(1)` to prevent potentially charging excessive weight/fees.
      This adjustment avoids situations where fees could be calculated based
      on the count of assets, as illustrated
      [here](https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs#L38-L46).
      - It encapsulates `DepositAsset` with `SetAppendix` to ensure that
      `fees` are not trapped in any case. For instance, this prevents issues
      when `ExportXcm::validate` encounters an error during the processing of
      `ExportMessage`.
      6ea472ad
    • dependabot[bot]'s avatar
      Bump bounded-collections from 0.1.9 to 0.2.0 (#3118) · 2adf499a
      dependabot[bot] authored
      Bumps [bounded-collections](https://github.com/paritytech/parity-common)
      from 0.1.9 to 0.2.0.
      <details>
      <summary>Commits</summary>
      <ul>
      <li>See full diff in <a
      href="https://github.com/paritytech/parity-common/commits/impl-rlp-v0.2.0">compare
      view</a></li>
      </ul>
      </details>
      <br />
      
      
      [![Dependabot compatibility
      score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=bounded-collections&package-manager=cargo&previous-version=0.1.9&new-version=0.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores
      
      )
      
      Dependabot will resolve any conflicts with this PR as long as you don't
      alter it yourself. You can also trigger a rebase manually by commenting
      `@dependabot rebase`.
      
      [//]: # (dependabot-automerge-start)
      [//]: # (dependabot-automerge-end)
      
      ---
      
      <details>
      <summary>Dependabot commands and options</summary>
      <br />
      
      You can trigger Dependabot actions by commenting on this PR:
      - `@dependabot rebase` will rebase this PR
      - `@dependabot recreate` will recreate this PR, overwriting any edits
      that have been made to it
      - `@dependabot merge` will merge this PR after your CI passes on it
      - `@dependabot squash and merge` will squash and merge this PR after
      your CI passes on it
      - `@dependabot cancel merge` will cancel a previously requested merge
      and block automerging
      - `@dependabot reopen` will reopen this PR if it is closed
      - `@dependabot close` will close this PR and stop Dependabot recreating
      it. You can achieve the same result by closing it manually
      - `@dependabot show <dependency name> ignore conditions` will show all
      of the ignore conditions of the specified dependency
      - `@dependabot ignore <dependency name> major version` will close this
      group update PR and stop Dependabot creating any more for the specific
      dependency's major version (unless you unignore this specific
      dependency's major version or upgrade to it yourself)
      - `@dependabot ignore <dependency name> minor version` will close this
      group update PR and stop Dependabot creating any more for the specific
      dependency's minor version (unless you unignore this specific
      dependency's minor version or upgrade to it yourself)
      - `@dependabot ignore <dependency name>` will close this group update PR
      and stop Dependabot creating any more for the specific dependency
      (unless you unignore this specific dependency or upgrade to it yourself)
      - `@dependabot unignore <dependency name>` will remove all of the ignore
      conditions of the specified dependency
      - `@dependabot unignore <dependency name> <ignore condition>` will
      remove the ignore condition of the specified dependency and ignore
      conditions
      
      
      </details>
      
      Signed-off-by: default avatardependabot[bot] <[email protected]>
      Co-authored-by: default avatardependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      2adf499a
    • Branislav Kontur's avatar
    • Alexandru Gheorghe's avatar
    • Adrian Catangiu's avatar
      xcm-executor: DepositReserveAsset charges delivery fees from inner assets (#3142) · 5354097a
      Adrian Catangiu authored
      
      
      This fix aims to solve an issue in Kusama that resulted in failed
      reserve asset transfers.
      
      During multi-hop XCMs, like reserve asset transfers where the reserve is
      not the sender nor the destination, but a third remote chain, the origin
      is not available to pay for delivery fees out of their account directly,
      so delivery fees should be paid out of transferred assets.
      
      This commit also adds an xcm-emulator regression test that validates
      this scenario is now working.
      
      Signed-off-by: default avatarAdrian Catangiu <[email protected]>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      5354097a
    • Vladimir Istyufeev's avatar
      Use external reference for the CI image as before (#3153) · e757f811
      Vladimir Istyufeev authored
      Usual chore after bumping Rust toolchain version.
      e757f811
    • Branislav Kontur's avatar
      Fix for `poeple-*` benchmarks command + added them to CI (#3146) · 2aa7926c
      Branislav Kontur authored
      Found it when trying to run: 
      ```
      bot bench-all pallet --pallet=pallet_balances
      ```
      https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5081585
      
      ## TODO
      - [x] check/fix command bot for `people-westend-dev` /
      `people-rococo-dev`
      https://github.com/paritytech/command-bot-scripts/pull/67
      2aa7926c
    • Branislav Kontur's avatar
      [frame] `#[pallet::composite_enum]` improved variant count handling + removed... · bb8ddc46
      Branislav Kontur authored
      [frame] `#[pallet::composite_enum]` improved variant count handling + removed `pallet_balances`'s `MaxHolds` config (#2657)
      
      I started this investigation/issue based on @liamaharon question
      [here](https://github.com/paritytech/polkadot-sdk/pull/1801#discussion_r1410452499).
      
      ## Problem
      
      The `pallet_balances` integrity test should correctly detect that the
      runtime has correct distinct `HoldReasons` variant count. I assume the
      same situation exists for RuntimeFreezeReason.
      
      It is not a critical problem, if we set `MaxHolds` with a sufficiently
      large value, everything should be ok. However, in this case, the
      integrity_test check becomes less useful.
      
      **Situation for "any" runtime:**
      - `HoldReason` enums from different pallets:
      ```rust
              /// from pallet_nis
              #[pallet::composite_enum]
      	pub enum HoldReason {
      		NftReceipt,
      	}
      
              /// from pallet_preimage
              #[pallet::composite_enum]
      	pub enum HoldReason {
      		Preimage,
      	}
      
              // from pallet_state-trie-migration
              #[pallet::composite_enum]
      	pub enum HoldReason {
      		SlashForContinueMigrate,
      		SlashForMigrateCustomTop,
      		SlashForMigrateCustomChild,
      	}
      ```
      
      - generated `RuntimeHoldReason` enum looks like:
      ```rust
      pub enum RuntimeHoldReason {
      
          #[codec(index = 32u8)]
          Preimage(pallet_preimage::HoldReason),
      
          #[codec(index = 38u8)]
          Nis(pallet_nis::HoldReason),
      
          #[codec(index = 42u8)]
          StateTrieMigration(pallet_state_trie_migration::HoldReason),
      }
      ```
      
      - composite enum `RuntimeHoldReason` variant count is detected as `3`
      - we set `type MaxHolds = ConstU32<3>`
      - `pallet_balances::integrity_test` is ok with `3`(at least 3)
      
      However, the real problem can occur in a live runtime where some
      functionality might stop working. This is due to a total of 5 distinct
      hold reasons (for pallets with multi-instance support, it is even more),
      and not all of them can be used because of an incorrect `MaxHolds`,
      which is deemed acceptable according to the `integrity_test`:
        ```
        // pseudo-code - if we try to call all of these:
      
      T::Currency::hold(&pallet_nis::HoldReason::NftReceipt.into(),
      &nft_owner, deposit)?;
      T::Currency::hold(&pallet_preimage::HoldReason::Preimage.into(),
      &nft_owner, deposit)?;
      
      T::Currency::hold(&pallet_state_trie_migration::HoldReason::SlashForContinueMigrate.into(),
      &nft_owner, deposit)?;
      
        // With `type MaxHolds = ConstU32<3>` these two will fail
      
      T::Currency::hold(&pallet_state_trie_migration::HoldReason::SlashForMigrateCustomTop.into(),
      &nft_owner, deposit)?;
      
      T::Currency::hold(&pallet_state_trie_migration::HoldReason::SlashForMigrateCustomChild.into(),
      &nft_owner, deposit)?;
        ```  
      
      
      ## Solutions
      
      A macro `#[pallet::*]` expansion is extended of `VariantCount`
      implementation for the `#[pallet::composite_enum]` enum type. This
      expansion generates the `VariantCount` implementation for pallets'
      `HoldReason`, `FreezeReason`, `LockId`, and `SlashReason`. Enum variants
      must be plain enum values without fields to ensure a deterministic
      count.
      
      The composite runtime enum, `RuntimeHoldReason` and
      `RuntimeFreezeReason`, now sets `VariantCount::VARIANT_COUNT` as the sum
      of pallets' enum `VariantCount::VARIANT_COUNT`:
      ```rust
      #[frame_support::pallet(dev_mode)]
      mod module_single_instance {
      
      	#[pallet::composite_enum]
      	pub enum HoldReason {
      		ModuleSingleInstanceReason1,
      		ModuleSingleInstanceReason2,
      	}
      ...
      }
      
      #[frame_support::pallet(dev_mode)]
      mod module_multi_instance {
      
      	#[pallet::composite_enum]
      	pub enum HoldReason<I: 'static = ()> {
      		ModuleMultiInstanceReason1,
      		ModuleMultiInstanceReason2,
      		ModuleMultiInstanceReason3,
      	}
      ...
      }
      
      
      impl self::sp_api_hidden_includes_construct_runtime::hidden_include::traits::VariantCount
          for RuntimeHoldReason
      {
          const VARIANT_COUNT: u32 = 0
              + module_single_instance::HoldReason::VARIANT_COUNT
              + module_multi_instance::HoldReason::<module_multi_instance::Instance1>::VARIANT_COUNT
              + module_multi_instance::HoldReason::<module_multi_instance::Instance2>::VARIANT_COUNT
              + module_multi_instance::HoldReason::<module_multi_instance::Instance3>::VARIANT_COUNT;
      }
      ```
      
      In addition, `MaxHolds` is removed (as suggested
      [here](https://github.com/paritytech/polkadot-sdk/pull/2657#discussion_r1443324573))
      from `pallet_balances`, and its `Holds` are now bounded to
      `RuntimeHoldReason::VARIANT_COUNT`. Therefore, there is no need to let
      the runtime specify `MaxHolds`.
      
      
      ## For reviewers
      
      Relevant changes can be found here:
      - `substrate/frame/support/procedural/src/lib.rs` 
      -  `substrate/frame/support/procedural/src/pallet/parse/composite.rs`
      -  `substrate/frame/support/procedural/src/pallet/expand/composite.rs`
      -
      `substrate/frame/support/procedural/src/construct_runtime/expand/composite_helper.rs`
      -
      `substrate/frame/support/procedural/src/construct_runtime/expand/hold_reason.rs`
      -
      `substrate/frame/support/procedural/src/construct_runtime/expand/freeze_reason.rs`
      - `substrate/frame/support/src/traits/misc.rs`
      
      And the rest of the files is just about removed `MaxHolds` from
      `pallet_balances`
      
      ## Next steps
      
      Do the same for `MaxFreezes`
      https://github.com/paritytech/polkadot-sdk/issues/2997
      
      .
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarDónal Murray <[email protected]>
      Co-authored-by: default avatargupnik <[email protected]>
      bb8ddc46
    • Francisco Aguirre's avatar
      Add limits to XCMv4 (#3114) · cc4805b5
      Francisco Aguirre authored
      
      
      Some more work regarding XCMv4. Two limits from v3 were not transferred
      over, those are:
      - The instructions limit
      - The number of assets limit
      Both of these are now in v4.
      
      For some reason `AssetInstance` increased in size, don't know why CI
      didn't catch that before.
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: command-bot <>
      cc4805b5
    • Branislav Kontur's avatar
      [cumulus] `parachains-common` testnet constants cleaning (#3134) · 4450b615
      Branislav Kontur authored
      The `parachains-common` contains a lots of constants and type
      definitions which are used for `polkadot-sdk`'s testnet runtimes and
      also for `polkadot-fellows`'s production [SP
      runtimes](https://github.com/polkadot-fellows/runtimes/tree/main/system-parachains/constants).
      This PR cleans `parachains-common` module to contain only common and
      generic functionality.
      
      Testnet-specific constants have been moved to the separate module
      dedicated just for testnets:
      `polkadot-sdk/cumulus/parachains/runtimes/constants/`
      
      
      Part of: https://github.com/paritytech/polkadot-sdk/issues/3054
      
      
      
      ---------
      
      Co-authored-by: default avatargeorgepisaltu <[email protected]>
      4450b615
  2. Jan 30, 2024
  3. Jan 29, 2024
  4. Jan 28, 2024
  5. Jan 27, 2024
  6. Jan 26, 2024
    • Alexander Theißen's avatar
      contracts: Fix printing the `Schedule` (#3021) · 5e5341da
      Alexander Theißen authored
      Printing the `Schedule` is a useful debugging tool and general sanity
      check. It is much more easy to interpret than the raw weights.
      
      The printing relied on using `println` and hence was only available from
      the native runtime. This is no longer available. This is why in this PR
      we switch to using `log` which works from Wasm.
      
      I made sure that the `WeightDebug` is only derived when
      `runtime-benchmarks` is set so that we don't increase the size of the
      binary.
      
      Some other changes were necessary to make this actually work inside the
      runtime. For example, I needed to remove `format!` and usage of floats.
      
      Please note that this removed the decimal from the number because
      truncating the fraction without using floats would not be easy and would
      require custom code. I think the precision here is sufficient.
      
      This is how the output looks like now:
      ```
      Schedule {
          limits: Limits {
              event_topics: 4,
              globals: 256,
              locals: 1024,
              parameters: 128,
              memory_pages: 16,
              table_size: 4096,
              br_table_size: 256,
              subject_len: 32,
              payload_len: 16384,
              runtime_memory: 134217728,
          },
          instruction_weights: InstructionWeights {
              base: 2565,
              _phantom: PhantomData<kitchensink_runtime::Runtime>,
          },
          host_fn_weights: HostFnWeights {
              caller: 322 ns, 6 bytes,
              is_contract: 28 µs, 2684 bytes,
              code_hash: 29 µs, 2688 bytes,
              own_code_hash: 400 ns, 6 bytes,
              caller_is_origin: 176 ns, 3 bytes,
              caller_is_root: 158 ns, 3 bytes,
              address: 315 ns, 6 bytes,
              gas_left: 355 ns, 6 bytes,
              balance: 1 µs, 6 bytes,
              value_transferred: 314 ns, 6 bytes,
              minimum_balance: 318 ns, 6 bytes,
              block_number: 313 ns, 6 bytes,
              now: 325 ns, 6 bytes,
              weight_to_fee: 1 µs, 14 bytes,
              input: 263 ns, 6 bytes,
              input_per_byte: 989 ps, 0 bytes,
              r#return: 0 ps, 45 bytes,
              return_per_byte: 320 ps, 0 bytes,
              terminate: 1 ms, 5266 bytes,
              random: 1 µs, 10 bytes,
              deposit_event: 1 µs, 10 bytes,
              deposit_event_per_topic: 127 µs, 2508 bytes,
              deposit_event_per_byte: 501 ps, 0 bytes,
              debug_message: 226 ns, 7 bytes,
              debug_message_per_byte: 1 ns, 0 bytes,
              set_storage: 131 µs, 293 bytes,
              set_storage_per_new_byte: 576 ps, 0 bytes,
              set_storage_per_old_byte: 184 ps, 1 bytes,
              set_code_hash: 297 µs, 3090 bytes,
              clear_storage: 131 µs, 289 bytes,
              clear_storage_per_byte: 92 ps, 1 bytes,
              contains_storage: 29 µs, 289 bytes,
              contains_storage_per_byte: 213 ps, 1 bytes,
              get_storage: 29 µs, 297 bytes,
              get_storage_per_byte: 980 ps, 1 bytes,
              take_storage: 131 µs, 297 bytes,
              take_storage_per_byte: 921 ps, 1 bytes,
              transfer: 156 µs, 2520 bytes,
              call: 484 µs, 2721 bytes,
              delegate_call: 406 µs, 2637 bytes,
              call_transfer_surcharge: 607 µs, 5227 bytes,
              call_per_cloned_byte: 970 ps, 0 bytes,
              instantiate: 1 ms, 2731 bytes,
              instantiate_transfer_surcharge: 131 µs, 2549 bytes,
              instantiate_per_input_byte: 1 ns, 0 bytes,
              instantiate_per_salt_byte: 1 ns, 0 bytes,
              hash_sha2_256: 377 ns, 8 bytes,
              hash_sha2_256_per_byte: 1 ns, 0 bytes,
              hash_keccak_256: 767 ns, 8 bytes,
              hash_keccak_256_per_byte: 3 ns, 0 bytes,
              hash_blake2_256: 443 ns, 8 bytes,
              hash_blake2_256_per_byte: 1 ns, 0 bytes,
              hash_blake2_128: 440 ns, 8 bytes,
              hash_blake2_128_per_byte: 1 ns, 0 bytes,
              ecdsa_recover: 45 µs, 77 bytes,
              ecdsa_to_eth_address: 11 µs, 42 bytes,
              sr25519_verify: 41 µs, 112 bytes,
              sr25519_verify_per_byte: 5 ns, 1 bytes,
              reentrance_count: 174 ns, 3 bytes,
              account_reentrance_count: 248 ns, 40 bytes,
              instantiation_nonce: 154 ns, 3 bytes,
              add_delegate_dependency: 131 µs, 2606 bytes,
              remove_delegate_dependency: 130 µs, 2568 bytes,
          },
      }
      ###############################################
      Lazy deletion weight per key: Weight(ref_time: 126109302, proof_size: 70)
      Lazy deletion keys per block: 15859
      ```
      5e5341da
    • Oliver Tale-Yazdi's avatar
      Release Process (#2490) · d72fb580
      Oliver Tale-Yazdi authored
      
      
      Writing down the processes to do our releases.
      
      Status: please review & approve so we can go ahead.
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarJegor Sidorenko <[email protected]>
      d72fb580
    • Liam Aharon's avatar
    • Oliver Tale-Yazdi's avatar
      Fix Pools 6->7 migration (#2942) · dd45c949
      Oliver Tale-Yazdi authored
      
      
      Fix the Pools `v7` migration.
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      dd45c949