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

[Feature] StakeTracker P2 - TargetList #13195

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
75401db
[Feature] StakeTracker P2 - TargetList
ruseinov Jan 20, 2023
eb11adc
add targetList to the runtime
ruseinov Jan 20, 2023
22aa965
introduce initializer
ruseinov Jan 20, 2023
ed411c5
more changes
ruseinov Jan 23, 2023
2eef4ed
more tests
ruseinov Jan 23, 2023
08832ee
introduce try-state
ruseinov Jan 23, 2023
0fdda0d
Merge remote-tracking branch 'origin/ru/feature/stake-tracker-voter' …
Jan 24, 2023
6f243bb
more tests
ruseinov Jan 24, 2023
f6ac9c7
add test cases for previous stake
ruseinov Jan 24, 2023
9fd1847
simplify on_stake_update tests
ruseinov Jan 25, 2023
1356721
more nomination scenarios
ruseinov Jan 25, 2023
88c4adf
on_unstake test
ruseinov Jan 25, 2023
f33f139
on_validator_add tests
ruseinov Jan 25, 2023
2b3507b
more tests
ruseinov Jan 25, 2023
ee4671a
some logic and test mods
ruseinov Jan 25, 2023
f3083e6
full tests coverage for StakeTracker
ruseinov Jan 26, 2023
ef5c9ac
add a basic check in Staking to make sure Validators::count lines up …
ruseinov Jan 26, 2023
1111be9
fix try_state
ruseinov Jan 26, 2023
7959a57
fix try-state
ruseinov Jan 26, 2023
460c90c
fmt
ruseinov Jan 26, 2023
f786bdc
fix stake-tracker
ruseinov Jan 26, 2023
eaf6053
add TemporaryMigrationLock
ruseinov Jan 26, 2023
e22ecfa
fix
ruseinov Jan 26, 2023
d371c87
fix migration
ruseinov Jan 26, 2023
ef93333
more migration fixes
ruseinov Jan 26, 2023
1a26fda
more lock
ruseinov Jan 26, 2023
5e7c7ab
fix bench tests
ruseinov Jan 26, 2023
b8cf32b
fix more
ruseinov Jan 26, 2023
bf48684
temp_lock disabled by default
ruseinov Jan 26, 2023
ee10bd8
fix nom-pools mock
ruseinov Jan 26, 2023
bdbed8a
fix offences
ruseinov Jan 26, 2023
3019477
fix nom-pools
ruseinov Jan 26, 2023
c16571a
a little fix
ruseinov Jan 26, 2023
10abb45
Revert "a little fix"
ruseinov Jan 27, 2023
59ac7e4
Revert "fix nom-pools"
ruseinov Jan 27, 2023
e51de44
Revert "fix offences"
ruseinov Jan 27, 2023
f70d2b0
Revert "temp_lock disabled by default"
ruseinov Jan 27, 2023
54b67bf
rework TemporaryMigrationLock to avoid fixing in too many places
ruseinov Jan 27, 2023
e1d4b9e
remove obsolete stuff
ruseinov Jan 27, 2023
e264493
Merge branch 'ru/feature/stake-tracker-voter' into ru/feature/stake-t…
ruseinov Jan 30, 2023
697b6e7
fix initializer
ruseinov Jan 30, 2023
a2c103e
fix initializer
ruseinov Jan 30, 2023
2a6e72c
fix initilizer
ruseinov Jan 30, 2023
93b620f
more fixes
ruseinov Jan 30, 2023
47408c4
more fix
ruseinov Jan 30, 2023
353b9b5
Merge remote-tracking branch 'origin/ru/feature/stake-tracker-voter' …
ruseinov Mar 15, 2023
2a59269
add pallet for initializer to be able to execute on_initialize
ruseinov Mar 17, 2023
2c055d5
Merge branch 'ru/feature/stake-tracker-voter' into ru/feature/stake-t…
ruseinov Mar 21, 2023
5723d22
Merge branch 'ru/feature/stake-tracker-voter' into ru/feature/stake-t…
ruseinov Mar 21, 2023
203ae61
defensive
ruseinov Mar 21, 2023
5fa8825
defensive
ruseinov Mar 21, 2023
91b3f07
Merge remote-tracking branch 'origin/ru/feature/stake-tracker-voter' …
Mar 21, 2023
a6fcba6
Merge remote-tracking branch 'origin/ru/feature/stake-tracker-voter' …
Mar 21, 2023
5de04a0
remove broken check
ruseinov Mar 21, 2023
b9c2166
Merge remote-tracking branch 'origin/ru/feature/stake-tracker-voter' …
Mar 22, 2023
129aaa1
a rough on-initialize migration draft
ruseinov Mar 24, 2023
3060520
some more modifications
ruseinov Mar 27, 2023
668fa64
fixes
ruseinov Mar 29, 2023
e63418a
Merge remote-tracking branch 'origin/ru/feature/stake-tracker-voter' …
Mar 30, 2023
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
18 changes: 18 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ members = [
"frame/society",
"frame/staking",
"frame/stake-tracker",
"frame/stake-tracker/initializer",
"frame/staking/reward-curve",
"frame/staking/reward-fn",
"frame/staking/runtime-api",
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 @@ -102,6 +102,7 @@ pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = ".
pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true }
pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" }
pallet-stake-tracker = { version = "4.0.0-dev", default-features = false, path = "../../../frame/stake-tracker" }
pallet-stake-tracker-initializer = { version = "1.0.0-dev", default-features = false, path = "../../../frame/stake-tracker/initializer" }
pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/reward-curve" }
pallet-staking-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/runtime-api" }
pallet-state-trie-migration = { version = "4.0.0-dev", default-features = false, path = "../../../frame/state-trie-migration" }
Expand Down Expand Up @@ -186,6 +187,7 @@ std = [
"sp-staking/std",
"pallet-staking/std",
"pallet-stake-tracker/std",
"pallet-stake-tracker-initializer/std",
"pallet-staking-runtime-api/std",
"pallet-state-trie-migration/std",
"pallet-salary/std",
Expand Down Expand Up @@ -329,6 +331,7 @@ try-runtime = [
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"pallet-stake-tracker/try-runtime",
"pallet-stake-tracker-initializer/try-runtime",
"pallet-state-trie-migration/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-society/try-runtime",
Expand Down
18 changes: 18 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,11 @@ impl pallet_stake_tracker::Config for Runtime {
type Currency = Balances;
type Staking = Staking;
type VoterList = VoterList;
type TargetList = TargetList;
}

impl pallet_stake_tracker_initializer::Config for Runtime {}

impl pallet_fast_unstake::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ControlOrigin = frame_system::EnsureRoot<AccountId>;
Expand Down Expand Up @@ -775,12 +778,25 @@ parameter_types! {
type VoterBagsListInstance = pallet_bags_list::Instance1;
impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>;
/// The voter bags-list is loosely kept up to date, and the real source of truth for the score
/// of each node is the staking pallet.
type ScoreProvider = Staking;
type BagThresholds = BagThresholds;
type Score = VoteWeight;
}

parameter_types! {
pub const BagThresholdsBalances: &'static [Balance] = &voter_bags::THRESHOLDS_BALANCES;
}

type TargetBagsListInstance = pallet_bags_list::Instance2;
impl pallet_bags_list::Config<TargetBagsListInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>;
type ScoreProvider = StakeTracker;
type BagThresholds = BagThresholdsBalances;
type Score = Balance;
}

parameter_types! {
Expand Down Expand Up @@ -1771,6 +1787,7 @@ construct_runtime!(
ElectionProviderMultiPhase: pallet_election_provider_multi_phase,
Staking: pallet_staking,
StakeTracker: pallet_stake_tracker,
StakeTrackerInitializer: pallet_stake_tracker_initializer,
Session: pallet_session,
Democracy: pallet_democracy,
Council: pallet_collective::<Instance1>,
Expand Down Expand Up @@ -1807,6 +1824,7 @@ construct_runtime!(
CoreFellowship: pallet_core_fellowship,
TransactionStorage: pallet_transaction_storage,
VoterList: pallet_bags_list::<Instance1>,
TargetList: pallet_bags_list::<Instance2>,
StateTrieMigration: pallet_state_trie_migration,
ChildBounties: pallet_child_bounties,
Referenda: pallet_referenda,
Expand Down
206 changes: 205 additions & 1 deletion bin/node/runtime/src/voter_bags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

//! Autogenerated bag thresholds.
//!
//! Generated on 2022-08-15T19:26:59.939787+00:00
//! Generated on 2023-01-20T15:05:52.717430+00:00
//! Arguments
//! Total issuance: 100000000000000
//! Minimum balance: 100000000000000
Expand Down Expand Up @@ -236,3 +236,207 @@ pub const THRESHOLDS: [u64; 200] = [
17_356_326_621_502_140_416,
18_446_744_073_709_551_615,
];

/// Upper thresholds delimiting the bag list.
pub const THRESHOLDS_BALANCES: [u128; 200] = [
100_000_000_000_000,
106_282_535_907_434,
112_959_774_389_150,
120_056_512_776_105,
127_599_106_300_477,
135_615_565_971_369,
144_135_662_599_590,
153_191_037_357_827,
162_815_319_286_803,
173_044_250_183_800,
183_915_817_337_347,
195_470_394_601_017,
207_750_892_330_229,
220_802_916_738_890,
234_674_939_267_673,
249_418_476_592_914,
265_088_281_944_639,
281_742_548_444_211,
299_443_125_216_738,
318_255_747_080_822,
338_250_278_668_647,
359_500_973_883_001,
382_086_751_654_776,
406_091_489_025_036,
431_604_332_640_068,
458_720_029_816_222,
487_539_280_404_019,
518_169_110_758_247,
550_723_271_202_866,
585_322_658_466_782,
622_095_764_659_305,
661_179_154_452_653,
702_717_972_243_610,
746_866_481_177_808,
793_788_636_038_393,
843_658_692_126_636,
896_661_852_395_681,
952_994_955_240_703,
1_012_867_205_499_736,
1_076_500_951_379_881,
1_144_132_510_194_192,
1_216_013_045_975_769,
1_292_409_502_228_280,
1_373_605_593_276_862,
1_459_902_857_901_004,
1_551_621_779_162_291,
1_649_102_974_585_730,
1_752_708_461_114_642,
1_862_822_999_536_805,
1_979_855_523_374_646,
2_104_240_657_545_975,
2_236_440_332_435_128,
2_376_945_499_368_703,
2_526_277_953_866_680,
2_684_992_273_439_945,
2_853_677_877_130_641,
3_032_961_214_443_876,
3_223_508_091_799_862,
3_426_026_145_146_232,
3_641_267_467_913_124,
3_870_031_404_070_482,
4_113_167_516_660_186,
4_371_578_742_827_277,
4_646_224_747_067_156,
4_938_125_485_141_739,
5_248_364_991_899_922,
5_578_095_407_069_235,
5_928_541_253_969_291,
6_301_003_987_036_955,
6_696_866_825_051_405,
7_117_599_888_008_300,
7_564_765_656_719_910,
8_040_024_775_416_580,
8_545_142_218_898_723,
9_081_993_847_142_344,
9_652_573_371_700_016,
10_258_999_759_768_490,
10_903_525_103_419_522,
11_588_542_983_217_942,
12_316_597_357_287_042,
13_090_392_008_832_678,
13_912_800_587_211_472,
14_786_877_279_832_732,
15_715_868_154_526_436,
16_703_223_214_499_558,
17_752_609_210_649_358,
18_867_923_258_814_856,
20_053_307_312_537_008,
21_313_163_545_075_252,
22_652_170_697_804_756,
24_075_301_455_707_600,
25_587_840_914_485_432,
27_195_406_207_875_088,
28_903_967_368_057_400,
30_719_869_496_628_636,
32_649_856_328_471_220,
34_701_095_276_033_064,
36_881_204_047_022_752,
39_198_278_934_370_992,
41_660_924_883_519_016,
44_278_287_448_695_240,
47_060_086_756_856_400,
50_016_653_605_425_536,
53_158_967_827_883_320,
56_498_699_069_691_424,
60_048_250_125_977_912,
63_820_803_001_928_304,
67_830_367_866_937_216,
72_091_835_084_322_176,
76_621_030_509_822_880,
81_434_774_264_248_528,
86_550_943_198_537_824,
91_988_537_283_208_848,
97_767_750_168_749_840,
103_910_044_178_992_000,
110_438_230_015_967_792,
117_376_551_472_255_616,
124_750_775_465_407_920,
132_588_287_728_824_640,
140_918_194_514_440_064,
149_771_430_684_917_568,
159_180_874_596_775_264,
169_181_470_201_085_280,
179_810_356_815_193_344,
191_107_007_047_393_216,
203_113_373_386_768_288,
215_874_044_002_592_672,
229_436_408_331_885_600,
243_850_833_070_063_392,
259_170_849_218_267_264,
275_453_350_882_006_752,
292_758_806_559_399_232,
311_151_483_703_668_992,
330_699_687_393_865_920,
351_476_014_000_157_824,
373_557_620_785_735_808,
397_026_512_446_556_096,
421_969_845_653_044_224,
448_480_252_724_740_928,
476_656_185_639_923_904,
506_602_281_657_757_760,
538_429_751_910_786_752,
572_256_794_410_890_176,
608_209_033_002_485_632,
646_419_983_893_124_352,
687_031_551_494_039_552,
730_194_555_412_054_016,
776_069_290_549_944_960,
824_826_122_395_314_176,
876_646_119_708_695_936,
931_721_726_960_522_368,
990_257_479_014_182_144,
1_052_470_760_709_299_712,
1_118_592_614_166_106_112,
1_188_868_596_808_997_376,
1_263_559_693_295_730_432,
1_342_943_284_738_898_688,
1_427_314_178_819_094_784,
1_516_985_704_615_302_400,
1_612_290_876_218_400_768,
1_713_583_629_449_105_408,
1_821_240_136_273_157_632,
1_935_660_201_795_120_128,
2_057_268_749_018_809_600,
2_186_517_396_888_336_384,
2_323_886_137_470_138_880,
2_469_885_118_504_583_168,
2_625_056_537_947_004_416,
2_789_976_657_533_970_944,
2_965_257_942_852_572_160,
3_151_551_337_860_326_400,
3_349_548_682_302_620_672,
3_559_985_281_005_267_968,
3_783_642_634_583_792_128,
4_021_351_341_710_503_936,
4_273_994_183_717_548_544,
4_542_509_402_991_247_872,
4_827_894_187_332_742_144,
5_131_208_373_224_844_288,
5_453_578_381_757_959_168,
5_796_201_401_831_965_696,
6_160_349_836_169_256_960,
6_547_376_026_650_146_816,
6_958_717_276_519_173_120,
7_395_901_188_113_309_696,
7_860_551_335_934_872_576,
8_354_393_296_137_270_272,
8_879_261_054_815_360_000,
9_437_103_818_898_946_048,
10_029_993_254_943_105_024,
10_660_131_182_698_121_216,
11_329_857_752_030_707_712,
12_041_660_133_563_240_448,
12_798_181_755_305_525_248,
13_602_232_119_581_272_064,
14_456_797_236_706_498_560,
15_365_050_714_167_523_328,
16_330_365_542_480_556_032,
17_356_326_621_502_140_416,
18_446_744_073_709_551_615,
];
1 change: 1 addition & 0 deletions frame/nomination-pools/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl pallet_stake_tracker::Config for Runtime {
type Currency = Balances;
type Staking = Staking;
type VoterList = VoterList;
type TargetList = pallet_staking::UseValidatorsMap<Runtime>;
}

parameter_types! {
Expand Down
Loading