Skip to content
Snippets Groups Projects
  1. Aug 15, 2024
  2. Aug 14, 2024
    • Ankan's avatar
      [Pools] Fix issues with member migration to `DelegateStake` (#4822) · feacf2f3
      Ankan authored
      
      ## Context
      Pool members using the old `TransferStake` strategy were able to
      transfer all their funds to the pool. With `DelegateStake` changes, we
      want to ensure similar behaviour by allowing members to delegate all
      their stake to the pool.
      
      ## Changes
      - Ensure all the balance including ED of an account can be delegated
      (and used in the pool) by adding a provider for delegators.
      - Gates calls that mutates the pool or pool member if they are in
      unmigrated state. Closes
      https://github.com/paritytech-secops/srlabs_findings/issues/409.
      - Adds remote test to migrate all pools and members to `DelegateStake`
      which can be used with `Kusama` and `Polkadot` runtime state. closes
      https://github.com/paritytech/polkadot-sdk/issues/4629.
      - Add new runtime apis to read pool and member balance.
      
      ## Addressing possible migration errors 
      Pool members migrating can run into two types of errors:
      - Already Staking: If the pool member is already staking, we cannot
      migrate them to `DelegateStake` since this may mean they are able to use
      the same staked funds in the pool. Users would need to withdraw all
      their funds from staking, in order to migrate their pool funds.
      - Pool contribution below ED: For these cases transfer from pool account
      to member account would fail. The affected users can top up their
      accounts and redo migration.
      
      Another error that was earlier possible was when member's free balance
      is below ED. This PR adds a provider to delegator allowing all user
      balance including ED can be contributed towards the pool. This helps
      `1095` accounts in Polkadot and `41` accounts in Kusama to migrate now
      which would have earlier failed.
      
      ## Results from RemoteExternalities Tests.
      
      ### Kusama
      `Migration stats: success: 3017, direct_stakers: 361, unexpected_errors:
      0`
      
      ### Polkadot
      `Migration stats: success: 42859, direct_stakers: 643,
      unexpected_errors: 0`
      
      ## TODO
      - [x] Add runtime api for member total balance.
      - [x] New
      [issue](https://github.com/paritytech/polkadot-sdk/issues/5009) to reap
      pool members with contribution below ED.
      - [x] Add provider for delegators so whole balance including ED can be
      held while contributing to pools.
      - [x] Gate all pool extrinsics if pool/member is in non-migrated state.
      
      ---------
      
      Co-authored-by: default avatarGonçalo Pestana <g6pestana@gmail.com>
    • Serban Iorga's avatar
      Beefy: add benchmarks for `report_fork_voting()` (#5188) · 81d8f0c0
      Serban Iorga authored
      
      Related to #4523 
      
      This PR adds benchmarks for `report_fork_voting()`.
      
      **Important: Even though the benchmarks are now available, we still use
      `Weight::MAX`. That's because I realized while working on this PR that
      there's still one missing piece. We should also check that the ancestry
      proof is optimal. I plan to do this in a future PR, hopefully the last
      one related to #4523.**
      
      ---------
      
      Co-authored-by: default avatarBranislav Kontur <bkontur@gmail.com>
      Co-authored-by: command-bot <>
    • Muharem Ismailov's avatar
      Make ticket non-optional and add ensure_successful method to Consideration trait (#5359) · 00946b10
      Muharem Ismailov authored
      Make ticket non-optional and add ensure_successful method to
      Consideration trait.
      
      Reverts the optional return ticket type for the new function introduced
      in
      [polkadot-sdk/4596](https://github.com/paritytech/polkadot-sdk/pull/4596)
      and adds a helper `ensure_successful` function for the runtime
      benchmarks.
      Since the existing FRAME pallet represents zero cost with a zero balance
      rather than `None` in an option, maintaining the ticket type as a
      non-optional balance is beneficial for backward compatibility and helps
      avoid unnecessary migrations.
    • Francisco Aguirre's avatar
      Migrate foreign assets v3::Location to v4::Location (#4129) · be74fe92
      Francisco Aguirre authored
      
      In the move from XCMv3 to XCMv4, the `AssetId` for `ForeignAssets` in
      `asset-hub-rococo` and `asset-hub-westend` was left as `v3::Location` to
      be later migrated to `v4::Location`.
      
      This is that migration PR.
      
      Because the encoding of `v3::Location` and `v4::Location` is the same,
      we don't need to do any data migration, the keys will still be
      decodable.
      The [original idea by
      Jan](https://github.com/paritytech/polkadot/pull/7236) was to make the
      v4 changes in v3 since the ABI (the encoding/decoding) didn't change.
      Corroborated the ABI is the same iterating over all storage, the code is
      on [another
      branch](https://github.com/paritytech/polkadot-sdk/blob/cisco-assert-v3-v4-encodings-equal/cumulus/parachains/runtimes/assets/migrations/src/foreign_assets_to_v4/mod.rs).
      
      We will need a data migration when we want to update from `v4::Location`
      to `v5::Location` because of [the accepted RFC changing the NetworkId
      enum](https://github.com/polkadot-fellows/RFCs/pull/108).
      I'll configure MBMs (Multi-Block Migrations) then and make the actual
      migration.
      
      Fixes https://github.com/paritytech/polkadot-sdk/issues/4128
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: command-bot <>
  3. Aug 13, 2024
    • Ankan's avatar
      [Pools] Ensure members can always exit the pool gracefully (#4998) · 42eb4ec0
      Ankan authored
      
      Resolves https://github.com/paritytech-secops/srlabs_findings/issues/412
      
      ## Changes
      - Clear any dangling delegation when member is removed.
      - Agents need to be killed explicitly when pools are destroyed.
      - Member withdraw amount is max of their locked funds and the value of
      their points.
      
      ---------
      
      Co-authored-by: default avatarGonçalo Pestana <g6pestana@gmail.com>
      Co-authored-by: command-bot <>
    • Sebastian Kunert's avatar
      StorageWeightReclaim: set to node pov size if higher (#5281) · 055eb537
      Sebastian Kunert authored
      This PR adds an additional defensive check to the reclaim SE. 
      
      Since it can happen that we miss some storage accesses on other SEs
      pre-dispatch, we should double check
      that the bookkeeping of the runtime stays ahead of the node-side
      pov-size.
      
      If we discover a mismatch and the node-side pov-size is indeed higher,
      we should set the runtime bookkeeping to the node-side value. In cases
      such as #5229, we would stop including extrinsics and not run `on_idle`
      at least.
      
      cc @gui1117
      
      ---------
      
      Co-authored-by: command-bot <>
  4. Aug 08, 2024
  5. Aug 07, 2024
  6. Aug 06, 2024
  7. Aug 05, 2024
    • Sergej Sakac's avatar
      Coretime auto-renew (#4424) · f170af61
      Sergej Sakac authored
      
      This PR adds functionality that allows tasks to enable auto-renewal.
      Each task eligible for renewal can enable auto-renewal.
      
      A new storage value is added to track all the cores with auto-renewal
      enabled and the associated task running on the core. The `BoundedVec` is
      sorted by `CoreIndex` to make disabling auto-renewal more efficient.
      
      Cores are renewed at the start of a new bulk sale. If auto-renewal
      fails(e.g. due to the sovereign account of the task not holding
      sufficient balance), an event will be emitted, and the renewal will
      continue for the other cores.
      
      The two added extrinsics are:
      - `enable_auto_renew`: Extrinsic for enabling auto renewal.
      - `disable_auto_renew`: Extrinsic for disabling auto renewal.
      
      TODOs:
      - [x] Write benchmarks for the newly added extrinsics.
      
      Closes: #4351
      
      ---------
      
      Co-authored-by: default avatarDónal Murray <donalm@seadanda.dev>
    • Kian Paimani's avatar
      Fix frame crate usage doc (#5222) · ad1e556e
      Kian Paimani authored
  8. Aug 02, 2024
    • Francisco Aguirre's avatar
      Add an adapter for configuring AssetExchanger (#5130) · 8ccb6b33
      Francisco Aguirre authored
      
      Added a new adapter to xcm-builder, the `SingleAssetExchangeAdapter`.
      This adapter makes it easy to use `pallet-asset-conversion` for
      configuring the `AssetExchanger` XCM config item.
      
      I also took the liberty of adding a new function to the `AssetExchange`
      trait, with the following signature:
      
      ```rust
      fn quote_exchange_price(give: &Assets, want: &Assets, maximal: bool) -> Option<Assets>;
      ```
      
      The signature is meant to be fairly symmetric to that of
      `exchange_asset`.
      The way they interact can be seen in the doc comment for it in the
      `AssetExchange` trait.
      
      This is a breaking change but is needed for
      https://github.com/paritytech/polkadot-sdk/pull/5131.
      Another idea is to create a new trait for this but that would require
      setting it in the XCM config which is also breaking.
      
      Old PR: https://github.com/paritytech/polkadot-sdk/pull/4375.
      
      ---------
      
      Co-authored-by: default avatarAdrian Catangiu <adrian@parity.io>
  9. Aug 01, 2024
  10. Jul 31, 2024
  11. Jul 30, 2024
  12. Jul 29, 2024
  13. Jul 26, 2024
  14. Jul 24, 2024
    • Shree Vatsa N's avatar
      membership: Restructure pallet into separate files (#4536) · f5e7eaf6
      Shree Vatsa N authored
      
      - What does this PR do?
      This PR separates `membership` pallet into separate files for `lib`,
      `mock` & `tests`.
         
      - Why are these changes needed?
      Currently `membership` pallet consists of `lib`, `mock` & `tests`
      written into a single file.
      Refactor it into separate files which makes it inline to other pallets
      and improves readability.
      
      - How were these changes implemented and what do they affect?
         The PR will not have any affect.
      
      Signed-off-by: default avatarShreevatsa N <i.mnshreevatsa@gmail.com>
      
      ---------
      
      Signed-off-by: default avatarShreevatsa N <i.mnshreevatsa@gmail.com>
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: default avatarBastian Köcher <info@kchr.de>
    • Muharem Ismailov's avatar
      Tx Payment: drop ED requirements for tx payments with exchangeable asset (#4488) · 5878ea27
      Muharem Ismailov authored
      Drop the Existential Deposit (ED) requirement for the asset amount
      exchangeable for the fee asset (eg. DOT/KSM) during transaction
      payments.
      
      This achieved by using `SwapCredit` implementation of swap, which works
      with imbalances and does not require a temporary balance account within
      the transaction payment.
      
      ### Problem
      Currently, every swap during transaction payment, processed with asset
      `A` for native asset, must be for an amount greater than the ED of a
      native asset if the user lacks a native asset account. Since fees are
      typically smaller, the current implementation necessitates additional
      swaps to meet the ED during `pre_dispatch`, with refunds for excess ED
      swap occurring during `post_dispatch`. Further details can be found
      [here](https://github.com/paritytech/polkadot-sdk/blob/115c2477
      
      /substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs#L115).
      
      This setup presents an issue where a user is unable to transfer their
      entire balance and close the account. Instead, the user must transfer
      slightly less of asset `A` to ensure there is enough not only for the
      fee payment but also some extra to meet the ED requirement for their
      native account during `pre_dispatch`. In some cases during
      `post_dispatch`, the user will have the excess ED swapped back to asset
      `A`, while in other cases, it may not be sufficient to meet the ED
      requirement for asset `A`, leading it being left in the user's
      'temporary' native asset account.
      
      ---------
      
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
    • Parth Mittal's avatar
      Remove `pallet-getter` usage from pallet-transaction-payment (#4970) · 71109c5f
      Parth Mittal authored
      
      As per #3326, removes usage of the `pallet::getter` macro from the
      `transaction-payment` pallet. The syntax `StorageItem::<T, I>::get()`
      should be used instead.
      
      Also, adds public functions for compatibility.
      
      NOTE: The `Releases` enum has been made public to transition
      `StorageVersion` from `pub(super) type` to `pub type`.
      
      cc @muraca
      
      polkadot address: 5GsLutpKjbzsbTphebs9Uy4YK6gTN47MAaz6njPktidjR5cp
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
    • thiolliere's avatar
      pallet macro: do not generate try-runtime related code when frame-support... · 8a96d07e
      thiolliere authored
      pallet macro: do not generate try-runtime related code when frame-support doesn't have try-runtime. (#5099)
      
      Status: Ready for review
      
      Fix https://github.com/paritytech/polkadot-sdk/issues/5092
      
      Introduce a new macro in frame-support which discard content if
      `try-runtime` is not enabled.
      
      Use this macro inside `frame-support-procedural` to generate code only
      when `frame-support` is compiled with `try-runtime`.
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
    • dharjeezy's avatar
      include events for voting (#4613) · 2982bf3e
      dharjeezy authored
      
      closes https://github.com/paritytech/polkadot-sdk/issues/143
      
      Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW
      
      ---------
      
      Co-authored-by: default avatarMuharem <ismailov.m.h@gmail.com>
  15. Jul 23, 2024
    • Oliver Tale-Yazdi's avatar
      Remove not-audited warning (#5114) · 604f56f0
      Oliver Tale-Yazdi authored
      
      Pallet tx-pause and safe-mode are both audited, see: #4445
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
    • polka.dom's avatar
      Remove pallet::getter macro from pallet-identity (#4586) · 9974a68c
      polka.dom authored
      
      As per #3326, removes pallet::getter macro usage from the
      pallet-identity. The syntax `StorageItem::<T, I>::get()` should be used
      instead.
      
      Also makes all storage values public
      
      cc @muraca
      
      ---------
      
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: command-bot <>
    • Serban Iorga's avatar
      Beefy equivocation: add runtime API methods (#4993) · 216e8fa1
      Serban Iorga authored
      Related to https://github.com/paritytech/polkadot-sdk/issues/4523
      
      Add runtime API methods for:
      - generating the ancestry proof
      - submiting a fork voting report
      - submitting a future voting report
    • Muharem Ismailov's avatar
      Make `on_unbalanceds` work with `fungibles` `imbalances` (#4564) · 6d0926e2
      Muharem Ismailov authored
      Make `on_unbalanceds` work with `fungibles` `imbalances`.
      
      The `fungibles` `imbalances` cannot be handled by the default
      implementation of `on_unbalanceds` from the `OnUnbalanced` trait. This
      is because the `fungibles` `imbalances` types do not implement the
      `Imbalance` trait (and cannot with its current semantics). The
      `on_unbalanceds` function requires only the `merge` function for the
      imbalance type. In this PR, we provide the `TryMerge` trait, which can
      be implemented by all imbalance types and make `OnUnbalanced` require it
      instead `Imbalance`.
      
      ### Migration for `OnUnbalanced` trait implementations:
      In case if you have a custom implementation of `on_unbalanceds` trait
      function, remove it's `<B>` type argument.
      
      ### Migration for custom imbalance types:
      If you have your own imbalance types implementations, implement the
      `TryMerge` trait for it introduced with this update.
              
      The applicability of the `on_unbalanceds` function to fungibles
      imbalances is useful in cases like -
      [link](https://github.com/paritytech/polkadot-sdk/blob/3a8e675e
      
      /substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs#L267)
      from https://github.com/paritytech/polkadot-sdk/pull/4488.
      
      ---------
      
      Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  16. Jul 22, 2024
  17. Jul 19, 2024
    • Parth Mittal's avatar
      Balances Pallet: Emit events when TI is updated in currency impl (#4936) · 59e3315f
      Parth Mittal authored
      
      # Description
      
      Previously, in the `Currency` impl, the implementation of
      `pallet_balances` was not emitting any instances of `Issued` and
      `Rescinded` events, even though the `Fungible` equivalent was.
      
      This PR adds the `Issued` and `Rescinded` events in appropriate places
      in `impl_currency` along with tests.
      
      Closes #4028 
      
      polkadot address: 5GsLutpKjbzsbTphebs9Uy4YK6gTN47MAaz6njPktidjR5cp
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <git@kchr.de>
      Co-authored-by: default avatarBastian Köcher <info@kchr.de>
    • Ankan's avatar
      [NPoS] Some simple refactors to Delegate Staking (#4981) · 394ea70d
      Ankan authored
      ## Changes
      - `fn update_payee` is renamed to `fn set_payee` in the trait
      `StakingInterface` since there is also a call `Staking::update_payee`
      which does something different, ie used for migrating deprecated
      `Controller` accounts.
      - `set_payee` does not re-dispatch, only mutates ledger.
      - Fix rustdocs for `NominationPools::join`.
      - Add an implementation note about why we cannot allow existing stakers
      to join/bond_extra into the pool.