Commit Graph

78 Commits

Author SHA1 Message Date
Bastian Köcher 05da6d8e84 HoldReason: Improve usage (#13869)
* HoldReason: Improve usage

`HoldReason` was switched recently to use the `composite_enum` attribute that will merge the enums
from all pallets in the runtime to `RuntimeHoldReason`. `pallet-nis` was still requiring that the
variant was passed as constant to call `hold`. The proper implementation is to use the `HoldReason`
from inside the pallet directly when calling `hold`. This is done by adding a `RuntimeHoldReason` as
type to the `Config` trait and requiring that `Currency` is using the same reason. Besides that the
pr changes the name `HoldIdentifier` in `pallet_balances::Config` to `RuntimeHoldReason`.

* Update frame/nis/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Review comment

* Fixes

---------

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
2023-05-24 21:59:34 +00:00
Ross Bulat 56940bc874 Staking::{bond, set_controller} to set controllers to stash only. (#14039)
* 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: Javier Viola <javier@parity.io>
2023-05-11 18:22:15 +00:00
Gavin Wood 5d81f23f8f Deprecate Currency; introduce holds and freezing into fungible traits (#12951)
* First reworking of fungibles API

* New API and docs

* More fungible::* API improvements

* New ref-counting logic for old API

* Missing files

* Fixes

* Use the new transfer logic

* Use fungibles for the dispatchables

* Use shelve/restore names

* Locking works with total balance.

* repotting and removal

* Separate Holds from Reserves

* Introduce freezes

* Missing files

* Tests for freezing

* Fix hold+freeze combo

* More tests

* Fee-free dispatchable for upgrading accounts

* Benchmarks and a few fixes

* Another test

* Docs and refactor to avoid blanket impls

* Repot

* Fit out ItemOf fully

* Add events to Balanced traits

* Introduced events into Hold traits

* Fix Assets pallet tests

* Assets benchmarks pass

* Missing files and fixes

* Fixes

* Fixes

* Benchmarks fixes

* Fix balance benchmarks

* Formatting

* Expose fungible sub modules

* Move NIS to fungible API

* Fix broken impl and add test

* Fix tests

* API for `transfer_and_hold`

* Use composite APIs

* Formatting

* Upgraded event

* Fixes

* Fixes

* Fixes

* Fixes

* Repot tests and some fixed

* Fix some bits

* Fix dust tests

* Rename `set_balance`

- `Balances::set_balance` becomes `Balances::force_set_balance`
- `Unbalanced::set_balance` becomes `Unbalances::write_balance`

* becomes

* Move dust handling to fungibles API

* Formatting

* Fixes and more refactoring

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Use reducible_balance for better correctness on fees

* Reducing hold to zero should remove entry.

* Add test

* Docs

* Update frame/support/src/traits/tokens/fungibles/hold.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Update frame/support/src/traits/tokens/fungibles/regular.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Update frame/support/src/traits/tokens/fungible/hold.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Update frame/support/src/traits/tokens/fungible/regular.rs

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Docs

* Docs

* Docs

* Fix NIS benchmarks

* Doc comment

* Remove post_mutation

* Fix some tests

* Fix some grumbles

* Enumify bool args to fungible(s) functions

* Fix up assets and balances

* Formatting

* Fix contracts

* Fix tests & benchmarks build

* Typify minted boolean arg

* Typify on_hold boolean arg; renames

* Fix numerous tests

* Fix dependency issue

* Privatize dangerous API mutate_account

* Fix contracts (@alext - please check this commit)

* Remove println

* Fix tests for contracts

* Fix broken rename

* Fix broken rename

* Fix broken rename

* Docs

* Update frame/support/src/traits/tokens/fungible/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* remove from_ref_time

* Update frame/executive/src/lib.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/executive/src/lib.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Reenable test

* Update frame/support/src/traits/tokens/fungibles/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungible/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungible/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungible/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/currency.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/lottery/src/tests.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungible/mod.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungible/regular.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungibles/freeze.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungible/regular.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungibles/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungibles/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Update frame/support/src/traits/tokens/fungibles/hold.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* Rename UnwantedRemoval to UnwantedAccountRemoval

* Docs

* Formatting

* Update frame/balances/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update primitives/runtime/src/lib.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* handle_raw_dust oes nothing

* Formatting

* Fixes

* Grumble

* Fixes

* Add test

* Add test

* Tests for reducible_balance

* Fixes

* Fix Salary

* Fixes

* Disable broken test

* Disable nicely

* Fixes

* Fixes

* Fixes

* Rename some events

* Fix nomination pools breakage

* Add compatibility stub for transfer tx

* Reinstate a safely compatible version of Balances set_balance

* Fixes

* Grumble

* Update frame/nis/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances

* disable flakey tests

* Update frame/balances/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Grumbles

* Grumble

---------

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: command-bot <>
2023-03-18 14:47:55 +00:00
Vivek Pandya bc53b9a03a Remove years from copyright notes. (#13415)
* Change copyright year to 2023 from 2022

* Fix incorrect update of copyright year

* Remove years from copy right header

* Fix remaining files

* Fix typo in a header and remove update-copyright.sh
2023-02-21 18:46:41 +00:00
Sam Johnson c9361bed1a migrate new benchmarking syntax from frame_support::benchmarking to frame_benchmarking::v2 (#13235)
* * re-export frame_support::benchmarking in frame_benchmarking::
* prefer use frame_benchmarking::*; in examples, etc

* switch to frame_benchmarking::v2

* completely migrate new benchmarking code out of frame_support

* fix doc links

* remove unneeded return

Co-authored-by: Bastian Köcher <git@kchr.de>

* remove another unneeded return

Co-authored-by: Bastian Köcher <git@kchr.de>

* properly export all macros in v1

* refactor existing frame_benchmarking imports to use ::v1

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
2023-01-27 20:59:39 +00:00
Ankan 9726a10dbb Allow StakingAdmin to set min_commission (#13018)
* staking admin can set min commission

* ".git/.scripts/bench-bot.sh" pallet dev pallet_staking

* fmt

* fix for pr comments

Co-authored-by: command-bot <>
2022-12-26 15:48:40 +00:00
Ankan 657d99202c Bound Election and Staking by MaxActiveValidators (#12436)
* 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: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* 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: kianenigma <kian@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2022-11-09 09:11:51 +00:00
Ankan c6a9abcc68 Bound staking storage items (#12230)
* 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: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/staking/src/migrations.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* doc for all storage items bounded by HistoryDepth

* Update frame/staking/src/pallet/mod.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/staking/src/tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* pr feedback fixes

* Update frame/staking/src/tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* remove extra checks

* fix merge

* fmt

Co-authored-by: command-bot <>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
2022-09-21 08:57:02 +00:00
Sergej Sakac e4b6f4a66d BREAKING: Rename Origin (#12258)
* BREAKING: Rename Origin

* more renaming

* a bit more renaming

* fix

* more fixing

* fix in frame_support

* even more fixes

* fix

* small fix

* ...

* update .stderr

* docs

* update docs

* update docs

* docs
2022-09-20 22:13:09 +00:00
Roman Useinov 1b24f562e6 [Feature] Part 1: add TargetList for validator ranking (#12034)
* [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: Squirrel <gilescope@gmail.com>

* 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: kianenigma <kian@parity.io>
Co-authored-by: Squirrel <gilescope@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2022-09-18 11:28:16 +02:00
Oliver Tale-Yazdi 45966d509e Fix Rust features (#11976)
* Add std feature

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix features

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* WIP

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix features

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix features

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Cleanup

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Impl function also in tests

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Make compile

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix sp-trie feature

Something makes the bench regression guard fail, maybe this?

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add runtime-benchmarks feature to sc-service

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Revert "Fix sp-trie feature"

This reverts commit f2cddfe41bc72e6f2f8133795ec9408ba0c3ec63.
Was already fixed, only needed a CI retry.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
2022-09-14 16:31:58 +00:00
Sergej Sakac 6e8795afe6 BREAKING: Rename Call & Event (#11981)
* rename Event to RuntimeEvent

* rename Call

* rename in runtimes

* small fix

* rename Event

* small fix & rename RuntimeCall back to Call for now

* small fixes

* more renaming

* a bit more renaming

* fmt

* small fix

* commit

* prep for renaming associated types

* fix

* rename associated Event type

* rename to RuntimeEvent

* commit

* merge conflict fixes & fmt

* additional renaming

* fix.

* fix decl_event

* rename in tests

* remove warnings

* remove accidental rename

* .

* commit

* update .stderr

* fix in test

* update .stderr

* TRYBUILD=overwrite

* docs

* fmt

* small change in docs

* rename PalletEvent to Event

* rename Call to RuntimeCall

* renamed at wrong places :P

* rename Call

* rename

* rename associated type

* fix

* fix & fmt

* commit

* frame-support-test

* passing tests

* update docs

* rustdoc fix

* update .stderr

* wrong code in docs

* merge fix

* fix in error message

* update .stderr

* docs & error message

* .

* merge fix

* merge fix

* fmt

* fmt

* merge fix

* more fixing

* fmt

* remove unused

* fmt

* fix

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2022-09-12 22:03:31 +00:00
Kian Paimani f73ce5795c remove unused staking trait bound (#11942) 2022-08-01 10:44:56 +00:00
Bisola Olasehinde aaf693f05a Replace simple parameter_types (#11254)
* update bin/node-template/runtime/src/lib.rs

* update frame/contracts/src/tests.rs

* update frame/executive/src/lib.rs

* update frame/grandpa/src/mock.rs

* update frame/im-online/src/mock.rs

* update frame/offences/benchmarking/src/mock.rs

* update frame/recovery/src/mock.rs

* update frame/referenda/src/mock.rs

* update frame/session/benchmarking/src/mock.rs

* update frame/staking/src/mock.rs

* update frame/state-trie-migration/src/lib.rs

* update frame/support/test/compile_pass/src/lib.rs

* frame/treasury/src/tests.rs

* update frame/whitelist/src/mock.rs

* update frame/vesting/src/mock.rs

* update test-utils/runtime/src/lib.rs

* update bin/node-template/runtime/src/lib.rs

* Update frame/grandpa/src/mock.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* resolve failed checks 1518659 & 1518669

* resolve format check

* backtrack to resolve compile error

* check --all --tests 

* cargo +nightly fmt 

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
2022-04-29 02:25:50 +00:00
Zeke Mostov e0bf4f36bf staking: Proportional ledger slashing (#10982)
* staking: Proportional ledger slashing

* Some comment cleanup

* Update frame/staking/src/pallet/mod.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fix benchmarks

* FMT

* Try fill in all staking configs

* round of feedback and imp from kian

* demonstrate per_thing usage

* Update some tests

* FMT

* Test that era offset works correctly

* Update mocks

* Remove unnescary docs

* Remove unlock_era

* Update frame/staking/src/lib.rs

* Adjust tests to account for only remove when < ED

* Remove stale TODOs

* Remove dupe test

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
2022-04-21 22:53:54 +00:00
Georges ae75a371bf Adding benchmarking for new frame_election_provider_support (#11149)
* First stab at adding benchmarking for
`election-provider-support` onchain

* Adding `BoundedPhragMMS` and fixing stuff

* Fixing node runtime

* Fixing tests

* Finalising all benchmarking stuff

* better comments

* Better benchmarking config

* Better `WeightInfo` and benchmarking

* Fixing tests

* Adding some documentation

* Fixing some typos

* Incorporating review feedback

* cleanup of rustdocs

* rustdoc changes

* changes after code review

* Fixing some errors.

* Fixing dependencies post merge

* Bringing back `UnboundedExecution`

* Better rustdoc and naming

* Cargo.toml formatting
2022-04-15 10:15:01 +00:00
Georges e9bfdd9a0d Add a bounded fallback on failed elections (#10988)
* Allow `pallet-election-provider` to accept smaller
solutions, issue #9478

* Fixing a typo

* Adding some more tests
Removing a seemingly outdated comment

* making it a URL

* Updating test name as per suggestion

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Updating documentation to be more explicit

And to follow the general guidelines

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fixing formatting

* `Fallback` now of type `InstantElectionProvider`
Some cleanups

* Allow `pallet-election-provider` to accept smaller
solutions, issue #9478

* Fixing a typo

* Adding some more tests
Removing a seemingly outdated comment

* making it a URL

* Updating test name as per suggestion

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Updating documentation to be more explicit

And to follow the general guidelines

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fixing formatting

* `Fallback` now of type `InstantElectionProvider`
Some cleanups

* Merging types into one type with generics

* Removing `ConstUSize` and use `ConstU32`

* cleaning up the code

* deprecating `OnChainSequentialPhragmen`
Renaming it to `UnboundedSequentialPhragmen` which should only be used
at genesis and for testing.
Use preferrably `BoundedOnChainSequentialPhragmen`

* Amending docs

* Adding some explicit imports

* Implementing generic `BoundedOnchainExecution`
Removing the deprecated `OnChainSequentialPhragmen`

* Use the right Balancing strategy

* Refactoring `onchain::Config`
Creating `onchain::ExecutionConfig`

* Merge master

* fmt

* Name cleanups after review suggestions

* cosmetics

* renaming `instant_elect` to `elect_with_bounds`
Other corresponding changes as per @kianenigma feedback

* `BoundedOnchainExecution` -> `BoundedExecution`
And `UnboundedOnchainExecution` -> `UnboundedExecution`

* feedback from kian

* fmt + unneeded import

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
2022-03-25 20:15:50 +00:00
Kian Paimani 661d0ea5bb Store validator self-vote in bags-list, and allow them to be trimmed for election (#10821)
* Implement the new validator-in-bags-list scenario + migration

* Apply suggestions from code review

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* some review comments

* guard the migration

* some review comments

* Fix tests 🤦‍♂️

* Fix build

* fix weight_of_fn

* reformat line width

* make const

* use weight of fn cached

* SortedListProvider -> VoterList

* Fix all build and docs

* check post migration

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
2022-03-23 14:17:26 +00:00
Zeke Mostov 3f5e0baf4a Only maintain at most 1 UnlockChunk per era (#10670)
* Only maintain at most 1 `UnlockChunk` per era

* Bound `unlocking`

* Run cargo +nightly-2021-10-29 fmt

* Make benchmarks stuff compile

* Update frame/staking/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Remove DerefMut; Implement neccesary methods directly

* Doc comments for new BoundedVec methods

* Fix benchmarks

* wip bonded_vec macro

* Correct rust doc

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update staking::Config impls

* Add MaxUnlockingChunks to more places

* Use defensive saturating add

* FMT

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2022-03-01 23:31:13 +00:00
Kian Paimani 38d94d6323 Use proper bounded vector type for nominations (#10601)
* Use proper bounded vector type for nominations

* add docs and tweak chill_other for cleanup purposes

* Fix the build

* remove TODO

* add a bit more doc

* even more docs
gushc

* Update frame/staking/src/pallet/mod.rs

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* Update frame/staking/src/pallet/mod.rs

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* Fix the nasty bug

* also bound the Snapshot type

* fix doc test

* document bounded_vec

* self-review

* remove unused

* Fix build

* frame-support: repetition overload for bounded_vec

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fix

* remove the need to allocate into unbounded voters etc etc

* Don't expect

* unbreal the build again

* handle macro a bit better

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
2022-01-25 14:44:10 +00:00
Bastian Köcher f3662b4bba Happy new year 2022 (#10573) 2022-01-03 09:22:14 +01:00
dharjeezy 1b0be8ae06 Replace parameter_types with ConstU32 &c. (#10402)
* remove parameter types and use const type

* remove parameter types and use const type

* Delete {

* Delete count,

* refractor for beefy, benchmarking, child bounties, and collective pallets

* refractor for pallet contracts

* refractor for elections

* refractor for more pallets

* fix CI issues

* fix CI issues

* fix CI issues

* fix CI issues

* remove warning to fix CI issue

* remove warning to fix CI issue
refractor for pallet preimage

* remove warning to fix CI issue
refractor for pallet proxy

* remove warning to fix CI issue
refractor for pallet recovery
refractor for pallet randomness-collective-flip

* remove warning to fix CI issue
refractor for pallet scored-pool
refractor for pallet scheduler
refractor for pallet session

* remove warning to fix CI issue
refractor for pallet society, support, system, timestamp, tips

* remove warning to fix CI issue
refractor for pallet transaction_payment, transaction_storage, treasury, uniques, utility

* remove warning to fix CI issue

* cargo +nightly fmt

* CI fix

* more param refractor on beefy-mmr

* refractor for beefy

* Update frame/babe/src/mock.rs

* Update frame/babe/src/mock.rs

* Update frame/bounties/src/tests.rs

* Update frame/tips/src/tests.rs

* Delete mock.rs

* Update frame/examples/basic/src/tests.rs

* Apply suggestions from code review

* Update frame/im-online/src/mock.rs

* Update frame/im-online/src/mock.rs

* Update frame/offences/benchmarking/src/mock.rs

* Update frame/session/benchmarking/src/mock.rs

* Update frame/support/test/tests/pallet_compatibility.rs

* Update frame/support/test/tests/pallet_compatibility_instance.rs

* Update frame/treasury/src/tests.rs

* Update test-utils/runtime/src/lib.rs

* some cleanup

* fmt

* remove unused

Co-authored-by: Damilare <dakinlose@teamapt.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2021-12-16 03:06:11 +00:00
Gavin Wood 1e24e45ea1 Remove Default bound for AccountId (#10403)
* Remove Default for AccountId

* More removals of default

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/authorship/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* More work

* More work

* Remove old code

* More work

* pallet-asset-tx-payment

* tips

* sc-consensus-babe

* sc-finality-grandpa

* sc-consensus-babe-rpc

* sc-cli

* make npos crates accept non-default account (#10420)

* minimal changes to make npos pallets all work

* make this pesky reduce.rs a bit cleaner

* more work

* more work

* Tests build

* Fix imonline tests

* Formatting

* Fixes

* Fixes

* Fix bench

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Formatting

* Fixes

* Formatting

* Fixes

* Formatting

* Fixes

* Formatting

* Fixes

* Formatting

* Update client/keystore/src/local.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/finality-grandpa/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/keystore/src/local.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/keystore/src/local.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/staking/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update frame/staking/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update primitives/runtime/src/traits.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Formatting

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
2021-12-13 15:03:59 +01:00
Gavin Wood 3dd8f83a3a Insufficient asset quota and deposits (#10382)
* Allow asset accounts to exist by deposit

* Place limit on consumers (and therefore freebie asset accounts)

* Maximum number of assets

* Fixes

* Fixes

* Formatting

* Docs

* Formatting

* Destroyed assets are properly tidied

* Update frame/assets/src/types.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Docs

* Docs

* Formatting

* Docs

* Docs

* Fixes

* Fixes

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2021-12-09 13:22:54 +01:00
Kian Paimani 2fafb9546e Reduce the execution time of some tests (#10377)
* Reduce the execution time of some tests

* Fix

* Fix build

* fmt
2021-11-28 12:47:33 +00:00
Qinxuan Chen 0b224d1b60 pallet-session: Migrate the historical part to the new pallet macro (#9878)
* Migrate session-historical to the new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* pallet-session: Migrate the historical part to the new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix staking test runtime

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Update frame/session/src/historical/mod.rs

* Update frame/session/src/historical/mod.rs

* update migration doc

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* use hardcoded prefix for migration v1

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* cargo +nightly-2021-11-08 fmt

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2021-11-17 16:16:28 +09:00
André Silva 7e5c022aea staking: only disable slashed validators and keep them disabled for whole era (#9448)
* session: remove disabled validators threshold logic

* staking: add logic to track offending validators

* staking: disable validators for the whole era

* frame: fix tests

* staking: add tests for disabling validators handling

* staking: fix adding offending validator when already slashed in era

* address review comments

* session, staking: add comments about sorted vecs

Co-authored-by: Andronik Ordian <write@reusable.software>
2021-10-06 16:22:34 +00:00
ucover f8ce186496 Test each benchmark case in own #[test] (#9860)
* Generate one #[test] fn per bench case.

* Update benchmark macro syntax in frame pallets.

* Explain new benchmark macro syntax in example pallet.

* support with and without a semicolon

* update pallets to use individual tests

* migrate staking too

* migrate more pallets

* fix up democracy and use individual tests

* Fix comment

* Put println message in panic

* Remove `another_set_dummy` from doc

`another_set_dummy` is not present in the benchmarking.rs (anymore).

* Update doc for benchmarks macro

* Update doc for impl_benchmark_test_suite macro

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-10-01 08:17:26 +00:00
Qinxuan Chen 7f550d6dd2 Migrate pallet-session to the new pallet macro (#9796)
* Migrate pallet-session to the new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Remove old macros

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2021-09-28 03:12:57 +00:00
Zeke Mostov 669972a171 Implement pallet-bags-list and its interfaces with pallet-staking (#9507)
* remove extra whitespace

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* only emit rebag event on success

* add doc explaining the term voter

* revamp/simplify rebag test

* ensure genesis accounts are placed into the correct nodes/bags

* bond_extra implicitly rebags

* types at top; doc public type

* start sketching out adjustable thresholds

* add integrity test for voter bag threshold requirements

* get rid of BagIdx

This reorganizes bag storage such that bags are always referred to
by their upper threshold. This in turn means that adding and removing
bags is cheaper; you only need to migrate certain voters, not all of them.

* implement migration logic for when the threshold list changes

* start sketching out threshold proc macros

* further refine macro signatures

* WIP: implement make_ratio macro

* start rethinking the process of producing threshold lists

The macro approach seems to be a non-starter; that only really works
if we're throwing around numeric literals everywhere, and that's just
not nice in this case.

Instead, let's write helper functions and make it really easy to
generate the tables in separate, permanent files, which humans
can then edit.

* write helper functions to emit voter bags module

* WIP: demo generating voter bags for a realistic runtime

This isn't yet done, becuase it seems to take a Very Long Time to run,
and it really shouldn't. Need to look into that.

Still, it's a lot closer than it was this morning.

* rm unnecessary arg_enum

* fix voter bags math

Turns out that when you're working in exponential space, you need
to divide, not subtract, in order to keep the math working properly.

Also neaten up the output a little bit to make it easier to read.

* add computed voter bags thresholds to node

* fixup some docs

* iter from large bags to small, fulfuilling the contract

* make tests compile

* add VoterBagThresholds to some configs

* ensure that iteration covers all voters even with implied final bag

* use sp_std::boxed::Box;

* fix unused import

* add some more voter bags tests

* file_header.txt

* integrity test to ensure min bag exceeds existential weight

* add more debug assertions about node list length

* rm unused imports

* Kian enters

* Update frame/election-provider-support/src/onchain.rs

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>

* Suggestions for #9081 (Store voters in unsorted bags) (#9328)

* Add some debug asserts to node::get and remove_node

* Improve the debug asserts in remove_node

* improve debug asserts

* Space

* Remove bad assertions

* Tests: WIP take_works

* Take test

* Doc comment

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Test storage is cleaned up;

* formatting

* Switch to simpler thresholds

* Update the storage cleanup test

* Remove hardcoded values from benchmark to make it more robust

* Fix tests to acces bags properly

* Sanity check WIP; tests failing

* Update sanity checks to be more correct

* Improve storage cleanup tests

* WIP remote_ext_tests

* Some notes on next steps

* Remove some stuff that was for remote-ext tests

* Some more cleanup to reduce diff

* More :clean:

* Mo cleanin

* small fix

* A lot of changes from kian

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>

* merge fallout

* Run cargo +nightly fmt

* Fix a bunch of stuff, remove not needed runtime arg of make-bags

* add logs

* Glue the new staking bags to the election snapshot (#9415)

* Glue the new staking bags to the election snapshot

* add CheckedRem (#9412)

* add CheckedRem

* fix

* Run fmt

* Test comment

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: emostov <32168567+emostov@users.noreply.github.com>

* Update node runtime with VoterSnapshotPerBlock

* Unit test for pallet-staking unsorted bags feature (targets #9081) (#9422)

* impl notional_bag_for_works

* Add tests: insert_as_works & insert_works

* Impl test: remove_works

* Trivial cleaning

* Add test: update_position_for_works

* Write out edge case; probably can delete later

* Add test: bags::get_works

* Add test: remove_node_happy_path_works

* Add test: remove_node_bad_paths_documented

* WIP: voting_data_works

* done

* Improve test voting_data_works

* Add comment

* Fill out test basic_setup_works

* Update: iteration_is_semi_sorted

* Improve remove_works

* Update update_position_for_works; create set_ledger_and_free_balance

* Improve get_works

* Improve storage clean up checks in remove test

* Test: impl rebag_works + insert_and_remove_works

* forgot file -  Test: impl rebag_works + insert_and_remove_works

* Small tweak

* Update voter_bags test to reflect unused bags are removed

* Unbond & Rebond: do_rebag

* Prevent infinite loops with duplicate tail insert

* Check iter.count on voter list in pre-migrate

* undo strang fmt comment stuff

* Add in todo

Co-authored-by: kianenigma <kian@parity.io>

* Try prepare for master merge

* Reduce diff

* Add comment for test to add

* Add in code TODO for update_position efficiency updates

* Initial impl compiles

* impl StakingVoterListStub

* Sample impl<T: Config> VoterListProvider<T> for VoterList<T>

* impl VoterListProvider for voter-bags

* WIP integrate pallet-voter-bags to staking mock

* the trait `pallet_staking::pallet::pallet::Config` is not implemented for `mock::Test`

* random

* pushing my stuff

* Mock working

* WIP voter list tests

* Add bag insert, remove tests

* Add test for bag insert and remove

* Add remaining tests for VoterList

* Add tests for node

* Add rebag works

* Add rebag extrinsic tests

* Rename to bags-list and name the list .. list!

* Rename VoterBagThresholds => BagThresholds

* Add test count_works

* Test on_update_works

* test sanity check

* a round of test fixes

* push a lot of changes

* my last changes

* all bags-list test work; fmt

* Beautify some tests

* Doc comment for bags-list

* Add insert warnings

* Setup initial benchmark

* Wire up WeightInfo

* is_terminal wip; everything broken!

* Is terminal working

* add TODOs for remove_node

* clean up remoe_node

* Fix all staking tests

* retire VoterBagFor

* commit

* bring in stashed changes

* save

* bench pipeline works now, but I can't run stuff

* sabe

* benchmarks now run, but we have a failure

* WIP: Wire up make_bags

* bags-thresholds compiles

* Fix most build issues

* This will fix all the tests

* move bag thresholds to bags-list

* Move bag-thresholds bin to within pallet-bags

* Remove some unnescary TODOs

* Impl tets wrong_rebag_is_noop

* assert remove is a noop with bad data

* Assert integrity test panics

* Return an error when inserting duplicates

* Update to handle error in staking pallet when inserting to list

* Test contains and on_insert error

* Test re-nominate does not mess up list or count

* Everything builds and works, only the benchmark...

* fuck yeah benchmarks

* more cleanup, more hardening.

* use the bags list again

* fix benhc

* Some questions and changs for List::migration

* Fix migration removed_bags and new_bags usage

* Some trivial aesthetic changes

* Some more trivial changes

* tiny changes/

* mega rename

* fix all tests and ci build

* nit

* Test and fix migration

* nit

* fmt

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fmt

* remove unused

* make a few things pub

* make node also pub.. for remote-ext test

* Fix all tests again

* Force bag changes in relevant benchmarks (targets #9507) (#9529)

* force rebag for unbond, rebond, and bond_extra

* nit

* Improve utils

* fmt

* nits

* Move generate_bags to its own pallet

* Get runtime-benchmarks feature setup with prepare_on_update_benchmark

* Withdraw unbonded kill working

* Nominate bench working

* some cleanup

* WIP

* update to check head pre & post conditions

* Add some post condition verification stuff for on_remove

* Update nominate

* fmt

* Improvements

* Fix build

* fix build with polkadot companion

* Update frame/bags-list/src/list/tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* move generate-bag from frame to utils

* wip

* refactor WIP

* WIP save

* Refactor working

* some variable renaming

* WIP: prepare to remove head checks

* Finish MvP refactor

* Some cleanup

* Soem more cleanup

* save

* fix a lot of stuff

* Update client/db/src/bench.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Apply suggestions from code review

* Apply suggestions from code review

* Fix some issues that came from trying to merge comments on github

* some small changes

* simplify it

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Build works

* Apply suggestions from code review

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Apply suggestions from code review

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Remove commented out debug assert

* Remove some unused deps and some unused benchmarking stuff

* Fix stakings ElectionDataProvider clear

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_bags_list --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/bags-list/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_bags_list --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/bags-list/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_bags_list --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/bags-list/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_bags_list --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/bags-list/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Improving staking pallet-bags-list migration

* fix build and some comments;

* comment

* Reduce visibility in bags list components

* make node.bag_upper only accesible to benchmarks

* Address some feedback; comments updates

* use nominator map comment

* fix vec capacity debug assert

* Apply suggestions from code review

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* clarify VoterSnapshotPerBlock

* Reduce diff on create_validators by wrapping with_seed

* Some small improvements to staking benches

* Soem comment updates

* fix vec capacity debug assert ... for real this time

* Reduce ListBags viz

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Remove supports_eq_unordered & Support eq_unordered

* Update utils/frame/generate-bags/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Make total-issuance & minimium-balance CLI args; Dont use emptry ext

* Improve docs for generate bags CLI args

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Don't use default bags weight in node runtime

* Feature gating sanity_check not working

* Feature gate sanity check by creating duplicate fns

* Fix line wrapping

* Document VoteWeightProvider

* Make bags ext-builder not a module

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* use pallet_bags_list instead of crate in mock

* Make get_bags test helper fn live in List

* use remove_from_storage_unchecked for node removal

* Remove count of ids removed in remove_many

* Add node sanity check, improve list sanity check

* Do a list sanity check after on_update

* List::migrate: clean up debug assert, exit early when no change in thresholds

* Improve public doc comments for pallet_bags_list::list::List

* Improve public doc comments for pallet_bags_list::list::List

* Update generate bags docs

* Fix grammar in bags-list benchmark

* Add benchmark case for `rebag` extrinsic

* Add count parameter to List::clear; WIP adding MaxEncodedLen to list'

* MaxEncodeLen + generate_storage_info not working for Bag or Node

* Get MaxEncodeLen derive to work

* Try to correctly feature gate SortedListProvider::clear

* Use u32::MAX, not u32::max_value

* Get up to nominators_quota noms

* SortedListProvider::clear takes an Option

* Eplicitly ignore SortedListProvider return value

* Fix doc comment

* Update node-runtime voter snapshot per block

* Add test get_max_len_voters_even_if_some_nominators_are_slashed

* Add test only_iterates_max_2_times_nominators_quota

* Fix generate bags cargo.toml

* use sp_std vec

* Remove v8 migration hooks from pallet-staking

* Update npos trait

* Try respect line width

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_bags_list --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/bags-list/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Update frame/bags-list/src/benchmarks.rs

* Unwrap try-runtime error; remove sortedlistprovider pre upgrade len  check

* trigger ci

* restore

* trigger ci

* restore

* trigger ci

* revert

* trigger ci

* revert

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Peter Goodspeed-Niklaus <peter.r.goodspeedniklaus@gmail.com>
Co-authored-by: kianenigma <kian@parity.io>
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2021-09-17 02:25:21 +00:00
Kian Paimani 056fd9b8a8 Recursive election provider as fallback (#9648)
* Recursive election provider as fallback

* minor fix

* Fix integrity tests

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>

* Fix everything

* fmt again

* Fix test

* Fix state machine warning

* Fix build

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
2021-09-12 14:38:32 +00:00
Kian Paimani 7a32c3504d remove the uselsss weight return type from election provider API (#9569)
* remove the uselsss weight return type from election provider API

* fix everything, should be ready for final benchmark

* simplify on_init a bit furhter

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* remove unwraps

* fmt

* Update lock file

* whitelist block weight

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fix warning

Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
2021-08-19 07:45:54 +00:00
Gavin Wood bdda3ed612 Remove Filter and use Contains instead (#9514)
* Remove Filter and use Contains instead

* Fixes

* Formatting

* Update docs/Upgrading-2.0-to-3.0.md

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Typo

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2021-08-07 19:26:40 +00:00
Squirrel aafe64315a Remove extra commas made redundent after rustfmt (#9404)
* Remove extra commas made redundent after rustfmt
2021-07-22 11:06:17 +01:00
Bastian Köcher 7b56ab15b4 Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
2021-07-21 14:32:32 +00:00
Alexander Theißen e01ac8cea0 contracts: Allow contracts to dispatch calls into the runtime (#9276)
* contracts: Allow contracts to dispatch calls into the runtime

* Fix RPC tests

* Fix typo

* Replace () by AllowAllFilter and DenyAllFilter

* Add rust doc

* Fixup for `()` removal

* Fix lowest gas calculation

* Rename AllowAllFilter and DenyAllFilter

* Updated changelog
2021-07-12 20:40:27 +00:00
Guillaume Thiolliere ebf5e771fc staking/election: prolonged era and emergency mode for governance submission. (#8912)
* Implementation but weird initial era in tests

* Emergency mode for elections. (#8918)

* do some testing, some logging.

* some testing apparatus

* genesis election provider (#8970)

* genesis election provider

* fix historical stuff

* Fix test

* remove dbg

* Apply suggestions from code review

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* capitalize comment and name without conflict

* fix log

* Update frame/election-provider-multi-phase/src/lib.rs

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* apply suggestion on tests

* remove testing modifications

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Dmitry Kashitsyn <korvin@deeptown.org>

* apply suggestion

* fix master merge

Co-authored-by: kianenigma <kian@parity.io>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Dmitry Kashitsyn <korvin@deeptown.org>
2021-06-14 14:02:45 +00:00
Shaun Wang 0869fdf9aa Migrate pallet-staking to pallet attribute macro (#9083)
* Migrate staking pallet to pallet attribute macro.

* HistoryDepth default value.

* Make all calls public.

* Update frame/staking/src/lib.rs

* remove externalities again

* Update lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-06-12 00:22:40 +00:00
Xiliang Chen 223529e4dd Named reserve (#7778)
* add NamedReservableCurrency

* move currency related trait and types into a new file

* implement NamedReservableCurrency

* remove empty reserves

* Update frame/support/src/traits.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* fix build

* bump year

* add MaxReserves

* repatriate_reserved_named should put reserved fund into named reserved

* add tests

* add some docs

* fix warning

* Update lib.rs

* fix test

* fix test

* fix

* fix

* triggier CI

* Move NamedReservableCurrency.

* Use strongly bounded vec for reserves.

* Fix test.

* remove duplicated file

* trigger CI

* Make `ReserveIdentifier` assosicated type

* add helpers

* make ReserveIdentifier assosicated type

* fix

* update

* trigger CI

* Apply suggestions from code review

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* trigger CI

* Apply suggestions from code review

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Gavin Wood <i@gavwood.com>
Co-authored-by: Shaun Wang <spxwang@gmail.com>
2021-06-04 09:32:46 +02:00
Gavin Wood 643d2b669f Introduce OnSetCode type into system config trait. (#8496)
* Introduce OnSetCode type into system config trait.

* Docs.

* Fixes

* Fixes
2021-04-01 12:20:24 +00:00
Kian Paimani f571023df3 Make the number of nominations configurable (#8368)
* Base features and traits.

* pallet and unsigned phase

* Undo bad formattings.

* some formatting cleanup.

* Small self-cleanup.

* Make it all build

* self-review

* Some doc tests.

* Some changes from other PR

* Fix session test

* Update Cargo.lock

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Some review comments

* Rename + make encode/decode

* Do an assert as well, just in case.

* Fix build

* Update frame/election-provider-multi-phase/src/unsigned.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Las comment

* fix staking fuzzer.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Add one last layer of feasibility check as well.

* Last fixes to benchmarks

* Some more docs.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Some nits

* It all works

* Some self cleanup

* Update frame/staking/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* remove most todos.

* Round of self-review.

* Fix migration

* clean macro

* Revert wrong merge

* Make the number of nominations configurable

* Self reivew

* renmae.

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
2021-03-25 09:15:28 +00:00
Kian Paimani 0c69651830 Decouple Staking and Election - Part 2.1: Unleash Multi Phase (#8113)
* Base features and traits.

* pallet and unsigned phase

* Undo bad formattings.

* some formatting cleanup.

* Small self-cleanup.

* Make it all build

* self-review

* Some doc tests.

* Some changes from other PR

* Fix session test

* Update Cargo.lock

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Some review comments

* Rename + make encode/decode

* Do an assert as well, just in case.

* Fix build

* Update frame/election-provider-multi-phase/src/unsigned.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Las comment

* fix staking fuzzer.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Add one last layer of feasibility check as well.

* Last fixes to benchmarks

* Some more docs.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Some nits

* It all works

* Some self cleanup

* Update frame/staking/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* remove most todos.

* Round of self-review.

* Fix migration

* clean macro

* Revert wrong merge

* remove fuzzer stuff.

* Self review

* Update frame/staking/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* review comments

* add logs

* Add tests to demonstrate the capacity of the snapshot.

* Replace upgrade

* Last touches

* Fix benchmakrs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* remove unused stuff

* Fix tests.

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
2021-03-20 08:43:47 +00:00
Shaun Wang 2e5522444a Replace 'Module' with 'Pallet' in construct_runtime macro (#8372)
* Use 'Pallet' struct in construct_runtime.

* Fix genesis and metadata macro.

* Fix 'Pallet' type alias.

* Replace 'Module' with 'Pallet' for all construct_runtime use cases.

* Replace more deprecated 'Module' struct.

* Bring back AllModules and AllPalletsWithSystem type, but deprecate them.

* Replace deprecated 'Module' struct from merge master.

* Minor fix.

* Fix UI tests.

* Revert UI override in derive_no_bound.

* Fix more deprecated 'Module' use from master branch.

* Fix more deprecated 'Module' use from master branch.
2021-03-18 08:50:08 +00:00
Gavin Wood 363db4f086 staking: Flexible generation of reward curve and associated tweaks (#8327)
* Initial abstraction

* Alter rest of APIs

* Fixes

* Some extra getters in Gilt pallet.

* Refactor Gilt to avoid u128 conversions

* Simplify and improve pow in per_things

* Add scalar division to per_things

* Renaming from_fraction -> from_float, drop _approximation

* Fixes

* Fixes

* Fixes

* Fixes

* Make stuff build

* Fixes

* Fixes

* Fixes

* Fixes

* Update .gitignore

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/gilt/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/gilt/src/mock.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fixes

* Fixes

* Fixes

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2021-03-16 12:03:58 +00:00
Kian Paimani b6c626399e Audit fixes for election/staking decoupling part 2 (#8167)
* Base features and traits.

* pallet and unsigned phase

* Undo bad formattings.

* some formatting cleanup.

* Small self-cleanup.

* Make it all build

* self-review

* Some doc tests.

* Some changes from other PR

* Fix session test

* Update Cargo.lock

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Some review comments

* Rename + make encode/decode

* Do an assert as well, just in case.

* Fix build

* Update frame/election-provider-multi-phase/src/unsigned.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Las comment

* fix staking fuzzer.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Add one last layer of feasibility check as well.

* Last fixes to benchmarks

* Some more docs.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Some nits

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Fix doc

* Mkae ci green

* Audit fixes for election-provider: part 2 signed phase.

* Fix weight

* Some grumbles.

* Try and weigh to get_npos_voters

* Fix build

* Fix line width

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Fix tests.

* Fix build

* Reorg some stuff

* More reorg.

* Reorg done.

* Fix build

* Another rename

* Fix build

* Update frame/election-provider-multi-phase/src/mock.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* nit

* better doc

* Line width

* Fix build

* Self-review

* Self-review

* Fix wan

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fix build and review comments.

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* add comment

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
2021-03-16 12:44:30 +01:00
Kian Paimani 7205eea40d Decouple Staking and Election - Part 2 Unsigned Phase (#7909)
* Base features and traits.

* pallet and unsigned phase

* Undo bad formattings.

* some formatting cleanup.

* Small self-cleanup.

* Make it all build

* self-review

* Some doc tests.

* Some changes from other PR

* Fix session test

* Update Cargo.lock

* Update frame/election-provider-multi-phase/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Some review comments

* Rename + make encode/decode

* Do an assert as well, just in case.

* Fix build

* Update frame/election-provider-multi-phase/src/unsigned.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Las comment

* fix staking fuzzer.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Add one last layer of feasibility check as well.

* Last fixes to benchmarks

* Some more docs.

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Some nits

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Fix doc

* Mkae ci green

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
2021-02-23 15:46:17 +01:00
Peter Goodspeed-Niklaus 44d5aba80d Create a macro which automates creation of benchmark test suites. (#8104)
* Create a macro which automates creation of benchmark test suites.

* bump impl_version

* allow unused on test_bench_by_name

* use proper doctest ignore attribute

* Explicitly hand the Module to the test suite

Much better practice than depending on it showing up implicitly in
the namespace.

* explicitly import what we need into `mod tests`

* bench_module is `ident` not `tt`

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* allow end users to specify arguments for new_test_ext

This turned out to be surprisingly easy. On reflection, it turns out
that of course the compiler can't eagerly evaluate the function call,
but needs to paste it in everywhere desired.

* enable explicitly specifying the path to the benchmarks invocation

also enable optional trailing commas

* Revert "bump impl_version"

This reverts commit 0209e4de33fd43873f8cfc6875815d0fd6151e63.

* list failing benchmark tests and the errors which caused the failure

* harden benchmark tests against internal panics

* suppress warning about ignored profiles

unfortunately, setting the profile here doesn't do anything; we'd
need to set it in every leaf package anyway. However, as this was
just making the default explicit anyway, I think it's safe enough
to remove entirely.

* impl_benchmark_test_suite for assets

* impl_benchmark_test_suite for balances

* impl_benchmark_test_suite for bounties

* impl_benchmark_test_suite for Collective

* impl_benchmark_test_suite for Contracts

* impl_benchmark_test_suite for Democracy

* don't impl_benchmark_test_suite for Elections-Phragmen

* impl_benchmark_test_suite for Identity

Note that Identity tests currently fail. They failed in an identical
way before this change, so as far as I'm concerned, the status quo is
good enough for now.

* impl_benchmark_test_suite for ImOnline

* impl_benchmark_test_suite for indices

For this crate also, the test suite fails identically with and without
this change, so we can say that this change is not the cause of the
tests' failure to compile.

* impl_benchmark_test_suite for lottery

* impl_benchmark_test_suite for merkle-mountain-range

* impl_benchmark_test_suite for Multisig

These tests fail identically with and without the change, so the change
seems unlikely to be the origin of the failures.

* impl_benchmark_test_suite for offences

* impl_benchmark_test_suite for Proxy

Fails identically with and without this change.

* impl_benchmark_test_suite for scheduler

* impl_benchmark_test_suite for session

It turns out to be important to be able to exclude items marked
`#[extra]` sometimes. Who knew?

* impl_benchmark_test_suite for staking

* impl_benchmark_test_suite for system

* impl_benchmark_test_suite for timestamp

* impl_benchmark_test_suite for tips

* impl_benchmark_test_suite for treasury

* impl_benchmark_test_suite for utility

Note that benchmark tests fail identically before and after this change.

* impl_benchmark_test_suite for vesting

* fix wrong module name in impl_benchmark_test_suite in Offences

* address line length nits

* enable optional keyword argument: exec_name

Took a _lot_ of macro-wrangling to get the functionality that I want,
but now you have the option to pass in

```rust
impl_benchmark_test_suite!(
	Elections,
	crate::tests::ExtBuilder::default().desired_members(13).desired_runners_up(7),
	crate::tests::Test,
	exec_name = build_and_execute,
);
```

and have it expand out properly. A selected fragment of the expansion:

```rust
        fn test_benchmarks() {
            crate::tests::ExtBuilder::default()
                .desired_members(13)
                .desired_runners_up(7)
                .build_and_execute(|| {
```

* get rid of dead code

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
2021-02-16 10:01:20 +01:00
Guillaume Thiolliere 0ed683ca13 Use construct_runtime in tests (#8059)
* impl some more

* add serde

* remove unused

* fix staking fuzz

* fix system bench

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2021-02-06 20:12:46 +00:00
Andrew Jones 71ef82afbc Migrate frame-system to pallet attribute macro (#7898)
* PRINT_PALLET_UPGRADE=1 cargo check -p frame-system

* Copy attributes, imports, mods and type defs

* Copy Config trait

* Annotate constants

* Tabify

* Migrate hooks

* Upgrade template rename interface to hooks

* Migrate pallet call

* Migrate Event

* Migrate Error

* Migrate Origin

* Remove optional validate_unsigned

* Remove remaining TODO_MAYBE_WHERE_CLAUSE

* Overwrite original lib.rs with migrated lib2.rs.

* Add required Event IsType constraint

* Add disable supertrait check

* Fix leftover Trait trait

* Add missing pallet prefix for weight attributes

* Add missing Error type parameter

* Add missing Hooks type parameter

* Private call visibility, restore original helper types and helpers etc

* Fix hooks type parameter

* Rename RawEvent to Event

* Add missing storage type annotations

* Remove unused imports

* Add GenesisConfig helpers for compat

* Fix unused import warnings

* Update frame/support/procedural/src/storage/print_pallet_upgrade.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Fix test errors and warnings

* Fix remaining errors and warnings

* Apply review suggestion: fix formatting

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Apply review suggestion: annotate BlockLength as constant

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Apply review suggestion: add triling comma

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Apply review suggestion: add triling comma

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Apply review suggestion: add trailing comma

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Apply review suggestion: fix storage type indentation

* Apply review suggestion: remove redundant Origin type alias

* Add missing codec derives for BlockLength

* Restore module docs

* Module -> Pallet renamel

* Revert "Update frame/support/procedural/src/storage/print_pallet_upgrade.rs"

This reverts commit d2a2d5b6

* Apply review suggestion: merge crate imports

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

* Revert "Upgrade template rename interface to hooks"

This reverts commit 306f0239

* Single line import

* Refactor generated genesis build

* Import sp_io::storage

* Revert previous, fully qualify sp_io::storage

* Fix ui tests

* Fix errors after merge, missing changes

* Set UpgradedToDualRefCount to true in genesis build

* Annotated Runtime version with constant, exposing it via metadata

* Add metadata attribute

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
2021-01-20 10:48:19 +00:00
Gavin Wood f1d36a7103 Introduces account existence providers reference counting (#7363)
* Initial draft

* Latest changes

* Final bits.

* Fixes

* Fixes

* Test fixes

* Fix tests

* Fix babe tests

* Fix

* Fix

* Fix

* Fix

* Fix

* fix warnings in assets

* Fix UI tests

* fix line width

* Fix

* Update frame/system/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/system/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fix

* fix unused warnings

* Fix

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Fix

* fix slash and comprehensive slash test

* fix reserved slash and comprehensive tests

* check slash on non-existent account

* Revert "Fix UI tests"

This reverts commit e0002c0f13442f7d0c95a054a6c515536328a4a0.

* Fix

* Fix utility tests

* keep dispatch error backwards compatible

* Fix

* Fix

* fix ui test

* Companion checker shouldn't be so anal.

* Fix

* Fix

* Fix

* Apply suggestions from code review

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Update frame/balances/src/lib.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* return correct slash info when failing gracefully

* fix missing import

* Update frame/system/src/lib.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Fix

* Update frame/balances/src/tests_local.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Fixes

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
2021-01-16 18:47:28 +01:00