Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds stake-tracker pallet and integrates with the staking pallet #1933

Closed
wants to merge 162 commits into from
Closed
Show file tree
Hide file tree
Changes from 141 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
5803d69
Adds `stake-tracker` pallet and integrates with the staking pallet
gpestana Oct 18, 2023
c7ad6bf
Comments and other nit fixes
gpestana Oct 18, 2023
cb393b9
Removes the untracked stake
gpestana Nov 1, 2023
84a3b71
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Nov 3, 2023
46f5f2e
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Nov 7, 2023
b9d3f64
Removes completely the untracked stake code
gpestana Nov 7, 2023
b42a160
Fixes to review comments
gpestana Nov 7, 2023
086a183
more improvements
gpestana Nov 7, 2023
7b89e06
fixes comments
gpestana Nov 7, 2023
ad1c49d
nits and more tests
gpestana Nov 8, 2023
2c2256d
nits and more tests
gpestana Nov 8, 2023
e2babf5
Adds more tests
gpestana Nov 8, 2023
cab3568
Adds more testing
gpestana Nov 8, 2023
0152b34
improves testing
gpestana Nov 9, 2023
ae98ed9
Change score typ of target list from voteweight to balance
gpestana Nov 10, 2023
ac4a7af
adds more rebagging and sorting tests to stake-tracker
gpestana Nov 10, 2023
c2d681d
More tests
gpestana Nov 14, 2023
4e06d60
test fixing due to new target list ordering
gpestana Nov 14, 2023
bbc59a5
Adds more staking tests for the stake-tracker integration
gpestana Nov 15, 2023
33a9357
more stake_tracker integration tests
gpestana Nov 15, 2023
01793c5
fixes target score updates when kicking
gpestana Nov 15, 2023
fee0514
Addresses review comments; moves stake-tracker into staking crate
gpestana Nov 17, 2023
30a9c47
Adds more defensives
gpestana Nov 17, 2023
05c40db
ledger.kill will fail if preconditions have not been met
gpestana Nov 19, 2023
77d7762
fixes remaining tests
gpestana Nov 19, 2023
f3e4185
Adds stake-tracker to westend runtime
gpestana Nov 19, 2023
bd2d7e2
nits to make CI happy
gpestana Nov 19, 2023
ed3cc48
Update substrate/frame/staking/src/mock.rs
gpestana Nov 21, 2023
dc141ad
Update substrate/frame/staking/stake-tracker/src/mock.rs
gpestana Nov 21, 2023
bbb5740
Update substrate/frame/staking/stake-tracker/src/lib.rs
gpestana Nov 21, 2023
1d98e7d
Update substrate/frame/staking/stake-tracker/Cargo.toml
gpestana Nov 21, 2023
964413c
Adds try-state checks to stake-tracker pallet; review nits
gpestana Nov 21, 2023
25c97e1
Removes duplicate assert
gpestana Nov 24, 2023
f9c439c
Refactors staking and `stake-tracker` so that target and voter lists …
gpestana Dec 2, 2023
b09f8bc
Addresses review comments
gpestana Dec 5, 2023
062868d
review comments
gpestana Dec 5, 2023
992cff1
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Dec 5, 2023
70ab8c3
".git/.scripts/commands/fmt/fmt.sh"
Dec 5, 2023
ee52b6f
Update documentation
gpestana Dec 5, 2023
a3b0b41
Wraps slash tests on TestExternalities
gpestana Dec 13, 2023
f1526e0
Removes ability to explicitly add moot nominations, as it fails with …
gpestana Dec 14, 2023
2870db3
Keeps approvals even if the validator chills or stash is killed (if t…
gpestana Dec 20, 2023
6713df3
Update docs; VoterList node is removed upon chilling.
gpestana Dec 24, 2023
341e28e
Update substrate/frame/staking/stake-tracker/src/lib.rs
gpestana Dec 26, 2023
dba853b
review nits
gpestana Dec 26, 2023
b316f6f
Refactor `OnStakingUpdate` interface to be safer to use. (#2877)
gpestana Jan 8, 2024
261456e
Fixes fast-unstake test setup
gpestana Jan 8, 2024
27a85fc
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jan 8, 2024
088783e
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jan 21, 2024
bf1e043
simplifies do_add_validator
gpestana Jan 21, 2024
c0497b2
Adds prdoc
gpestana Jan 21, 2024
27129fb
fixes clippy
gpestana Jan 22, 2024
f0098d6
Fixes clippy
gpestana Jan 23, 2024
fa94b7f
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Feb 1, 2024
f89a046
after master merge fixes
gpestana Feb 1, 2024
18f11b7
simplify on_remove_* logic
gpestana Feb 1, 2024
0e95378
Adds stake-tracker to benchmarking runtime
gpestana Feb 5, 2024
ff8a64e
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Feb 5, 2024
261e8ab
stake-tracker cargo fix
gpestana Feb 5, 2024
63f43f8
Fixes stake-tracker/no-std
gpestana Feb 5, 2024
bc2f2ce
Fixes feature dependencies
gpestana Feb 5, 2024
50ea3d0
fmt cargo.toml
gpestana Feb 5, 2024
38e6616
fixes westend/stake-tracker runtime config
gpestana Feb 5, 2024
5a5494a
impls max_exposure_page_size for mock (runtime-benchmarks)
gpestana Feb 5, 2024
246c49a
fixes rust docs
gpestana Feb 6, 2024
41a00a3
Adds throughout try-state checks and includes stake-tracker try-state…
gpestana Feb 7, 2024
3ae6d11
Update substrate/frame/staking/src/ledger.rs
gpestana Feb 8, 2024
cf047db
fixes clippy
gpestana Feb 8, 2024
6e5d019
clean up try-state code
gpestana Feb 8, 2024
d12cdc2
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Feb 8, 2024
a1b16c7
clippy nits
gpestana Feb 8, 2024
f48c7de
Add try-runtime gated method in sorted list provider to help with checks
gpestana Feb 8, 2024
4ac7fcf
Adds the callable drop_dangling_nomination to allow permissionless dr…
gpestana Feb 9, 2024
2fdb673
clippy
gpestana Feb 9, 2024
e5ca233
doc fixes
gpestana Feb 9, 2024
786dbf5
simplifies staking imbalance calculation; addresses reviews
gpestana Feb 11, 2024
bfa02dc
Update substrate/frame/staking/stake-tracker/src/lib.rs
gpestana Feb 12, 2024
44f44ef
addresses PR comments & simplifies stake-tracker code
gpestana Feb 12, 2024
ff8ee33
add a couple more checks to try-state when building the approvals map
gpestana Feb 12, 2024
740565b
ensures OnStakingUpdate events are triggered at the correct places an…
gpestana Feb 13, 2024
8c8d004
updates comments; ensures that voter list is also always sorted + tes…
gpestana Feb 13, 2024
d48f823
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Feb 15, 2024
639edaf
nits and address comments
gpestana Feb 15, 2024
9af1122
defensive instead of err in case of killing a stash that is not Idle
gpestana Feb 15, 2024
7dd813b
Adds stake-tracker benchs
gpestana Feb 16, 2024
9ec7759
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Feb 19, 2024
ab802b5
Removes the need for staking to check the state of the target and vot…
gpestana Feb 19, 2024
12fce24
cargo-clippy fix
gpestana Feb 19, 2024
d44f734
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Apr 15, 2024
afeddd2
Update substrate/frame/staking/stake-tracker/src/lib.rs
gpestana Apr 15, 2024
e66d00f
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Apr 19, 2024
56ecb62
starts adding mmb for target list
gpestana Apr 19, 2024
595022e
moves drop_dangling_target extrinsic from stake-tracker to staking
gpestana Apr 20, 2024
fa7edf1
finishes dangling nomination benchs
gpestana Apr 21, 2024
b4f9e90
fixes BadTarget error in benchmarks
gpestana Apr 21, 2024
803f148
Adds v13 mmb migration benchmarks and tests
gpestana Apr 21, 2024
6123e12
refactors benchmarks to use benchmarking::v2
gpestana Apr 22, 2024
25589af
some refactoring on mmb benchmarks
gpestana Apr 22, 2024
7e6db9e
changes mmb strategy -- do nominator-based migrations instead of vali…
gpestana Apr 22, 2024
2864631
Finishes benchmarks and MMB for stake-tracker
gpestana Apr 23, 2024
b01f013
simplifies defensive for tests only
gpestana Apr 28, 2024
ac5df15
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Apr 28, 2024
34c4612
nit
gpestana Apr 28, 2024
6273d4c
nits
gpestana Apr 28, 2024
2096b25
fixes imports
gpestana Apr 29, 2024
1080cc4
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Apr 29, 2024
c6593dc
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Apr 29, 2024
605e54d
starts sorting mode
gpestana Apr 29, 2024
3fa1601
fixes iter
gpestana Apr 30, 2024
9d335ca
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana May 2, 2024
9e18a84
cargo lock update after merging master
gpestana May 2, 2024
40620e0
Update substrate/frame/staking/stake-tracker/src/lib.rs
gpestana May 2, 2024
97d254e
Update substrate/frame/staking/stake-tracker/src/mock.rs
gpestana May 2, 2024
8624320
nit
gpestana May 2, 2024
6e452e1
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana May 2, 2024
e9218b6
nits
gpestana May 2, 2024
1dd4d38
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana May 8, 2024
628bceb
`stake-tracker` feedback PR (#4411)
gpestana May 10, 2024
52cde8a
Merge branch 'gpestana/stake-tracker_integration' of github.com:parit…
gpestana May 10, 2024
c444174
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana May 10, 2024
d726d0f
fixes zepter
gpestana May 10, 2024
3d4452f
ensures mmb bench checks are deteministic
gpestana May 10, 2024
d225176
clippy nits
gpestana May 10, 2024
a56f765
taplo nit fixes
gpestana May 10, 2024
80895ad
clippy nit
gpestana May 10, 2024
6219b32
Stake tracker improvements (migration and try-state checks OK in Polk…
gpestana Jun 3, 2024
822a945
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jun 3, 2024
1aa1c80
fixes umbrella runtime and stake-tracker mock after master merge
gpestana Jun 3, 2024
4bf868a
nits
gpestana Jun 3, 2024
3a07d09
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 3, 2024
1445118
docs pass
gpestana Jun 5, 2024
e785621
nit: fix umbrella cargo lint
gpestana Jun 5, 2024
8c685d7
fixes nomination pools benchmarks (validators must exist)
gpestana Jun 5, 2024
c34ede1
adds try-state checks to ensure no duplicate targets in nomination
gpestana Jun 5, 2024
303b4be
fixes tests and mocks in other pallets
gpestana Jun 5, 2024
66290a6
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jun 5, 2024
cc16579
semver nits
gpestana Jun 5, 2024
fc39f8e
all try-state checks pass for ext pallets; prdoc nits
gpestana Jun 6, 2024
f2613de
nit
gpestana Jun 6, 2024
8caac45
on_add_validator without option
gpestana Jun 6, 2024
b44a4e5
doc improvements; drop dangling target fix; more tests
gpestana Jun 6, 2024
3a68c14
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jun 13, 2024
66f8259
addresses review
gpestana Jun 13, 2024
ea9e838
simplifies dedup
gpestana Jun 14, 2024
4c79d3b
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jun 14, 2024
b3bd4fd
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jul 15, 2024
0fda93d
compilation nits after merge; addresses review comments.
gpestana Jul 17, 2024
62a3e5c
removes unecessary staking::status calls in stake-tracker
gpestana Jul 17, 2024
d08cf70
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jul 17, 2024
19abad8
merge nits: removes sp_std
gpestana Jul 17, 2024
cb631fa
fixes dependencies on mmbs without sp_std
gpestana Jul 17, 2024
9219e2e
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jul 17, 2024
f591b89
use crv2 in stake-tracker mock
gpestana Jul 18, 2024
8b0dec2
Improves MMB docs and naming
gpestana Jul 18, 2024
a0d3962
stake-tracker cargo toml to use workspace
gpestana Jul 18, 2024
4f90672
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Jul 18, 2024
4ddff0f
".git/.scripts/commands/fmt/fmt.sh"
Jul 18, 2024
aab02ce
nit to prevent defensives in migration
gpestana Jul 19, 2024
06b6821
Merge branch 'gpestana/stake-tracker_integration' of github.com:parit…
gpestana Jul 19, 2024
933e159
Adds target approvals buffering below a threshold (#5168)
gpestana Aug 1, 2024
24c4faa
Revert "Adds target approvals buffering below a threshold" (#5235)
gpestana Aug 5, 2024
1b6d567
Merge branch 'master' into gpestana/stake-tracker_integration
gpestana Aug 5, 2024
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
3,374 changes: 1,742 additions & 1,632 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ members = [
"substrate/frame/staking/reward-curve",
"substrate/frame/staking/reward-fn",
"substrate/frame/staking/runtime-api",
"substrate/frame/staking/stake-tracker",
"substrate/frame/state-trie-migration",
"substrate/frame/statement",
"substrate/frame/sudo",
Expand Down
4 changes: 4 additions & 0 deletions polkadot/runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pallet-scheduler = { path = "../../../substrate/frame/scheduler", default-featur
pallet-session = { path = "../../../substrate/frame/session", default-features = false }
pallet-society = { path = "../../../substrate/frame/society", default-features = false }
pallet-staking = { path = "../../../substrate/frame/staking", default-features = false }
pallet-stake-tracker = { path = "../../../substrate/frame/staking/stake-tracker", default-features = false }
pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", path = "../../../substrate/frame/staking/reward-curve" }
pallet-staking-runtime-api = { path = "../../../substrate/frame/staking/runtime-api", default-features = false }
pallet-delegated-staking = { path = "../../../substrate/frame/delegated-staking", default-features = false }
Expand Down Expand Up @@ -184,6 +185,7 @@ std = [
"pallet-session-benchmarking?/std",
"pallet-session/std",
"pallet-society/std",
"pallet-stake-tracker/std",
"pallet-staking-runtime-api/std",
"pallet-staking/std",
"pallet-state-trie-migration/std",
Expand Down Expand Up @@ -270,6 +272,7 @@ runtime-benchmarks = [
"pallet-scheduler/runtime-benchmarks",
"pallet-session-benchmarking/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
"pallet-stake-tracker/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-state-trie-migration/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
Expand Down Expand Up @@ -329,6 +332,7 @@ try-runtime = [
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
"pallet-society/try-runtime",
"pallet-stake-tracker/try-runtime",
"pallet-staking/try-runtime",
"pallet-state-trie-migration/try-runtime",
"pallet-sudo/try-runtime",
Expand Down
208 changes: 206 additions & 2 deletions polkadot/runtime/westend/src/bag_thresholds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,212 @@ pub const EXISTENTIAL_WEIGHT: u64 = 10_000_000_000;
#[allow(unused)]
pub const CONSTANT_RATIO: f64 = 1.1131723507077667;

/// Upper thresholds delimiting the bag list.
pub const THRESHOLDS: [u64; 200] = [
/// Upper thresholds delimiting the voters bag list.
pub const VOTER_THRESHOLDS: [u64; 200] = [
10_000_000_000,
11_131_723_507,
12_391_526_824,
13_793_905_044,
15_354_993_703,
17_092_754_435,
19_027_181_634,
21_180_532_507,
23_577_583_160,
26_245_913_670,
29_216_225_417,
32_522_694_326,
36_203_364_094,
40_300_583_912,
44_861_495_728,
49_938_576_656,
55_590_242_767,
61_881_521_217,
68_884_798_439,
76_680_653_006,
85_358_782_760,
95_019_036_859,
105_772_564_622,
117_743_094_401,
131_068_357_174,
145_901_671_259,
162_413_706_368,
180_794_447_305,
201_255_379_901,
224_031_924_337,
249_386_143_848,
277_609_759_981,
309_027_509_097,
344_000_878_735,
382_932_266_827,
426_269_611_626,
474_511_545_609,
528_213_132_664,
587_992_254_562,
654_536_720_209,
728_612_179_460,
811_070_932_564,
902_861_736_593,
1_005_040_721_687,
1_118_783_542_717,
1_245_398_906_179,
1_386_343_627_960,
1_543_239_395_225,
1_717_891_425_287,
1_912_309_236_147,
2_128_729_767_682,
2_369_643_119_512,
2_637_821_201_686,
2_936_349_627_828,
3_268_663_217_709,
3_638_585_517_729,
4_050_372_794_022,
4_508_763_004_364,
5_019_030_312_352,
5_587_045_771_074,
6_219_344_874_498,
6_923_202_753_807,
7_706_717_883_882,
8_578_905_263_043,
9_549_800_138_161,
10_630_573_468_586,
11_833_660_457_397,
13_172_903_628_838,
14_663_712_098_160,
16_323_238_866_411,
18_170_578_180_087,
20_226_985_226_447,
22_516_120_692_255,
25_064_322_999_817,
27_900_911_352_605,
31_058_523_077_268,
34_573_489_143_434,
38_486_252_181_966,
42_841_831_811_331,
47_690_342_626_046,
53_087_570_807_094,
59_095_615_988_698,
65_783_605_766_662,
73_228_491_069_308,
81_515_931_542_404,
90_741_281_135_191,
101_010_685_227_495,
112_442_301_921_293,
125_167_661_548_718,
139_333_180_038_781,
155_101_843_555_358,
172_655_083_789_626,
192_194_865_483_744,
213_946_010_204_502,
238_158_783_103_893,
265_111_772_429_462,
295_115_094_915_607,
328_513_963_936_552,
365_692_661_475_578,
407_078_959_611_349,
453_149_042_394_237,
504_432_984_742_966,
561_520_851_400_862,
625_069_486_125_324,
695_810_069_225_823,
774_556_530_406_243,
862_214_913_708_369,
959_793_802_308_039,
1_068_415_923_109_985,
1_189_331_064_661_951,
1_323_930_457_019_515,
1_473_762_779_014_021,
1_640_551_977_100_649,
1_826_217_100_807_404,
2_032_894_383_008_501,
2_262_961_819_074_188,
2_519_066_527_700_738,
2_804_155_208_229_882,
3_121_508_044_894_685,
3_474_776_448_088_622,
3_868_025_066_902_796,
4_305_778_556_320_752,
4_793_073_637_166_665,
5_335_517_047_800_242,
5_939_350_054_341_159,
6_611_520_261_667_250,
7_359_761_551_432_161,
8_192_683_066_856_378,
9_119_868_268_136_230,
10_151_985_198_186_376,
11_300_909_227_415_580,
12_579_859_689_817_292,
14_003_551_982_487_792,
15_588_366_878_604_342,
17_352_539_001_951_086,
19_316_366_631_550_092,
21_502_445_250_375_680,
23_935_927_525_325_748,
26_644_812_709_737_600,
29_660_268_798_266_784,
33_016_991_140_790_860,
36_753_601_641_491_664,
40_913_093_136_236_104,
45_543_324_061_189_736,
50_697_569_104_240_168,
56_435_132_174_936_472,
62_822_028_745_677_552,
69_931_745_415_056_768,
77_846_085_432_775_824,
86_656_109_914_600_688,
96_463_185_576_826_656,
107_380_151_045_315_664,
119_532_615_158_469_088,
133_060_402_202_199_856,
148_119_160_705_543_712,
164_882_154_307_451_552,
183_542_255_300_186_560,
204_314_163_786_713_728,
227_436_877_985_347_776,
253_176_444_104_585_088,
281_829_017_427_734_464,
313_724_269_827_691_328,
349_229_182_918_168_832,
388_752_270_484_770_624,
432_748_278_778_513_664,
481_723_418_752_617_984,
536_241_190_443_833_600,
596_928_866_512_693_376,
664_484_709_541_257_600,
739_686_006_129_409_280,
823_398_010_228_713_984,
916_583_898_614_395_264,
1_020_315_853_041_475_584,
1_135_787_396_594_579_584,
1_264_327_126_171_442_688,
1_407_413_999_103_859_968,
1_566_694_349_801_462_272,
1_744_000_832_209_069_824,
1_941_373_506_026_471_680,
2_161_083_309_305_266_176,
2_405_658_187_494_662_656,
2_677_912_179_572_818_944,
2_980_977_795_924_034_048,
3_318_342_060_496_414_208,
3_693_886_631_935_247_360,
4_111_932_465_319_354_368,
4_577_289_528_371_127_808,
5_095_312_144_166_932_480,
5_671_960_597_112_134_656,
6_313_869_711_009_142_784,
7_028_425_188_266_614_784,
7_823_848_588_596_424_704,
8_709_291_924_949_524_480,
9_694_942_965_096_232_960,
10_792_142_450_433_898_496,
12_013_514_580_722_579_456,
13_373_112_266_084_982_784,
14_886_578_817_516_689_408,
16_571_327_936_291_497_984,
18_446_744_073_709_551_615,
];

/// Upper thresholds delimiting the targets bag list.
pub const TARGET_THRESHOLDS: [u128; 200] = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the distribution of initial validators in these bags good? We could go for a different bag distribution for targets, given that approval stakes are generally much higher. Just an option.

10_000_000_000,
11_131_723_507,
12_391_526_824,
Expand Down
44 changes: 37 additions & 7 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ pub use pallet_balances::Call as BalancesCall;
pub use pallet_election_provider_multi_phase::{Call as EPMCall, GeometricDepositBase};
#[cfg(feature = "std")]
pub use pallet_staking::StakerStatus;
use pallet_staking::UseValidatorsMap;
pub use pallet_timestamp::Call as TimestampCall;
use sp_runtime::traits::Get;
#[cfg(any(feature = "std", test))]
Expand Down Expand Up @@ -578,18 +577,38 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
}

parameter_types! {
pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS;
pub const VoterBagThresholds: &'static [u64] = &bag_thresholds::VOTER_THRESHOLDS;
gpestana marked this conversation as resolved.
Show resolved Hide resolved
pub const TargetBagThresholds: &'static [u128] = &bag_thresholds::TARGET_THRESHOLDS;

pub const VoterUpdateMode: pallet_stake_tracker::VoterUpdateMode = pallet_stake_tracker::VoterUpdateMode::Lazy;
}

type VoterBagsListInstance = pallet_bags_list::Instance1;
impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type ScoreProvider = Staking;
type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
type BagThresholds = BagThresholds;
type BagThresholds = VoterBagThresholds;
type Score = sp_npos_elections::VoteWeight;
}

type TargetBagsListInstance = pallet_bags_list::Instance2;
impl pallet_bags_list::Config<TargetBagsListInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type ScoreProvider = pallet_bags_list::Pallet<Runtime, TargetBagsListInstance>;
type WeightInfo = weights::pallet_bags_list::WeightInfo<Runtime>;
type BagThresholds = TargetBagThresholds;
type Score = u128;
}

impl pallet_stake_tracker::Config for Runtime {
type Currency = Balances;
type Staking = Staking;
type VoterList = VoterList;
type TargetList = TargetList;
type VoterUpdateMode = VoterUpdateMode;
}

pallet_staking_reward_curve::build! {
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
Expand Down Expand Up @@ -638,13 +657,13 @@ impl pallet_staking::Config for Runtime {
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type TargetList = TargetList;
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type HistoryDepth = frame_support::traits::ConstU32<84>;
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
type EventListeners = (NominationPools, DelegatedStaking);
type EventListeners = (StakeTracker, NominationPools, DelegatedStaking);
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
type DisablingStrategy = pallet_staking::UpToLimitDisablingStrategy;
}
Expand Down Expand Up @@ -1003,6 +1022,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Slots(..) |
RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet
RuntimeCall::VoterList(..) |
RuntimeCall::TargetList(..) |
RuntimeCall::NominationPools(..) |
RuntimeCall::FastUnstake(..)
),
Expand All @@ -1013,6 +1033,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Session(..) | RuntimeCall::Utility(..) |
RuntimeCall::FastUnstake(..) |
RuntimeCall::VoterList(..) |
RuntimeCall::TargetList(..) |
RuntimeCall::NominationPools(..)
)
},
Expand Down Expand Up @@ -1505,7 +1526,7 @@ mod runtime {
#[runtime::pallet_index(24)]
pub type ElectionProviderMultiPhase = pallet_election_provider_multi_phase;

// Provides a semi-sorted list of nominators for staking.
// Provides a sorted list of nominators for staking.
#[runtime::pallet_index(25)]
pub type VoterList = pallet_bags_list<Instance1>;

Expand Down Expand Up @@ -1613,6 +1634,14 @@ mod runtime {
// Pallet for migrating Identity to a parachain. To be removed post-migration.
#[runtime::pallet_index(248)]
pub type IdentityMigrator = identity_migrator;

// Provides a sorted list of validators for staking.
#[runtime::pallet_index(249)]
pub type TargetList = pallet_bags_list<Instance2>;

// Keeps VoterList and TargetList up to date based on staking events.
#[runtime::pallet_index(250)]
pub type StakeTracker = pallet_stake_tracker;
}

/// The address format for describing accounts.
Expand Down Expand Up @@ -1683,7 +1712,7 @@ pub mod migrations {
Runtime,
MaxPoolsToMigrate,
>,
pallet_staking::migrations::v15::MigrateV14ToV15<Runtime>,
pallet_staking::migrations::single_block::v15::MigrateV14ToV15<Runtime>,
);
}

Expand Down Expand Up @@ -1726,6 +1755,7 @@ mod benches {
[polkadot_runtime_parachains::coretime, Coretime]
// Substrate
[pallet_bags_list, VoterList]
[pallet_bags_list, TargetList]
[pallet_balances, Balances]
[pallet_conviction_voting, ConvictionVoting]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
Expand Down
Loading
Loading