-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[Feature] P2 Staking Tracker #12744
[Feature] P2 Staking Tracker #12744
Changes from all commits
91dd322
e8127c7
c809c57
99bd9d7
0d4a022
c5bb19c
5549a78
1666bdc
e7cfb35
54b2e33
da8f780
c89d8ec
7fcafe0
6689460
9f3e436
bed5ad4
84ec3d4
f65e5bd
c11877f
345585e
09550de
69b27c5
b9b4978
1cd145a
3297703
c618967
6b33afc
bd18275
9c70db7
9b3fdf9
4a126cc
70fceb5
9a90e4b
85529a3
08118a4
ace54bb
ea35228
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -553,6 +553,13 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { | |
| type MaxValidators = ConstU32<1000>; | ||
| } | ||
|
|
||
| impl pallet_stake_tracker::Config for Runtime { | ||
| type Currency = Balances; | ||
| type Staking = Staking; | ||
| type VoterList = VoterListTracker; | ||
| type TargetList = TargetList; | ||
|
Comment on lines
+559
to
+560
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the names in two lines are not consistent -- either both
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea here is that the TargetList is not used in Staking yet, so we can start tracking it in staking-tracker and then passing it to Staking without any migrations. |
||
| } | ||
|
|
||
| impl pallet_staking::Config for Runtime { | ||
| type MaxNominations = MaxNominations; | ||
| type Currency = Balances; | ||
|
|
@@ -586,6 +593,7 @@ impl pallet_staking::Config for Runtime { | |
| type OnStakerSlash = NominationPools; | ||
| type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>; | ||
| type BenchmarkingConfig = StakingBenchmarkingConfig; | ||
| type EventListener = StakeTracker; | ||
| } | ||
|
|
||
| impl pallet_fast_unstake::Config for Runtime { | ||
|
|
@@ -750,7 +758,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { | |
| } | ||
|
|
||
| parameter_types! { | ||
| pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS; | ||
| pub const BagThresholds: &'static [VoteWeight] = &voter_bags::THRESHOLDS; | ||
| } | ||
|
|
||
| type VoterBagsListInstance = pallet_bags_list::Instance1; | ||
|
|
@@ -764,6 +772,33 @@ impl pallet_bags_list::Config<VoterBagsListInstance> for Runtime { | |
| type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>; | ||
| } | ||
|
|
||
| // A special VoterList instance used to test the StakeTracker. | ||
| type VoterBagsListTrackerInstance = pallet_bags_list::Instance3; | ||
kianenigma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| impl pallet_bags_list::Config<VoterBagsListTrackerInstance> for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| // 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; | ||
| type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>; | ||
| } | ||
|
|
||
| parameter_types! { | ||
| pub const BagThresholdsBalances: &'static [Balance] = &voter_bags::THRESHOLDS_BALANCES; | ||
| } | ||
|
|
||
| // A TargetList, currently populated by StakeTracker, once this has been tested enough - this will | ||
| // be used by pallet-staking as a list of electable targets. | ||
| type TargetBagsListInstance = pallet_bags_list::Instance2; | ||
| impl pallet_bags_list::Config<TargetBagsListInstance> for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| type ScoreProvider = StakeTracker; | ||
| type BagThresholds = BagThresholdsBalances; | ||
| type Score = Balance; | ||
| type WeightInfo = pallet_bags_list::weights::SubstrateWeight<Runtime>; | ||
| } | ||
|
|
||
| parameter_types! { | ||
| pub const PostUnbondPoolsWindow: u32 = 4; | ||
| pub const NominationPoolsPalletId: PalletId = PalletId(*b"py/nopls"); | ||
|
|
@@ -1743,6 +1778,9 @@ construct_runtime!( | |
| Nfts: pallet_nfts, | ||
| TransactionStorage: pallet_transaction_storage, | ||
| VoterList: pallet_bags_list::<Instance1>, | ||
| TargetList: pallet_bags_list::<Instance2>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these two instances are only going to be used by the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VoterList is used in the original Staking. TargetList, once tested, will be passed to Staking as well. It kind of felt strange to be renaming this back and forth, as those lists shouldn't care who tracks them and neither should the Staking pallet. Unfortunately I had to add an ugly VoterListTracker bags-list, but that will be dropped as soon as we have concluded that the original VoterList tracked by Staking and the new one are one and the same. Let me know if this makes sense. |
||
| // A special VoterList tha is used just to see if the stake-tracker works correctly. | ||
| VoterListTracker: pallet_bags_list::<Instance3>, | ||
| StateTrieMigration: pallet_state_trie_migration, | ||
| ChildBounties: pallet_child_bounties, | ||
| Referenda: pallet_referenda, | ||
|
|
@@ -1756,6 +1794,7 @@ construct_runtime!( | |
| RankedPolls: pallet_referenda::<Instance2>, | ||
| RankedCollective: pallet_ranked_collective, | ||
| FastUnstake: pallet_fast_unstake, | ||
| StakeTracker: pallet_stake_tracker, | ||
| MessageQueue: pallet_message_queue, | ||
| } | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.