Skip to content

Commit 3fee5c7

Browse files
kianenigmagpestana
andauthored
remove OnStakerSlash replace with OnStakingEvents (paritytech#14527)
* remove 'OnStakerSlash', replace with 'OnStakingEvents' * fix other features in pallets * small fixes * fix docs * fix docs * fix docs * Update primitives/staking/src/lib.rs Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>
1 parent 70c0547 commit 3fee5c7

28 files changed

Lines changed: 262 additions & 178 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/runtime/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use frame_support::{
3838
tokens::{nonfungibles_v2::Inspect, GetSalary, PayFromAccount},
3939
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU16, ConstU32, Currency, EitherOfDiverse,
4040
EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, KeyOwnerProofSystem,
41-
LockIdentifier, Nothing, OnUnbalanced, U128CurrencyToVote, WithdrawReasons,
41+
LockIdentifier, Nothing, OnUnbalanced, WithdrawReasons,
4242
},
4343
weights::{
4444
constants::{
@@ -575,7 +575,7 @@ impl pallet_staking::Config for Runtime {
575575
type Currency = Balances;
576576
type CurrencyBalance = Balance;
577577
type UnixTime = Timestamp;
578-
type CurrencyToVote = U128CurrencyToVote;
578+
type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
579579
type RewardRemainder = Treasury;
580580
type RuntimeEvent = RuntimeEvent;
581581
type Slash = Treasury; // send the slashed funds to the treasury.
@@ -600,7 +600,7 @@ impl pallet_staking::Config for Runtime {
600600
type TargetList = pallet_staking::UseValidatorsMap<Self>;
601601
type MaxUnlockingChunks = ConstU32<32>;
602602
type HistoryDepth = HistoryDepth;
603-
type OnStakerSlash = NominationPools;
603+
type EventListeners = NominationPools;
604604
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
605605
type BenchmarkingConfig = StakingBenchmarkingConfig;
606606
}
@@ -1047,7 +1047,7 @@ impl pallet_elections_phragmen::Config for Runtime {
10471047
// NOTE: this implies that council's genesis members cannot be set directly and must come from
10481048
// this module.
10491049
type InitializeMembers = Council;
1050-
type CurrencyToVote = U128CurrencyToVote;
1050+
type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
10511051
type CandidacyBond = CandidacyBond;
10521052
type VotingBondBase = VotingBondBase;
10531053
type VotingBondFactor = VotingBondFactor;

frame/babe/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl onchain::Config for OnChainSeqPhragmen {
182182
impl pallet_staking::Config for Test {
183183
type MaxNominations = ConstU32<16>;
184184
type RewardRemainder = ();
185-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
185+
type CurrencyToVote = ();
186186
type RuntimeEvent = RuntimeEvent;
187187
type Currency = Balances;
188188
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
@@ -204,7 +204,7 @@ impl pallet_staking::Config for Test {
204204
type TargetList = pallet_staking::UseValidatorsMap<Self>;
205205
type MaxUnlockingChunks = ConstU32<32>;
206206
type HistoryDepth = ConstU32<84>;
207-
type OnStakerSlash = ();
207+
type EventListeners = ();
208208
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
209209
type WeightInfo = ();
210210
}

frame/beefy/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl onchain::Config for OnChainSeqPhragmen {
206206
impl pallet_staking::Config for Test {
207207
type MaxNominations = ConstU32<16>;
208208
type RewardRemainder = ();
209-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
209+
type CurrencyToVote = ();
210210
type RuntimeEvent = RuntimeEvent;
211211
type Currency = Balances;
212212
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
@@ -228,7 +228,7 @@ impl pallet_staking::Config for Test {
228228
type TargetList = pallet_staking::UseValidatorsMap<Self>;
229229
type MaxUnlockingChunks = ConstU32<32>;
230230
type HistoryDepth = ConstU32<84>;
231-
type OnStakerSlash = ();
231+
type EventListeners = ();
232232
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
233233
type WeightInfo = ();
234234
}

frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl pallet_staking::Config for Runtime {
265265
type Currency = Balances;
266266
type CurrencyBalance = Balance;
267267
type UnixTime = Timestamp;
268-
type CurrencyToVote = traits::SaturatingCurrencyToVote;
268+
type CurrencyToVote = ();
269269
type RewardRemainder = ();
270270
type RuntimeEvent = RuntimeEvent;
271271
type Slash = (); // burn slashes
@@ -285,7 +285,7 @@ impl pallet_staking::Config for Runtime {
285285
type TargetList = pallet_staking::UseValidatorsMap<Self>;
286286
type MaxUnlockingChunks = ConstU32<32>;
287287
type HistoryDepth = HistoryDepth;
288-
type OnStakerSlash = ();
288+
type EventListeners = ();
289289
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
290290
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
291291
}

frame/elections-phragmen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives
2626
sp-npos-elections = { version = "4.0.0-dev", default-features = false, path = "../../primitives/npos-elections" }
2727
sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" }
2828
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
29+
sp-staking = { default-features = false, path = "../../primitives/staking" }
2930

3031
[dev-dependencies]
3132
pallet-balances = { version = "4.0.0-dev", path = "../balances" }

frame/elections-phragmen/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
use codec::{Decode, Encode};
102102
use frame_support::{
103103
traits::{
104-
defensive_prelude::*, ChangeMembers, Contains, ContainsLengthBound, Currency,
105-
CurrencyToVote, Get, InitializeMembers, LockIdentifier, LockableCurrency, OnUnbalanced,
106-
ReservableCurrency, SortedMembers, WithdrawReasons,
104+
defensive_prelude::*, ChangeMembers, Contains, ContainsLengthBound, Currency, Get,
105+
InitializeMembers, LockIdentifier, LockableCurrency, OnUnbalanced, ReservableCurrency,
106+
SortedMembers, WithdrawReasons,
107107
},
108108
weights::Weight,
109109
};
@@ -113,6 +113,7 @@ use sp_runtime::{
113113
traits::{Saturating, StaticLookup, Zero},
114114
DispatchError, Perbill, RuntimeDebug,
115115
};
116+
use sp_staking::currency_to_vote::CurrencyToVote;
116117
use sp_std::{cmp::Ordering, prelude::*};
117118

118119
#[cfg(any(feature = "try-runtime", test))]
@@ -1424,7 +1425,7 @@ mod tests {
14241425
type PalletId = ElectionsPhragmenPalletId;
14251426
type RuntimeEvent = RuntimeEvent;
14261427
type Currency = Balances;
1427-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
1428+
type CurrencyToVote = ();
14281429
type ChangeMembers = TestChangeMembers;
14291430
type InitializeMembers = ();
14301431
type CandidacyBond = CandidacyBond;

frame/fast-unstake/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl pallet_staking::Config for Runtime {
137137
type Currency = Balances;
138138
type CurrencyBalance = Balance;
139139
type UnixTime = pallet_timestamp::Pallet<Self>;
140-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
140+
type CurrencyToVote = ();
141141
type RewardRemainder = ();
142142
type RuntimeEvent = RuntimeEvent;
143143
type Slash = ();
@@ -157,7 +157,7 @@ impl pallet_staking::Config for Runtime {
157157
type VoterList = pallet_staking::UseNominatorsAndValidatorsMap<Self>;
158158
type TargetList = pallet_staking::UseValidatorsMap<Self>;
159159
type MaxUnlockingChunks = ConstU32<32>;
160-
type OnStakerSlash = ();
160+
type EventListeners = ();
161161
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
162162
type WeightInfo = ();
163163
}

frame/grandpa/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl onchain::Config for OnChainSeqPhragmen {
187187
impl pallet_staking::Config for Test {
188188
type MaxNominations = ConstU32<16>;
189189
type RewardRemainder = ();
190-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
190+
type CurrencyToVote = ();
191191
type RuntimeEvent = RuntimeEvent;
192192
type Currency = Balances;
193193
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
@@ -209,7 +209,7 @@ impl pallet_staking::Config for Test {
209209
type TargetList = pallet_staking::UseValidatorsMap<Self>;
210210
type MaxUnlockingChunks = ConstU32<32>;
211211
type HistoryDepth = ConstU32<84>;
212-
type OnStakerSlash = ();
212+
type EventListeners = ();
213213
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
214214
type WeightInfo = ();
215215
}

frame/nomination-pools/benchmarking/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl pallet_staking::Config for Runtime {
9999
type Currency = Balances;
100100
type CurrencyBalance = Balance;
101101
type UnixTime = pallet_timestamp::Pallet<Self>;
102-
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
102+
type CurrencyToVote = ();
103103
type RewardRemainder = ();
104104
type RuntimeEvent = RuntimeEvent;
105105
type Slash = ();
@@ -120,7 +120,7 @@ impl pallet_staking::Config for Runtime {
120120
type TargetList = pallet_staking::UseValidatorsMap<Self>;
121121
type MaxUnlockingChunks = ConstU32<32>;
122122
type HistoryDepth = ConstU32<84>;
123-
type OnStakerSlash = Pools;
123+
type EventListeners = Pools;
124124
type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
125125
type WeightInfo = ();
126126
}

0 commit comments

Comments
 (0)