Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Implement pallet-bags-list and its interfaces with pallet-staking #9507

Merged
290 commits merged into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
290 commits
Select commit Hold shift + click to select a range
ee7959d
remove extra whitespace
coriolinus Jun 30, 2021
f58bb3a
only emit rebag event on success
coriolinus Jun 30, 2021
1cd8730
Merge branch 'prgn-nominator-unsorted-bags' of github.com:paritytech/…
coriolinus Jun 30, 2021
3c92eda
add doc explaining the term voter
coriolinus Jun 30, 2021
22bc615
revamp/simplify rebag test
coriolinus Jun 30, 2021
4092fa8
ensure genesis accounts are placed into the correct nodes/bags
coriolinus Jun 30, 2021
2182abe
bond_extra implicitly rebags
coriolinus Jun 30, 2021
472baa9
types at top; doc public type
coriolinus Jun 30, 2021
f1e7fe7
start sketching out adjustable thresholds
coriolinus Jun 29, 2021
16e4774
add integrity test for voter bag threshold requirements
coriolinus Jun 29, 2021
2a4ebf7
get rid of BagIdx
coriolinus Jun 30, 2021
cc6d0df
implement migration logic for when the threshold list changes
coriolinus Jul 1, 2021
88195fe
start sketching out threshold proc macros
coriolinus Jul 1, 2021
70848ea
further refine macro signatures
coriolinus Jul 1, 2021
b630321
WIP: implement make_ratio macro
coriolinus Jul 2, 2021
8ce3bc0
start rethinking the process of producing threshold lists
coriolinus Jul 2, 2021
202def0
write helper functions to emit voter bags module
coriolinus Jul 2, 2021
4da8204
WIP: demo generating voter bags for a realistic runtime
coriolinus Jul 2, 2021
498ab65
rm unnecessary arg_enum
coriolinus Jul 2, 2021
734ea86
fix voter bags math
coriolinus Jul 5, 2021
3cfa8cf
add computed voter bags thresholds to node
coriolinus Jul 5, 2021
a05df69
fixup some docs
coriolinus Jul 5, 2021
2838b83
iter from large bags to small, fulfuilling the contract
coriolinus Jul 5, 2021
3f17724
make tests compile
coriolinus Jul 5, 2021
b73fd7f
add VoterBagThresholds to some configs
coriolinus Jul 5, 2021
c719c5c
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jul 5, 2021
4861789
ensure that iteration covers all voters even with implied final bag
coriolinus Jul 6, 2021
59041b7
use sp_std::boxed::Box;
coriolinus Jul 6, 2021
646f708
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jul 6, 2021
f5c8a4d
fix unused import
coriolinus Jul 6, 2021
5e05e3f
add some more voter bags tests
coriolinus Jul 7, 2021
dbf3a84
file_header.txt
coriolinus Jul 7, 2021
873005e
Merge remote-tracking branch 'origin/master' into prgn-nominator-unso…
coriolinus Jul 7, 2021
d5e0c8d
integrity test to ensure min bag exceeds existential weight
coriolinus Jul 9, 2021
dbfb951
add more debug assertions about node list length
coriolinus Jul 9, 2021
06e69a8
rm unused imports
coriolinus Jul 9, 2021
df75e66
Merge branch 'master' of github.com:paritytech/substrate into prgn-no…
kianenigma Jul 9, 2021
6f15cc3
Kian enters
kianenigma Jul 10, 2021
1b545e4
Update frame/election-provider-support/src/onchain.rs
kianenigma Jul 12, 2021
e0a00fd
Suggestions for #9081 (Store voters in unsorted bags) (#9328)
emostov Jul 21, 2021
008cacf
Merge master pre-fmt
emostov Jul 21, 2021
48ccfc9
merge fallout
emostov Jul 22, 2021
225eb47
Merge origin master with new formatting
emostov Jul 22, 2021
acc9183
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov Jul 22, 2021
1c56016
Run cargo +nightly fmt
emostov Jul 22, 2021
1f02cb4
Fix a bunch of stuff, remove not needed runtime arg of make-bags
kianenigma Jul 22, 2021
2f83f16
add logs
kianenigma Jul 22, 2021
abb61c1
Merge branch 'master' of github.com:paritytech/substrate into prgn-no…
kianenigma Jul 22, 2021
0df47b0
Glue the new staking bags to the election snapshot (#9415)
kianenigma Jul 23, 2021
c1c4fcd
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov Jul 23, 2021
2c5a20c
Merge branch 'master' of https://github.com/paritytech/substrate into…
emostov Jul 27, 2021
8706404
Update node runtime with VoterSnapshotPerBlock
emostov Jul 27, 2021
98a4b1f
Merge remote-tracking branch 'origin' into prgn-nominator-unsorted-bags
emostov Jul 27, 2021
ced6077
Unit test for pallet-staking unsorted bags feature (targets #9081) (#…
emostov Jul 28, 2021
da4814c
Try prepare for master merge
emostov Jul 28, 2021
d20278a
Try merge origin master
emostov Jul 28, 2021
530e4d2
Reduce diff
emostov Jul 28, 2021
99bd08b
Try merge origin master
emostov Jul 30, 2021
df990d3
Add comment for test to add
emostov Aug 1, 2021
1632747
Add in code TODO for update_position efficiency updates
emostov Aug 1, 2021
dc3328e
Try merge origin master
emostov Aug 2, 2021
97ca105
Initial impl compiles
emostov Aug 3, 2021
44538b6
impl StakingVoterListStub
emostov Aug 3, 2021
44dcc1d
Sample impl<T: Config> VoterListProvider<T> for VoterList<T>
emostov Aug 3, 2021
79b8dca
impl VoterListProvider for voter-bags
emostov Aug 3, 2021
b3d0330
WIP integrate pallet-voter-bags to staking mock
emostov Aug 3, 2021
4790ad5
the trait `pallet_staking::pallet::pallet::Config` is not implemented…
emostov Aug 3, 2021
abfc1de
random
emostov Aug 3, 2021
863e744
pushing my stuff
kianenigma Aug 3, 2021
5543005
merrged.
kianenigma Aug 3, 2021
e40efff
Mock working
emostov Aug 4, 2021
3d545a9
WIP voter list tests
emostov Aug 4, 2021
61f9af9
Add bag insert, remove tests
emostov Aug 4, 2021
8b273ad
Add test for bag insert and remove
emostov Aug 4, 2021
c6d41b5
Add remaining tests for VoterList
emostov Aug 4, 2021
bf65a34
Add tests for node
emostov Aug 4, 2021
123776c
Add rebag works
emostov Aug 4, 2021
2907816
Add rebag extrinsic tests
emostov Aug 4, 2021
286d07f
Rename to bags-list and name the list .. list!
emostov Aug 4, 2021
2b7dc5e
Rename VoterBagThresholds => BagThresholds
emostov Aug 4, 2021
7d6f221
Add test count_works
emostov Aug 4, 2021
b1f98e7
Test on_update_works
emostov Aug 4, 2021
6d1d77e
test sanity check
emostov Aug 4, 2021
333052a
a round of test fixes
kianenigma Aug 4, 2021
894da3f
push a lot of changes
kianenigma Aug 4, 2021
8757ac9
my last changes
kianenigma Aug 4, 2021
3ff99e1
all bags-list test work; fmt
emostov Aug 4, 2021
bf41958
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Aug 4, 2021
e7d40fc
Beautify some tests
emostov Aug 4, 2021
93a26f6
Doc comment for bags-list
emostov Aug 4, 2021
569064a
Add insert warnings
emostov Aug 4, 2021
c128ffd
Setup initial benchmark
emostov Aug 5, 2021
d093a72
Wire up WeightInfo
emostov Aug 5, 2021
5758bd3
is_terminal wip; everything broken!
emostov Aug 5, 2021
bf9197e
Is terminal working
emostov Aug 5, 2021
7510ac7
add TODOs for remove_node
emostov Aug 5, 2021
316eeb5
clean up remoe_node
emostov Aug 5, 2021
d9540de
Fix all staking tests
kianenigma Aug 5, 2021
ce85c12
retire VoterBagFor
kianenigma Aug 5, 2021
238bdd6
commit
kianenigma Aug 5, 2021
2f4e62c
bring in stashed changes
kianenigma Aug 5, 2021
30423d4
save
emostov Aug 5, 2021
b59ab38
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Aug 5, 2021
794fce0
bench pipeline works now, but I can't run stuff
kianenigma Aug 5, 2021
f5d9dc8
sabe
emostov Aug 5, 2021
cf2d1e7
Try merge
emostov Aug 5, 2021
c22e3fa
benchmarks now run, but we have a failure
kianenigma Aug 5, 2021
da3e0d5
WIP: Wire up make_bags
emostov Aug 5, 2021
49828f4
bags-thresholds compiles
emostov Aug 5, 2021
3e06c16
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Aug 5, 2021
5b1f237
Fix most build issues
kianenigma Aug 5, 2021
4a4b915
Merged
kianenigma Aug 5, 2021
8fa8e6d
This will fix all the tests
kianenigma Aug 5, 2021
54c250a
move bag thresholds to bags-list
emostov Aug 5, 2021
23fd0a5
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Aug 5, 2021
6d7bf29
Move bag-thresholds bin to within pallet-bags
emostov Aug 5, 2021
fb79356
Remove some unnescary TODOs
emostov Aug 5, 2021
dc2b593
Impl tets wrong_rebag_is_noop
emostov Aug 5, 2021
e68a9f2
assert remove is a noop with bad data
emostov Aug 5, 2021
16ff8ba
Assert integrity test panics
emostov Aug 6, 2021
4ff4551
Return an error when inserting duplicates
emostov Aug 6, 2021
89bdefb
Update to handle error in staking pallet when inserting to list
emostov Aug 6, 2021
168295e
Test contains and on_insert error
emostov Aug 6, 2021
4c3d689
Test re-nominate does not mess up list or count
emostov Aug 6, 2021
216718c
Everything builds and works, only the benchmark...
kianenigma Aug 6, 2021
b3424ed
fuck yeah benchmarks
kianenigma Aug 6, 2021
09e0106
more cleanup, more hardening.
kianenigma Aug 6, 2021
e3f5f91
use the bags list again
kianenigma Aug 6, 2021
7d78aaf
fix benhc
kianenigma Aug 6, 2021
ceb7066
Some questions and changs for List::migration
emostov Aug 6, 2021
b41564f
Fix migration removed_bags and new_bags usage
emostov Aug 6, 2021
93b4455
Some trivial aesthetic changes
emostov Aug 6, 2021
c086721
Some more trivial changes
emostov Aug 6, 2021
fa87906
tiny changes/
emostov Aug 7, 2021
928fa95
mega rename
kianenigma Aug 7, 2021
fe214d5
Upstream.into()
kianenigma Aug 7, 2021
db222f7
fix all tests and ci build
kianenigma Aug 7, 2021
70bfc53
nit
kianenigma Aug 7, 2021
f665ea3
Test and fix migration
emostov Aug 9, 2021
56b6e23
nit
emostov Aug 9, 2021
c09a2c0
fmt
emostov Aug 10, 2021
b3121e8
Try merge origin master
emostov Aug 10, 2021
b81cd60
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Aug 10, 2021
ddfe3c7
Master.into()
kianenigma Aug 13, 2021
9c7d77f
Try merge origin master
emostov Aug 13, 2021
601521f
fmt
kianenigma Aug 16, 2021
81b3aaa
remove unused
kianenigma Aug 16, 2021
0ac8b20
Merge branch 'master' of github.com:paritytech/substrate into zeke-vo…
kianenigma Aug 18, 2021
66f9eda
make a few things pub
kianenigma Aug 18, 2021
864d348
make node also pub.. for remote-ext test
kianenigma Aug 18, 2021
88b694c
Master.into()
kianenigma Aug 19, 2021
4c65bde
Fix all tests again
kianenigma Aug 19, 2021
d1588bf
Merge remote-tracking branch 'origin' into zeke-voter-bags-module
emostov Aug 19, 2021
16bcd61
Merge branch 'master' of github.com:paritytech/substrate into zeke-vo…
kianenigma Aug 24, 2021
418bb85
Merge branch 'zeke-voter-bags-module' of github.com:paritytech/substr…
kianenigma Aug 24, 2021
bd835d4
Force bag changes in relevant benchmarks (targets #9507) (#9529)
emostov Aug 28, 2021
01dbd02
Try merge origin master
emostov Aug 31, 2021
65682bb
Build works
emostov Aug 31, 2021
6d69956
Apply suggestions from code review
emostov Aug 31, 2021
fa4844f
Apply suggestions from code review
emostov Aug 31, 2021
9166eed
Remove commented out debug assert
emostov Sep 1, 2021
e7052d9
Remove some unused deps and some unused benchmarking stuff
emostov Sep 1, 2021
c9263bc
Fix stakings ElectionDataProvider clear
emostov Sep 1, 2021
ecddb82
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 1, 2021
ceace6c
Merge branch 'master' of https://github.com/paritytech/substrate into…
emostov Sep 1, 2021
ef604fd
Merge branch 'master' of https://github.com/paritytech/substrate into…
Sep 2, 2021
e69ad5d
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 2, 2021
708672d
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 2, 2021
bb41a29
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 2, 2021
a3c9624
Improving staking pallet-bags-list migration
emostov Sep 2, 2021
0b5de63
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Sep 2, 2021
f25a2e7
fix build and some comments;
emostov Sep 2, 2021
b83afc3
comment
emostov Sep 3, 2021
9de3c56
Reduce visibility in bags list components
emostov Sep 3, 2021
6610e2d
make node.bag_upper only accesible to benchmarks
emostov Sep 3, 2021
fa372b4
Merge remote-tracking branch 'origin' into zeke-voter-bags-module
emostov Sep 3, 2021
627bb16
Address some feedback; comments updates
emostov Sep 3, 2021
dba6875
use nominator map comment
emostov Sep 3, 2021
0ca98f9
fix vec capacity debug assert
emostov Sep 3, 2021
accfafa
Apply suggestions from code review
emostov Sep 3, 2021
80ec27f
clarify VoterSnapshotPerBlock
emostov Sep 3, 2021
0c3a081
Reduce diff on create_validators by wrapping with_seed
emostov Sep 3, 2021
a182f58
Some small improvements to staking benches
emostov Sep 3, 2021
a87a6c5
Soem comment updates
emostov Sep 3, 2021
d547cb4
fix vec capacity debug assert ... for real this time
emostov Sep 3, 2021
0a97cdb
Reduce ListBags viz
emostov Sep 3, 2021
e05e465
Merge branch 'master' of https://github.com/paritytech/substrate into…
Sep 4, 2021
478adb6
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 4, 2021
90fc443
Merge branch 'master' of https://github.com/paritytech/substrate into…
Sep 4, 2021
8da3202
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 4, 2021
2c9ebdb
Merge remote-tracking branch 'origin' into zeke-voter-bags-module
emostov Sep 6, 2021
9ade86d
Remove supports_eq_unordered & Support eq_unordered
emostov Sep 6, 2021
16a5c87
Update utils/frame/generate-bags/src/lib.rs
emostov Sep 6, 2021
2ee478c
Make total-issuance & minimium-balance CLI args; Dont use emptry ext
emostov Sep 7, 2021
2933daa
Improve docs for generate bags CLI args
emostov Sep 7, 2021
c2daac5
Apply suggestions from code review
emostov Sep 8, 2021
2cbedc0
Apply suggestions from code review
emostov Sep 8, 2021
4c8c4eb
Don't use default bags weight in node runtime
emostov Sep 8, 2021
bb5f968
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Sep 8, 2021
cf4990c
Feature gating sanity_check not working
emostov Sep 8, 2021
3594eab
Feature gate sanity check by creating duplicate fns
emostov Sep 8, 2021
fa674aa
Fix line wrapping
emostov Sep 8, 2021
0eb7bf2
Document VoteWeightProvider
emostov Sep 8, 2021
36dafaa
Make bags ext-builder not a module
emostov Sep 8, 2021
6f4043b
Apply suggestions from code review
emostov Sep 8, 2021
1951b2a
use pallet_bags_list instead of crate in mock
emostov Sep 8, 2021
97459c5
Make get_bags test helper fn live in List
emostov Sep 8, 2021
651148e
use remove_from_storage_unchecked for node removal
emostov Sep 8, 2021
6d4b526
Remove count of ids removed in remove_many
emostov Sep 8, 2021
b39e1c0
Add node sanity check, improve list sanity check
emostov Sep 8, 2021
161c691
Do a list sanity check after on_update
emostov Sep 8, 2021
597e186
List::migrate: clean up debug assert, exit early when no change in th…
emostov Sep 8, 2021
06a05c4
Improve public doc comments for pallet_bags_list::list::List
emostov Sep 8, 2021
69ac8c1
Improve public doc comments for pallet_bags_list::list::List
emostov Sep 8, 2021
35a9471
Update generate bags docs
emostov Sep 8, 2021
5ece97c
Master.into()
kianenigma Sep 13, 2021
cf63c63
Merge remote-tracking branch 'origin' into zeke-voter-bags-module
emostov Sep 13, 2021
02f607a
Fix grammar in bags-list benchmark
emostov Sep 13, 2021
2f18113
Add benchmark case for `rebag` extrinsic
emostov Sep 13, 2021
d8f3c1c
Add count parameter to List::clear; WIP adding MaxEncodedLen to list'
emostov Sep 13, 2021
3af2543
MaxEncodeLen + generate_storage_info not working for Bag or Node
emostov Sep 13, 2021
1047756
Get MaxEncodeLen derive to work
emostov Sep 14, 2021
be2038f
Try to correctly feature gate SortedListProvider::clear
emostov Sep 14, 2021
080f1b6
Use u32::MAX, not u32::max_value
emostov Sep 14, 2021
14b9120
Get up to nominators_quota noms
emostov Sep 14, 2021
385138f
SortedListProvider::clear takes an Option
emostov Sep 14, 2021
adcf4bf
Eplicitly ignore SortedListProvider return value
emostov Sep 14, 2021
ce85f91
Fix doc comment
emostov Sep 14, 2021
a2899e6
Update node-runtime voter snapshot per block
emostov Sep 14, 2021
2e9e317
Add test get_max_len_voters_even_if_some_nominators_are_slashed
emostov Sep 15, 2021
e6dd68b
Add test only_iterates_max_2_times_nominators_quota
emostov Sep 15, 2021
76d01d8
Fix generate bags cargo.toml
emostov Sep 15, 2021
aa8c0cc
use sp_std vec
emostov Sep 15, 2021
ca1b6dd
Remove v8 migration hooks from pallet-staking
emostov Sep 15, 2021
b670dc2
TypeInfo merge wip
emostov Sep 15, 2021
0a5fa7b
Update npos trait
emostov Sep 15, 2021
904e4a8
Try respect line width
emostov Sep 15, 2021
b91487d
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Sep 15, 2021
59ed5c5
Update frame/bags-list/src/benchmarks.rs
emostov Sep 15, 2021
a78477c
Unwrap try-runtime error; remove sortedlistprovider pre upgrade len …
emostov Sep 16, 2021
7b802cb
Merge branch 'zeke-voter-bags-module' of https://github.com/paritytec…
emostov Sep 16, 2021
ffa3a93
trigger ci
emostov Sep 16, 2021
ff0f48c
restore
emostov Sep 16, 2021
e162c0f
trigger ci
emostov Sep 16, 2021
43a57f9
restore
emostov Sep 16, 2021
d96f2c2
trigger ci
emostov Sep 17, 2021
9c2c6d0
revert
emostov Sep 17, 2021
998c5d0
Merge remote-tracking branch 'origin' into zeke-voter-bags-module
emostov Sep 17, 2021
a645fd5
trigger ci
emostov Sep 17, 2021
8002234
revert
emostov Sep 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ members = [
"frame/uniques",
"frame/utility",
"frame/vesting",
"frame/bags-list",
"primitives/api",
"primitives/api/proc-macro",
"primitives/api/test",
Expand Down Expand Up @@ -198,6 +199,8 @@ members = [
"utils/frame/try-runtime/cli",
"utils/frame/rpc/support",
"utils/frame/rpc/system",
"utils/frame/generate-bags",
"utils/frame/generate-bags/node-runtime",
"utils/prometheus",
"utils/wasm-builder",
]
Expand Down
3 changes: 3 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pallet-assets = { version = "4.0.0-dev", default-features = false, path = "../..
pallet-authority-discovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/authority-discovery" }
pallet-authorship = { version = "4.0.0-dev", default-features = false, path = "../../../frame/authorship" }
pallet-babe = { version = "4.0.0-dev", default-features = false, path = "../../../frame/babe" }
pallet-bags-list = { version = "4.0.0-dev", default-features = false, path = "../../../frame/bags-list" }
pallet-balances = { version = "4.0.0-dev", default-features = false, path = "../../../frame/balances" }
pallet-bounties = { version = "4.0.0-dev", default-features = false, path = "../../../frame/bounties" }
pallet-collective = { version = "4.0.0-dev", default-features = false, path = "../../../frame/collective" }
Expand Down Expand Up @@ -110,6 +111,7 @@ std = [
"pallet-authorship/std",
"sp-consensus-babe/std",
"pallet-babe/std",
"pallet-bags-list/std",
"pallet-balances/std",
"pallet-bounties/std",
"sp-block-builder/std",
Expand Down Expand Up @@ -179,6 +181,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-bounties/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
Expand Down
26 changes: 26 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ pub mod constants;
use constants::{currency::*, time::*};
use sp_runtime::generic::Era;

/// Generated voter bag information.
mod voter_bags;

// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
Expand Down Expand Up @@ -525,6 +528,9 @@ impl pallet_staking::Config for Runtime {
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
// Alternatively, use pallet_staking::UseNominatorsMap<Runtime> to just use the nominators map.
// Note that the aforementioned does not scale to a very large number of nominators.
type SortedListProvider = BagsList;
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
}

Expand Down Expand Up @@ -552,6 +558,11 @@ parameter_types! {
*RuntimeBlockLength::get()
.max
.get(DispatchClass::Normal);

// BagsList allows a practically unbounded count of nominators to participate in NPoS elections.
// To ensure we respect memory limits when using the BagsList this must be set to a number of
// voters we know can fit into a single vec allocation.
pub const VoterSnapshotPerBlock: u32 = 10_000;
}

sp_npos_elections::generate_solution_type!(
Expand Down Expand Up @@ -634,6 +645,18 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
type ForceOrigin = EnsureRootOrHalfCouncil;
type BenchmarkingConfig = BenchmarkConfig;
type VoterSnapshotPerBlock = VoterSnapshotPerBlock;
}

parameter_types! {
pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS;
}

impl pallet_bags_list::Config for Runtime {
type Event = Event;
type VoteWeightProvider = Staking;
type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>;
type BagThresholds = BagThresholds;
}

parameter_types! {
Expand Down Expand Up @@ -1254,6 +1277,7 @@ construct_runtime!(
Gilt: pallet_gilt::{Pallet, Call, Storage, Event<T>, Config},
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>},
TransactionStorage: pallet_transaction_storage::{Pallet, Call, Storage, Inherent, Config<T>, Event<T>},
BagsList: pallet_bags_list::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -1581,6 +1605,7 @@ impl_runtime_apis! {

list_benchmark!(list, extra, pallet_assets, Assets);
list_benchmark!(list, extra, pallet_babe, Babe);
list_benchmark!(list, extra, pallet_bags_list, BagsList);
list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_bounties, Bounties);
list_benchmark!(list, extra, pallet_collective, Council);
Expand Down Expand Up @@ -1655,6 +1680,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_babe, Babe);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_bags_list, BagsList);
add_benchmark!(params, batches, pallet_bounties, Bounties);
add_benchmark!(params, batches, pallet_collective, Council);
add_benchmark!(params, batches, pallet_contracts, Contracts);
Expand Down
Loading