@@ -24,34 +24,25 @@ use frame_system::Pallet as System;
24
24
25
25
/// Run to the specified block number.
26
26
/// Function assumes first block has been initialized.
27
- pub ( super ) fn run_to_block < T : Config > ( n : BlockNumberFor < T > )
28
- where
29
- BlockNumberFor < T > : IsType < BlockNumber > ,
30
- {
27
+ pub ( super ) fn run_to_block < T : Config > ( n : BlockNumberFor < T > ) {
31
28
while System :: < T > :: block_number ( ) < n {
32
29
DappStaking :: < T > :: on_finalize ( System :: < T > :: block_number ( ) ) ;
33
- System :: < T > :: set_block_number ( System :: < T > :: block_number ( ) + 1 . into ( ) ) ;
30
+ System :: < T > :: set_block_number ( System :: < T > :: block_number ( ) + 1u32 . into ( ) ) ;
34
31
// This is performed outside of dapps staking but we expect it before on_initialize
35
32
DappStaking :: < T > :: on_initialize ( System :: < T > :: block_number ( ) ) ;
36
33
}
37
34
}
38
35
39
36
/// Run for the specified number of blocks.
40
37
/// Function assumes first block has been initialized.
41
- pub ( super ) fn run_for_blocks < T : Config > ( n : BlockNumberFor < T > )
42
- where
43
- BlockNumberFor < T > : IsType < BlockNumber > ,
44
- {
38
+ pub ( super ) fn run_for_blocks < T : Config > ( n : BlockNumberFor < T > ) {
45
39
run_to_block :: < T > ( System :: < T > :: block_number ( ) + n) ;
46
40
}
47
41
48
42
/// Advance blocks until the specified era has been reached.
49
43
///
50
44
/// Function has no effect if era is already passed.
51
- pub ( super ) fn advance_to_era < T : Config > ( era : EraNumber )
52
- where
53
- BlockNumberFor < T > : IsType < BlockNumber > ,
54
- {
45
+ pub ( super ) fn advance_to_era < T : Config > ( era : EraNumber ) {
55
46
assert ! ( era >= ActiveProtocolState :: <T >:: get( ) . era) ;
56
47
while ActiveProtocolState :: < T > :: get ( ) . era < era {
57
48
run_for_blocks :: < T > ( One :: one ( ) ) ;
61
52
/// Advance blocks until the specified era has been reached.
62
53
///
63
54
/// Relies on the `force` approach to advance one era per block.
64
- pub ( super ) fn force_advance_to_era < T : Config > ( era : EraNumber )
65
- where
66
- BlockNumberFor < T > : IsType < BlockNumber > ,
67
- {
55
+ pub ( super ) fn force_advance_to_era < T : Config > ( era : EraNumber ) {
68
56
assert ! ( era > ActiveProtocolState :: <T >:: get( ) . era) ;
69
57
while ActiveProtocolState :: < T > :: get ( ) . era < era {
70
58
assert_ok ! ( DappStaking :: <T >:: force(
@@ -76,18 +64,12 @@ where
76
64
}
77
65
78
66
/// Advance blocks until next era has been reached.
79
- pub ( super ) fn _advance_to_next_era < T : Config > ( )
80
- where
81
- BlockNumberFor < T > : IsType < BlockNumber > ,
82
- {
67
+ pub ( super ) fn _advance_to_next_era < T : Config > ( ) {
83
68
advance_to_era :: < T > ( ActiveProtocolState :: < T > :: get ( ) . era + 1 ) ;
84
69
}
85
70
86
71
/// Advance to next era, in the next block using the `force` approach.
87
- pub ( crate ) fn force_advance_to_next_era < T : Config > ( )
88
- where
89
- BlockNumberFor < T > : IsType < BlockNumber > ,
90
- {
72
+ pub ( crate ) fn force_advance_to_next_era < T : Config > ( ) {
91
73
assert_ok ! ( DappStaking :: <T >:: force(
92
74
RawOrigin :: Root . into( ) ,
93
75
ForcingType :: Era
98
80
/// Advance blocks until next period has been reached.
99
81
///
100
82
/// Relies on the `force` approach to advance one subperiod per block.
101
- pub ( super ) fn force_advance_to_next_period < T : Config > ( )
102
- where
103
- BlockNumberFor < T > : IsType < BlockNumber > ,
104
- {
83
+ pub ( super ) fn force_advance_to_next_period < T : Config > ( ) {
105
84
let init_period_number = ActiveProtocolState :: < T > :: get ( ) . period_number ( ) ;
106
85
while ActiveProtocolState :: < T > :: get ( ) . period_number ( ) == init_period_number {
107
86
assert_ok ! ( DappStaking :: <T >:: force(
@@ -113,21 +92,15 @@ where
113
92
}
114
93
115
94
/// Advance to the specified period, using the `force` approach.
116
- pub ( super ) fn force_advance_to_period < T : Config > ( period : PeriodNumber )
117
- where
118
- BlockNumberFor < T > : IsType < BlockNumber > ,
119
- {
95
+ pub ( super ) fn force_advance_to_period < T : Config > ( period : PeriodNumber ) {
120
96
assert ! ( period >= ActiveProtocolState :: <T >:: get( ) . period_number( ) ) ;
121
97
while ActiveProtocolState :: < T > :: get ( ) . period_number ( ) < period {
122
98
force_advance_to_next_subperiod :: < T > ( ) ;
123
99
}
124
100
}
125
101
126
102
/// Use the `force` approach to advance to the next subperiod immediately in the next block.
127
- pub ( super ) fn force_advance_to_next_subperiod < T : Config > ( )
128
- where
129
- BlockNumberFor < T > : IsType < BlockNumber > ,
130
- {
103
+ pub ( super ) fn force_advance_to_next_subperiod < T : Config > ( ) {
131
104
assert_ok ! ( DappStaking :: <T >:: force(
132
105
RawOrigin :: Root . into( ) ,
133
106
ForcingType :: Subperiod
@@ -148,18 +121,12 @@ pub(super) const NUMBER_OF_SLOTS: u32 = 100;
148
121
pub ( super ) const SEED : u32 = 9000 ;
149
122
150
123
/// Assert that the last event equals the provided one.
151
- pub ( super ) fn assert_last_event < T : Config > ( generic_event : <T as Config >:: RuntimeEvent )
152
- where
153
- BlockNumberFor < T > : IsType < BlockNumber > ,
154
- {
124
+ pub ( super ) fn assert_last_event < T : Config > ( generic_event : <T as Config >:: RuntimeEvent ) {
155
125
frame_system:: Pallet :: < T > :: assert_last_event ( generic_event. into ( ) ) ;
156
126
}
157
127
158
128
// Return all dApp staking events from the event buffer.
159
- pub ( super ) fn dapp_staking_events < T : Config > ( ) -> Vec < crate :: Event < T > >
160
- where
161
- BlockNumberFor < T > : IsType < BlockNumber > ,
162
- {
129
+ pub ( super ) fn dapp_staking_events < T : Config > ( ) -> Vec < crate :: Event < T > > {
163
130
System :: < T > :: events ( )
164
131
. into_iter ( )
165
132
. map ( |r| r. event )
@@ -171,10 +138,7 @@ where
171
138
///
172
139
/// **NOTE:** This assumes similar tier configuration for all runtimes.
173
140
/// If we decide to change this, we'll need to provide a more generic init function.
174
- pub ( super ) fn initial_config < T : Config > ( )
175
- where
176
- BlockNumberFor < T > : IsType < BlockNumber > ,
177
- {
141
+ pub ( super ) fn initial_config < T : Config > ( ) {
178
142
let era_length = T :: CycleConfiguration :: blocks_per_era ( ) ;
179
143
let voting_period_length_in_eras = T :: CycleConfiguration :: eras_per_voting_subperiod ( ) ;
180
144
@@ -244,21 +208,15 @@ where
244
208
}
245
209
246
210
/// Maximum number of contracts that 'makes sense' - considers both contract number limit & number of slots.
247
- pub ( super ) fn max_number_of_contracts < T : Config > ( ) -> u32
248
- where
249
- BlockNumberFor < T > : IsType < BlockNumber > ,
250
- {
211
+ pub ( super ) fn max_number_of_contracts < T : Config > ( ) -> u32 {
251
212
T :: MaxNumberOfContracts :: get ( ) . min ( NUMBER_OF_SLOTS ) . into ( )
252
213
}
253
214
254
215
/// Registers & staked on the specified number of smart contracts
255
216
///
256
217
/// Stake amounts are decided in such a way to maximize tier filling rate.
257
218
/// This means that all of the contracts should end up in some tier.
258
- pub ( super ) fn prepare_contracts_for_tier_assignment < T : Config > ( x : u32 )
259
- where
260
- BlockNumberFor < T > : IsType < BlockNumber > ,
261
- {
219
+ pub ( super ) fn prepare_contracts_for_tier_assignment < T : Config > ( x : u32 ) {
262
220
let developer: T :: AccountId = whitelisted_caller ( ) ;
263
221
for id in 0 ..x {
264
222
let smart_contract = T :: BenchmarkHelper :: get_smart_contract ( id as u32 ) ;
@@ -308,20 +266,14 @@ fn trivial_fisher_yates_shuffle<T>(vector: &mut Vec<T>, random_seed: u64) {
308
266
/// Returns max amount of rewards that can be claimed in a single claim reward call from a past period.
309
267
///
310
268
/// Bounded by era reward span length & number of eras per period (not length but absolute number).
311
- pub ( super ) fn max_claim_size_past_period < T : Config > ( ) -> u32
312
- where
313
- BlockNumberFor < T > : IsType < BlockNumber > ,
314
- {
269
+ pub ( super ) fn max_claim_size_past_period < T : Config > ( ) -> u32 {
315
270
T :: EraRewardSpanLength :: get ( ) . min ( T :: CycleConfiguration :: eras_per_build_and_earn_subperiod ( ) )
316
271
}
317
272
318
273
/// Returns max amount of rewards that can be claimed in a single claim reward call from an ongoing period.
319
274
///
320
275
/// Bounded by era reward span length & number of eras per period (not length but absolute number).
321
- pub ( super ) fn max_claim_size_ongoing_period < T : Config > ( ) -> u32
322
- where
323
- BlockNumberFor < T > : IsType < BlockNumber > ,
324
- {
276
+ pub ( super ) fn max_claim_size_ongoing_period < T : Config > ( ) -> u32 {
325
277
T :: EraRewardSpanLength :: get ( )
326
278
. min ( T :: CycleConfiguration :: eras_per_build_and_earn_subperiod ( ) - 1 )
327
279
}
0 commit comments