1. Nov 04, 2023
  2. Nov 01, 2023
    • Ankan's avatar
      [NPoS] Paging reward payouts in order to scale rewardable nominators (#1189) · 00b85c51
      Ankan authored
      helps https://github.com/paritytech/polkadot-sdk/issues/439.
      closes https://github.com/paritytech/polkadot-sdk/issues/473.
      
      PR link in the older substrate repository:
      https://github.com/paritytech/substrate/pull/13498.
      
      # Context
      Rewards payout is processed today in a single block and limited to
      `MaxNominatorRewardedPerValidator`. This number is currently 512 on both
      Kusama and Polkadot.
      
      This PR tries to scale the nominators payout to an unlimited count in a
      multi-block fashion. Exposures are stored in pages, with each page
      capped to a certain number (`MaxExposurePageSize`). Starting out, this
      number would be the same as `MaxNominatorRewardedPerValidator`, but
      eventually, this number can be lowered through new runtime upgrades to
      limit the rewardeable nominators per dispatched call instruction.
      
      The changes in the PR are backward compatible.
      
      ## How payouts would work like after this change
      Staking exposes two calls, 1) the existing `payout_stakers` and 2)
      `payout_stakers_by_page`.
      
      ### payout_stakers
      This remains backward compatible with no signature change. If for a
      given era a validator has multiple pages, they can call `payout_stakers`
      multiple times. The pages are executed in an ascending sequence and the
      runtime takes care of preventing double claims.
      
      ### payout_stakers_by_page
      Very similar to `payout_stakers` but also accepts an extra param
      `page_index`. An account can choose to payout rewards only for an
      explicitly passed `page_index`.
      
      **Lets look at an example scenario**
      Given an active validator on Kusama had 1100 nominators,
      `MaxExposurePageSize` set to 512 for Era e. In order to pay out rewards
      to all nominators, the caller would need to call `payout_stakers` 3
      times.
      
      - `payout_stakers(origin, stash, e)` => will pay the first 512
      nominators.
      - `payout_stakers(origin, stash, e)` => will pay the second set of 512
      nominators.
      - `payout_stakers(origin, stash, e)` => will pay the last set of 76
      nominators.
      ...
      - `payout_stakers(origin, stash, e)` => calling it the 4th time would
      return an error `InvalidPage`.
      
      The above calls can also be replaced by `payout_stakers_by_page` and
      passing a `page_index` explicitly.
      
      ## Commission note
      Validator commission is paid out in chunks across all the pages where
      each commission chunk is proportional to the total stake of the current
      page. This implies higher the total stake of a page, higher will be the
      commission. If all the pages of a validator's single era are paid out,
      the sum of commission paid to the validator across all pages should be
      equal to what the commission would have been if we had a non-paged
      exposure.
      
      ### Migration Note
      Strictly speaking, we did not need to bump our storage version since
      there is no migration of storage in this PR. But it is still useful to
      mark a storage upgrade for the following reasons:
      
      - New storage items are introduced in this PR while some older storage
      items are deprecated.
      - For the next `HistoryDepth` eras, the exposure would be incrementally
      migrated to its corresponding paged storage item.
      - Runtimes using staking pallet would strictly need to wait at least
      `HistoryDepth` eras with current upgraded version (14) for the migration
      to complete. At some era `E` such that `E >
      era_at_which_V14_gets_into_effect + HistoryDepth`, we will upgrade to
      version X which will remove the deprecated storage items.
      In other words, it is a strict requirement that E<sub>x</sub> -
      E<sub>14</sub> > `HistoryDepth`, where
      E<sub>x</sub> = Era at which deprecated storages are removed from
      runtime,
      E<sub>14</sub> = Era at which runtime is upgraded to version 14.
      - For Polkadot and Kusama, there is a [tracker
      ticket](https://github.com/paritytech/polkadot-sdk/issues/433) to clean
      up the deprecated storage items.
      
      ### Storage Changes
      
      #### Added
      - ErasStakersOverview
      - ClaimedRewards
      - ErasStakersPaged
      
      #### Deprecated
      The following can be cleaned up after 84 eras which is tracked
      [here](https://github.com/paritytech/polkadot-sdk/issues/433).
      
      - ErasStakers.
      - ErasStakersClipped.
      - StakingLedger.claimed_rewards, renamed to
      StakingLedger.legacy_claimed_rewards.
      
      ### Config Changes
      - Renamed MaxNominatorRewardedPerValidator to MaxExposurePageSize.
      
      ### TODO
      - [x] Tracker ticket for cleaning up the old code after 84 eras.
      - [x] Add companion.
      - [x] Redo benchmarks before merge.
      - [x] Add Changelog for pallet_staking.
      - [x] Pallet should be configurable to enable/disable paged rewards.
      - [x] Commission payouts are distributed across pages.
      - [x] Review documentation thoroughly.
      - [x] Rename `MaxNominatorRewardedPerValidator` ->
      `MaxExposurePageSize`.
      - [x] NMap for `ErasStakersPaged`.
      - [x] Deprecate ErasStakers.
      - [x] Integrity tests.
      
      ### Followup issues
      [Runtime api for deprecated ErasStakers storage
      item](https://github.com/paritytech/polkadot-sdk/issues/426
      
      )
      
      ---------
      
      Co-authored-by: default avatarJavier Viola <[email protected]>
      Co-authored-by: default avatarRoss Bulat <[email protected]>
      Co-authored-by: command-bot <>
      00b85c51
  3. Oct 15, 2023
    • Gonçalo Pestana's avatar
      Refactor staking ledger (#1484) · 8ee4042c
      Gonçalo Pestana authored
      This PR refactors the staking ledger logic to encapsulate all reads and
      mutations of `Ledger`, `Bonded`, `Payee` and stake locks within the
      `StakingLedger` struct implementation.
      
      With these changes, all the reads and mutations to the `Ledger`, `Payee`
      and `Bonded` storage map should be done through the methods exposed by
      StakingLedger to ensure the data and lock consistency of the operations.
      The new introduced methods that mutate and read Ledger are:
      
      - `ledger.update()`: inserts/updates a staking ledger in storage;
      updates staking locks accordingly (and ledger.bond(), which is synthatic
      sugar for ledger.update())
      - `ledger.kill()`: removes all Bonded and StakingLedger related data for
      a given ledger; updates staking locks accordingly;
      `StakingLedger::get(account)`: queries both the `Bonded` and `Ledger`
      storages and returns a `Option<StakingLedger>`. The pallet impl exposes
      fn ledger(account) as synthatic sugar for `StakingLedger::get(account)`.
      
      Retrieving a ledger with `StakingLedger::get()` can be done by providing
      either a stash or controller account. The input must be wrapped in a
      `StakingAccount` variant (Stash or Controller) which is treated
      accordingly. This simplifies the caller API but will eventually be
      deprecated once we completely get rid of the controller account in
      staking. However, this refactor will help with the work necessary when
      completely removing the controller.
      
      Other goals:
      
      - No logical changes have been introduced in this PR;
      - No breaking changes or updates in wallets required;
      - No new storage items or need to perform storage migrations;
      - Centralise the changes to bonds and ledger updates to simplify the
      OnStakingUpdate updates to the target list (related to
      https://github.com/paritytech/polkadot-sdk/issues/443)
      
      Note: it would be great to prevent or at least raise a warning if
      `Ledger<T>`, `Payee<T>` and `Bonded<T>` storage types are accessed
      outside the `StakingLedger` implementation. This PR should not get
      blocked by that feature, but there's a tracking issue here
      https://github.com/paritytech/polkadot-sdk/issues/149
      
      Related and step towards
      https://github.com/paritytech/polkadot-sdk/issues/443
      8ee4042c
  4. Sep 18, 2023
  5. Aug 10, 2023
    • Gonçalo Pestana's avatar
      [NPoS] Implements dynamic number of nominators (#12970) · 93754780
      Gonçalo Pestana authored
      
      
      * Implements dynamic nominations per nominator
      
      * Adds SnapshotBounds and ElectionSizeTracker
      
      * Changes the ElectionDataProvider interface to receive ElectionBounds as input
      
      * Implements get_npos_voters with ElectionBounds
      
      * Implements get_npos_targets with ElectionBounds
      
      * Adds comments
      
      * tests
      
      * Truncates nomninations that exceed nominations quota; Old tests passing
      
      * Uses DataProviderBounds and ElectionBounds (to continue)
      
      * Finishes conversions - tests passing
      
      * Refactor staking in babe mocks
      
      * Replaces MaxElectableTargets and MaxElectingVoters with ElectionBounds; Adds more tests
      
      * Fixes nits; node compiling
      
      * bechmarks
      
      * removes nomination_quota extrinsic to request the nomination quota
      
      * Lazy quota check, ie. at nominate time only
      
      * remove non-working test (for now)
      
      * tests lazy nominations quota when quota is lower than current number of nominated targets
      
      * Adds runtime API and custom RPC call for clients to query the nominations quota for a given balance
      
      * removes old rpc
      
      * Cosmetic touches
      
      * All mocks working
      
      * Fixes benchmarking mocks
      
      * nits
      
      * more tests
      
      * renames trait methods
      
      * nit
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Fix V2 PoV benchmarking (#13485)
      
      * Bump default 'additional_trie_layers' to two
      
      The default here only works for extremely small runtimes, which have
      no more than 16 storage prefices. This is changed to a "sane" default
      of 2, which is save for runtimes with up to 4096 storage prefices (eg StorageValue).
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update tests and test weights
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Fix PoV weights
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances
      
      * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_message_queue
      
      * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_glutton
      
      * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_glutton
      
      * Fix sanity check
      
      >0 would also do as a check, but let's try this.
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: command-bot <>
      
      * Move BEEFY code to consensus (#13484)
      
      * Move beefy primitives to consensus dir
      * Move beefy gadget to client consensus folder
      * Rename beefy crates
      
      * chore: move genesis block builder to chain-spec crate. (#13427)
      
      * chore: move genesis block builder to block builder crate.
      
      * add missing file
      
      * chore: move genesis block builder to sc-chain-spec
      
      * Update client/chain-spec/src/genesis.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Update test-utils/runtime/src/genesismap.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Update test-utils/runtime/client/src/lib.rs
      
      * fix warnings
      
      * fix warnings
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Speed up storage iteration from within the runtime (#13479)
      
      * Speed up storage iteration from within the runtime
      
      * Move the cached iterator into an `Option`
      
      * Use `RefCell` in no_std
      
      * Simplify the code slightly
      
      * Use `Option::replace`
      
      * Update doc comment for `next_storage_key_slow`
      
      * Make unbounded channels size warning exact (part 1) (#13490)
      
      * Replace `futures-channel` with `async-channel` in `out_events`
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarKoute <[email protected]>
      
      * Also print the backtrace of `send()` call
      
      * Switch from `backtrace` crate to `std::backtrace`
      
      * Remove outdated `backtrace` dependency
      
      * Remove `backtrace` from `Cargo.lock`
      
      ---------
      
      Co-authored-by: default avatarKoute <[email protected]>
      
      * Removal of Prometheus alerting rules deployment in cloud-infra (#13499)
      
      * sp-consensus: remove unused error variants (#13495)
      
      * Expose `ChargedAmount` (#13488)
      
      * Expose `ChargedAmount`
      
      * Fix imports
      
      * sc-consensus-beefy: fix metrics: use correct names (#13494)
      
      
      Signed-off-by: default avataracatangiu <[email protected]>
      
      * clippy fix
      
      * removes NominationsQuotaExceeded event
      
      * Update frame/staking/src/lib.rs
      
      Co-authored-by: default avatarRoss Bulat <[email protected]>
      
      * adds back the npos_max_iter
      
      * remove duplicate imports added after merge
      
      * fmt
      
      * Adds comment in public struct; Refactors CountBound and SizeCount to struct
      
      * addresses various pr comments
      
      * PR comment reviews
      
      * Fixes on-chain election bounds and related code
      
      * EPM checks the size of the voter list returned by the data provider
      
      * cosmetic changes
      
      * updates e2e tests mock
      
      * Adds more tests for size tracker and refactors code
      
      * Adds back only_iterates_max_2_times_max_allowed_len test
      
      * Refactor
      
      * removes unecessary dependency
      
      * empty commit -- restart all stuck CI jobs
      
      * restarts ci jobs
      
      * Renames ElectionBounds -> Bounds in benchmarking mocks et al
      
      * updates mocks
      
      * Update frame/election-provider-support/src/lib.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Update frame/staking/src/pallet/impls.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Update frame/election-provider-support/src/lib.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Update frame/staking/src/tests.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * more checks in api_nominations_quota in tests
      
      * Improves docs
      
      * fixes e2e tests
      
      * Uses size_hint rather than mem::size_of in size tracker; Refactor size tracker to own module
      
      * nits from reviews
      
      * Refactors bounds to own module; improves docs
      
      * More tests and docs
      
      * fixes docs
      
      * Fixes benchmarks
      
      * Fixes rust docs
      
      * fixes bags-list remote-ext-tests
      
      * Simplify bound checks in create_snapshot_external
      
      * Adds target size check in get_npos_targets
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * restart ci
      
      * rust doc fixes and cosmetic nits
      
      * rollback upgrade on parity-scale-codec version (unecessary)
      
      * reset cargo lock, no need to update it
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Signed-off-by: default avataracatangiu <[email protected]>
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avataryjh <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarKoute <[email protected]>
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      Co-authored-by: default avatarAnthony Lazam <[email protected]>
      Co-authored-by: default avatarAndré Silva <[email protected]>
      Co-authored-by: default avatarPiotr Mikołajczyk <[email protected]>
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      Co-authored-by: default avatarRoss Bulat <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      93754780
  6. Jul 24, 2023
  7. Jul 13, 2023
    • gupnik's avatar
      Moves `Block` to `frame_system` instead of `construct_runtime` and removes... · 5e7b27e9
      gupnik authored
      
      Moves `Block` to `frame_system` instead of `construct_runtime` and removes `Header` and `BlockNumber` (#14437)
      
      * Initial setup
      
      * Adds node block
      
      * Uses UncheckedExtrinsic and removes Where section
      
      * Updates frame_system to use Block
      
      * Adds deprecation warning
      
      * Fixes pallet-timestamp
      
      * Removes Header and BlockNumber
      
      * Addresses review comments
      
      * Addresses review comments
      
      * Adds comment about compiler bug
      
      * Removes where clause
      
      * Refactors code
      
      * Fixes errors in cargo check
      
      * Fixes errors in cargo check
      
      * Fixes warnings in cargo check
      
      * Formatting
      
      * Fixes construct_runtime tests
      
      * Uses import instead of full path for BlockNumber
      
      * Uses import instead of full path for Header
      
      * Formatting
      
      * Fixes construct_runtime tests
      
      * Fixes imports in benchmarks
      
      * Formatting
      
      * Fixes construct_runtime tests
      
      * Formatting
      
      * Minor updates
      
      * Fixes construct_runtime ui tests
      
      * Fixes construct_runtime ui tests with 1.70
      
      * Fixes docs
      
      * Fixes docs
      
      * Adds u128 mock block type
      
      * Fixes split example
      
      * fixes for cumulus
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Updates new tests
      
      * Fixes fully-qualified path in few places
      
      * Formatting
      
      * Update frame/examples/default-config/src/lib.rs
      
      Co-authored-by: default avatarJuan <[email protected]>
      
      * Update frame/support/procedural/src/construct_runtime/mod.rs
      
      Co-authored-by: default avatarJuan <[email protected]>
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Addresses some review comments
      
      * Fixes build
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Update frame/democracy/src/lib.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/democracy/src/lib.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/support/procedural/src/construct_runtime/mod.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/support/procedural/src/construct_runtime/mod.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Addresses review comments
      
      * Updates trait bounds
      
      * Minor fix
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Removes unnecessary bound
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Updates test
      
      * Fixes build
      
      * Adds a bound for header
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Removes where block
      
      * Minor fix
      
      * Minor fix
      
      * Fixes tests
      
      * ".git/.scripts/commands/update-ui/update-ui.sh" 1.70
      
      * Updates test
      
      * Update primitives/runtime/src/traits.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Update primitives/runtime/src/traits.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Updates doc
      
      * Updates doc
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarJuan <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      5e7b27e9
  8. Jul 09, 2023
  9. May 23, 2023
  10. May 16, 2023
  11. May 11, 2023
    • Ross Bulat's avatar
      Staking::{bond, set_controller} to set controllers to stash only. (#14039) · 56940bc8
      Ross Bulat authored
      
      
      * update set_controller
      
      * clone
      
      * bond uses `stash`
      
      * remove controller from bond(), chill_other test works
      
      * remove ctlr from testing_utils &  dead ctlr -> dead payee
      
      * mvs controllers to stashes for 3 tests
      
      * migrate mock bond fns & fix 1 test
      
      * mvs controllers to stashes for 7 tests
      
      * mvs controllers to stashes for 9 tests
      
      * remove double_controlling_should_fail
      
      * remove double_staking_should_fail
      
      * mvs controllers to stashes for 10 tests
      
      * mvs controllers to stashes for 2 tests
      
      * remove payout_creates_controller
      
      * mvs controllers to stashes for 27 tests
      
      * remove println!
      
      * fix rewards_should_work
      
      * fix test_payout_stakers
      
      * fix bond benchmark
      
      * clone
      
      * rm unused import
      
      * rm unused var
      
      * rm controller from create_offender
      
      * fix GenesisConfig stakers
      
      * fix controllers in consensus pallets
      
      * fix unqiue controller in chain_spec
      
      * fmt
      
      * fix create_offender
      
      * fix set_controller benchmark
      
      * add TODO
      
      * create_unique_stash_controller
      
      * staking benchmarks working
      
      * fmt
      
      * fix args
      
      * rm println
      
      * import
      
      * import
      
      * fix fast unstake tests
      
      * fix staking-tests-e2e
      
      * fix root-offenses
      
      * fmt
      
      * differentiate controller to stash
      
      * bring back change_controller_works w. unique ctrl
      
      * bring back double_staking_should_fail
      
      * double_controlling_attempt_should_fail
      
      * bring back payout_creates_controller
      
      * add commnet to controller balances
      
      * + set_controller call description
      
      * fmt
      
      * rm clones
      
      * fmt
      
      * clippy fixes
      
      * fmt
      
      * update README
      
      * small fixes
      
      * use controller_to_be_deprecated
      
      * .comment
      
      * comment
      
      * bump zombienet version
      
      * ci
      
      ---------
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarJavier Viola <[email protected]>
      56940bc8
  12. Apr 27, 2023
  13. Apr 18, 2023
  14. Apr 15, 2023
  15. Apr 11, 2023
  16. Mar 13, 2023
    • Vivek Pandya's avatar
      Remove use of trait Store from all pallets and deprecate it. (#13535) · 2009821c
      Vivek Pandya authored
      * Remove use of trait Store from staking pallet
      
      * Remove use of trait Store from bounties pallet
      
      * Remove use of trait Store from collective pallet
      
      * Remove use of trait Store from babe pallet
      
      * Remove use of trait Store from assets pallet
      
      * Remove use of trait Store from grandpa pallet
      
      * Remove use of trait Store from balances pallet
      
      * Remove use of trait Store from authorship pallet
      
      * Remove use of trait Store from authority-discovery pallet
      
      * Remove use of trait Store from atomic-swap pallet
      
      * Remove use of trait Store from sudo pallet
      
      * Remove use of trait Store from scheduler pallet
      
      * Remove use of trait Store from scored-pool pallet
      
      * Remove use of trait Store from society pallet
      
      * Remove use of trait Store from lottery pallet
      
      * Remove use of trait Store from executive pallet
      
      * Remove use of trait Store from democracy pallet
      
      * Remove use of trait Store from elections-phragmen pallet
      
      * Remove use of trait Store from indices pallet
      
      * Remove use of trait Store from identity pallet
      
      * Remove use of trait Store from multisig pallet
      
      * Remove use of trait Store from merkle-mountain-range pallet
      
      * Remove use of trait Store from im-online pallet
      
      * Remove use of trait Store from membership pallet
      
      * Remove use of trait Store from nicks pallet
      
      * Remove use of trait Store from session pallet
      
      * Remove use of trait Store from transaction-payment pallet
      
      * Remove use of trait Store from utility pallet
      
      * Remove use of trait Store from child-bounties pallet
      
      * Remove use of trait Store from nis pallet
      
      * Remove use of trait Store from nfts pallet
      
      * Remove use of trait Store from conviction-voting pallet
      
      * Remove use of trait Store from treasury pallet
      
      * Remove use of trait Store from vesting pallet
      
      * Remove use of trait Store from preimage pallet
      
      * Remove use of trait Store from uniques pallet
      
      * Remove use of trait Store from ranked-collective pallet
      
      * Remove use of trait Store from beefy-mmr pallet
      
      * Remove use of trait Store from referenda pallet
      
      * Remove use of trait Store from whitelist pallet
      
      * Remove use of trait Store from alliance pallet
      
      * Remove use of trait Store from nomination-pools pallet
      
      * Remove use of trait Store from state-trie-migration pallet
      
      * Remove use of trait Store from message-queue pallet
      
      * Remove use of trait Store from root-offences pallet
      
      * Remove use of trait Store from root-testing pallet
      
      * Remove use of trait Store from timestamps pallet
      
      * Remove use of trait Store from system pallet
      
      * Remove use of trait Store from offences pallet
      
      * Remove use of trait Store from recovery pallet
      
      * Remove use of trait Store from node-authorization pallet
      
      * Remove use of trait Store from proxy pallet
      
      * Remove use of trait Store from benchmarking pallet
      
      * Remove use of trait Store from bags-list pallet
      
      * Add deprecated warning in store_trait
      
      * Change warning message
      
      * Run cargo fmt
      
      * Fix warning and update tests
      
      * Remove unnecessary allow deprecated
      
      * Remove use of trait Store
      
      * Fix mismatch in expected output
      
      * Minor update to warning message for deprecation of generate_store with Store trait attribute
      
      * Fixes as per review comments
      
      * Fixes as per review suggestions
      
      * Remove use of Store trait from core-fellowship pallet
      
      * Fix type in store_trait.rs
      
      * Fixes as pre review comment
      2009821c
  17. Mar 02, 2023
  18. Feb 21, 2023
  19. Feb 09, 2023
    • Roman Useinov's avatar
      [Fix] Try-state feature-gated for BagsList (#13296) · 03e9f43f
      Roman Useinov authored
      
      
      * [Fix] Try-state feature-gated for BagsList
      
      * fix comment
      
      * fix try_state remote-tests
      
      * feature-gate try-state remote test for bags-list
      
      * remove try-state from a migration
      
      * more SortedListProvider fixes
      
      * more fixes
      
      * more fixes to allow do_try_state usage in other crates
      
      * do-try-state for fuzz
      
      * more fixes
      
      * more fixes
      
      * remove feature-flag
      
      * do-try-state
      
      * fix review comments
      
      * Update frame/bags-list/src/mock.rs
      
      Co-authored-by: default avatarAnton <[email protected]>
      
      ---------
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarAnton <[email protected]>
      03e9f43f
  20. Jan 29, 2023
  21. Jan 09, 2023
    • Gonçalo Pestana's avatar
      EPM and staking events improvement (#13035) · fcdd8a88
      Gonçalo Pestana authored
      * EPM and staking events improvement
      
      * Uses RawOrigin in ElectionCompute event
      
      * Refactors new phase events to PhaseTransition event
      
      * PhaseTransitioned and remove RawOrigin from event
      
      * Adds helpers for epm phase transition and staking force new
      
      * addresses review comments
      
      * nit: removes unecessary clone
      
      * fixes benchmarks
      
      Co-authored-by: parity-processbot <>
      fcdd8a88
  22. Dec 23, 2022
    • Kian Paimani's avatar
      Fix fast-unstake for accounts with slashing (#12963) · 70e9f8e9
      Kian Paimani authored
      
      
      * Fix fast-unstake for accounts with slashing
      
      * ".git/.scripts/fmt.sh" 1
      
      * fmt
      
      * fix
      
      * fix weight tracking
      
      * Adds tests for withdraw_unbonded with slashing
      
      * Removes tests for withdraw_unbonded with slashing
      
      * ".git/.scripts/fmt.sh"
      
      * Adds slash spans calculation test for withdraw_unbonded
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatargpestana <[email protected]>
      70e9f8e9
  23. Dec 15, 2022
    • Gonçalo Pestana's avatar
      Automatic `withdraw_unbonded` upon `unbond` (#12582) · 8e120489
      Gonçalo Pestana authored
      
      
      * Prevents max unbonding chunk slots from being filled when unbonding in the staking pallet
      
      * hardcode num_slashing to unlock chunks automatically
      
      * refactor withdraw logic to do_withdraw; idiomatic rust improvements
      
      * a
      
      * callable unbond() to return a DispatchWithPostInfo to dynamically update the consumed weight
      
      * refunds overpaid fees when unbond with withdraw
      
      * fetches real slashing spans before withdrawal call
      
      * nits
      
      * addresses PR comments
      
      * Adds more testing
      
      * fixes doc comments
      
      * Fixes weight refunding logic for fn unbond
      
      * generalizes  to return used weight or dispatch error
      
      * Update frame/staking/src/pallet/mod.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Update frame/staking/src/pallet/mod.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Addresses PR comments
      
      * Add comment to speculative num spans
      
      * adds missing add_slashing_spans in withdraw_unbonded_kill benchmarks
      
      * ".git/.scripts/bench-bot.sh" pallet dev pallet_staking
      
      * fix publish
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: command-bot <>
      8e120489
  24. Dec 14, 2022
  25. Dec 13, 2022
    • Bastian Köcher's avatar
      Fixup some wrong dependencies (#12899) · c0c8d630
      Bastian Köcher authored
      * Fixup some wrong dependencies
      
      Dev dependencies should not appear in the feature list. If features are required, they should be
      directly enabled for the `dev-dependency`.
      
      * More fixups
      
      * Fix fix
      
      * Remove deprecated feature
      
      * Make all work properly and nice!!
      
      * FMT
      
      * Fix formatting
      c0c8d630
  26. Dec 12, 2022
  27. Dec 09, 2022
  28. Dec 08, 2022
    • Anthony Alaribe's avatar
      Move LockableCurrency trait to fungibles::Lockable and deprecate LockableCurrency (#12798) · 9a014d1e
      Anthony Alaribe authored
      
      
      * WIP move LockableCurrency to fungibles
      
      * rename Lockable and LockIdentifier to funginbles::*
      
      * fix imports further
      
      * change Lockable from fungible to fungibles
      
      * reintroduce LockableCurrency but marked as deprecated
      
      * fix imports
      
      * fix imports
      
      * cargo fmt
      
      * add allow deprecated warnings
      
      * remove unused benchmark import
      
      * fix some of the docs
      
      * fix failing doctest check
      
      * reexport LockIdentifier and LockableCurrency from support/traits
      
      * reexport LockIdentifier and LockableCurrency from support/traits
      
      * allow using deprecated re-export
      
      * replace LockableCurrency and LockIdentifier with a module alias
      
      * Update frame/support/src/traits/tokens/fungibles/lockable.rs
      
      * Update frame/staking/src/pallet/mod.rs
      
      Co-authored-by: default avatarSquirrel <[email protected]>
      
      * Update frame/support/src/traits.rs
      
      Co-authored-by: default avatarSquirrel <[email protected]>
      
      * REVERT removing fungibles::Lockable import
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarSquirrel <[email protected]>
      9a014d1e
  29. Nov 21, 2022
  30. Nov 09, 2022
    • Ankan's avatar
      Bound Election and Staking by MaxActiveValidators (#12436) · 657d9920
      Ankan authored
      
      
      * bounding election provider with kian
      
      * multi phase implement bounded election provider
      
      * election provider blanket implementation
      
      * staking compiles
      
      * fix test for election provider support
      
      * fmt
      
      * fixing epmp tests, does not compile yet
      
      * fix epmp tests
      
      * fix staking tests
      
      * fmt
      
      * fix runtime tests
      
      * fmt
      
      * remove outdated wip tags
      
      * add enum error
      
      * sort and truncate supports
      
      * comment
      
      * error when unsupported number of election winners
      
      * compiling wip after kian's suggestions
      
      * fix TODOs
      
      * remove,fix tags
      
      * ensure validator count does not exceed maxwinners
      
      * clean up
      
      * some more clean up and todos
      
      * handle too many winners
      
      * rename parameter for mock
      
      * todo
      
      * add sort and truncate rule if there are too many winners
      
      * fmt
      
      * fail, not swallow emergency result bound not met
      
      * remove too many winners resolution as it can be guaranteed to be bounded
      
      * fix benchmark
      
      * give MaxWinners more contextual name
      
      * make ready solution generic over T
      
      * kian feedback
      
      * fix stuff
      
      * Kian's way of solvign this
      
      * comment fix
      
      * fix compile
      
      * remove use of BoundedExecution
      
      * fmt
      
      * comment out failing integrity test
      
      * cap validator count increment to max winners
      
      * dont panic
      
      * add test for bad data provider
      
      * Update frame/staking/src/pallet/impls.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * fix namespace conflict and add test for onchain max winners less than desired targets
      
      * defensive unwrap
      
      * early convert to bounded vec
      
      * fix syntax
      
      * fmt
      
      * fix doc
      
      * fix rustdoc
      
      * fmt
      
      * fix maxwinner count for benchmarking
      
      * add instant election for noelection
      
      * fmt
      
      * fix compile
      
      * pr feedbacks
      
      * always error at validator count exceeding max winners
      
      * add useful error message
      
      * pr comments
      
      * import fix
      
      * add checked_desired_targets
      
      * fmt
      
      * fmt
      
      * fix rust doc
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      657d9920
  31. Oct 29, 2022
  32. Oct 17, 2022
    • Ankan's avatar
      Execute try-state at end of each test to ensure pallet data integrity (#12453) · ca15fe7e
      Ankan authored
      * execute try-state at end of tests
      
      * run post condition only with try runtime
      
      * Revert "run post condition only with try runtime"
      
      This reverts commit 7db0ecf7eaa2ee5afa5a995487b73d023ba3bcd9.
      
      * voterlist contains validators as well
      
      * fmt
      
      * simplify
      
      * fmt
      
      Co-authored-by: parity-processbot <>
      ca15fe7e
  33. Sep 27, 2022
  34. Sep 23, 2022
    • Kian Paimani's avatar
      Fast Unstake Pallet (#12129) · b56c0e4c
      Kian Paimani authored
      * add failing test for itamar
      
      * an ugly example of fast unstake
      
      * Revert "add failing test for itamar"
      
      This reverts commit 16c4d8015698a0684c090c54fce8b470a2d2feb2.
      
      * fast unstake wip
      
      * clean it up a bit
      
      * some comments
      
      * on_idle logic
      
      * fix
      
      * comment
      
      * new working version, checks all pass, looking good
      
      * some notes
      
      * add mock boilerplate
      
      * more boilerplate
      
      * simplify the weight stuff
      
      * ExtBuilder for pools
      
      * fmt
      
      * rm bags-list, simplify setup_works
      
      * mock + tests boilerplate
      
      * make some benchmarks work
      
      * mock boilerplate
      
      * tests boilerplate
      
      * run_to_block works
      
      * add Error enums
      
      * add test
      
      * note
      
      * make UnstakeRequest fields pub
      
      * some tests
      
      * fix origin
      
      * fmt
      
      * add fast_unstake_events_since_last_call
      
      * text
      
      * rewrite some benchmes and fix them -- the outcome is still strange
      
      * Fix weights
      
      * cleanup
      
      * Update frame/election-provider-support/solution-type/src/single_page.rs
      
      * fix build
      
      * Fix pools tests
      
      * iterate teset + mock
      
      * test unfinished
      
      * cleanup and add some tests
      
      * add test successful_multi_queue
      
      * comment
      
      * rm Head check
      
      * add TODO
      
      * complete successful_multi_queue
      
      * + test early_exit
      
      * fix a lot of things above the beautiful atlantic ocean 🌊
      
      
      
      * seemingly it is finished now
      
      * Fix build
      
      * ".git/.scripts/fmt.sh" 1
      
      * Fix slashing amount as well
      
      * better docs
      
      * abstract types
      
      * rm use
      
      * import
      
      * Update frame/nomination-pools/benchmarking/src/lib.rs
      
      Co-authored-by: default avatarNitwit <[email protected]>
      
      * Update frame/fast-unstake/src/types.rs
      
      Co-authored-by: default avatarNitwit <[email protected]>
      
      * Fix build
      
      * fmt
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * make bounded
      
      * feedback from code review with Ankan
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/lib.rs
      
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      
      * Update frame/fast-unstake/src/mock.rs
      
      * update to master
      
      * some final review comments
      
      * fmt
      
      * fix clippy
      
      * remove unused
      
      * ".git/.scripts/fmt.sh" 1
      
      * make it all build again
      
      * fmt
      
      * undo fishy change
      
      Co-authored-by: default avatarRoss Bulat <[email protected]>
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarNitwit <[email protected]>
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      Co-authored-by: default avatarRoman Useinov <[email protected]>
      b56c0e4c
  35. Sep 21, 2022
    • Ankan's avatar
      Bound staking storage items (#12230) · c6a9abcc
      Ankan authored
      
      
      * replace pallet level unboundedness to individual storage items
      
      * bound structs
      
      * bounding history depth
      
      * defensive error
      
      * use the era history depth from config
      
      * clean up history depth from storage in v11
      
      * keep the name HistoryDepth for the new configuration value
      
      * use u32 for history depth in node runtime
      
      * improve doc comments
      
      * add HistoryDepth to mock runtimes with pallet-staking
      
      * rustfmt
      
      * refactor and doc improve
      
      * apply re-benchmarked weight for staking
      
      * pr feedback improvements
      
      * test for claimed rewards following the expected bounds
      
      * refactor test to calculate first and last reward era programmatically
      
      * verify previous eras cannot be claimed
      
      * add migration v12
      
      * ".git/.scripts/bench-bot.sh" pallet dev pallet_staking
      
      * fix compiler error
      
      * corrupting history depth does not lead to catastrophic issue
      
      * fix new line
      
      * remove unused import
      
      * fmt
      
      * add test to document scenario where history depth is reduced without migration
      
      * fmt
      
      * Update frame/staking/src/lib.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Update frame/staking/src/migrations.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * doc for all storage items bounded by HistoryDepth
      
      * Update frame/staking/src/pallet/mod.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * Update frame/staking/src/tests.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * pr feedback fixes
      
      * Update frame/staking/src/tests.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * remove extra checks
      
      * fix merge
      
      * fmt
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarkianenigma <[email protected]>
      c6a9abcc
  36. Sep 18, 2022
    • Roman Useinov's avatar
      [Fix] Benchmark issue in staking (#12290) · 63c2e288
      Roman Useinov authored
      63c2e288
    • Roman Useinov's avatar
      [Feature] Part 1: add TargetList for validator ranking (#12034) · 1b24f562
      Roman Useinov authored
      
      
      * [Feature] Part 1: add TargetList for validator ranking
      
      * remove redundant todo
      
      * remove typo
      
      * cleanup
      
      * implement score
      
      * more fixes
      
      * fix thresholds
      
      * fmt
      
      * Remove the stuff that has to come in the next PR, some fixes
      
      * extended balance import
      
      * Change all the references from VoteWeight to Self::Score
      
      * Add a migration for VoterBagsList
      
      * fix score
      
      * add targetList to nomination-pools tests
      
      * fix bench
      
      * address review comments
      
      * change get_npos_targets
      
      * address more comments
      
      * remove thresholds for the time being
      
      * fix instance reference
      
      * VoterBagsListInstance
      
      * reus
      
      * remove params that are not used yet
      
      * Introduced pre/post upgrade try-runtime checks
      
      * fix
      
      * fixes
      
      * fix migration
      
      * fix migration
      
      * fix post_upgrade
      
      * change
      
      * Fix
      
      * eloquent PhantomData
      
      * fix PD
      
      * more fixes
      
      * Update frame/staking/src/pallet/impls.rs
      
      Co-authored-by: default avatarSquirrel <[email protected]>
      
      * is_nominator now works
      
      * fix test-staking
      
      * build fixes
      
      * fix remote-tests
      
      * Apply suggestions from code review
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: default avatarSquirrel <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      1b24f562