@@ -100,52 +100,6 @@ impl<T: Config> Pallet<T> {
100
100
log:: debug!( "alpha_in: {:?}" , alpha_in) ;
101
101
log:: debug!( "alpha_out: {:?}" , alpha_out) ;
102
102
103
- // --- 7. Drain pending emission through the subnet based on tempo.
104
- for & netuid in subnets. iter ( ) {
105
- // Pass on subnets that have not reached their tempo.
106
- if Self :: should_run_epoch ( netuid, current_block) {
107
- if let Err ( e) = Self :: reveal_crv3_commits ( netuid) {
108
- log:: warn!(
109
- "Failed to reveal commits for subnet {} due to error: {:?}" ,
110
- netuid,
111
- e
112
- ) ;
113
- } ;
114
-
115
- // Restart counters.
116
- BlocksSinceLastStep :: < T > :: insert ( netuid, 0 ) ;
117
- LastMechansimStepBlock :: < T > :: insert ( netuid, current_block) ;
118
-
119
- // Get and drain the subnet pending emission.
120
- let pending_alpha: u64 = PendingEmission :: < T > :: get ( netuid) ;
121
- PendingEmission :: < T > :: insert ( netuid, 0 ) ;
122
-
123
- // Get and drain the subnet pending root divs.
124
- let pending_tao: u64 = PendingRootDivs :: < T > :: get ( netuid) ;
125
- PendingRootDivs :: < T > :: insert ( netuid, 0 ) ;
126
-
127
- // Get this amount as alpha that was swapped for pending root divs.
128
- let pending_swapped: u64 = PendingAlphaSwapped :: < T > :: get ( netuid) ;
129
- PendingAlphaSwapped :: < T > :: insert ( netuid, 0 ) ;
130
-
131
- // Get owner cut and drain.
132
- let owner_cut: u64 = PendingOwnerCut :: < T > :: get ( netuid) ;
133
- PendingOwnerCut :: < T > :: insert ( netuid, 0 ) ;
134
-
135
- // Drain pending root divs, alpha emission, and owner cut.
136
- Self :: drain_pending_emission (
137
- netuid,
138
- pending_alpha,
139
- pending_tao,
140
- pending_swapped,
141
- owner_cut,
142
- ) ;
143
- } else {
144
- // Increment
145
- BlocksSinceLastStep :: < T > :: mutate ( netuid, |total| * total = total. saturating_add ( 1 ) ) ;
146
- }
147
- }
148
-
149
103
// --- 4. Injection.
150
104
// Actually perform the injection of alpha_in, alpha_out and tao_in into the subnet pool.
151
105
// This operation changes the pool liquidity each block.
@@ -249,6 +203,52 @@ impl<T: Config> Pallet<T> {
249
203
// Update moving prices after using them above.
250
204
Self :: update_moving_price ( * netuid_i) ;
251
205
}
206
+
207
+ // --- 7. Drain pending emission through the subnet based on tempo.
208
+ for & netuid in subnets. iter ( ) {
209
+ // Pass on subnets that have not reached their tempo.
210
+ if Self :: should_run_epoch ( netuid, current_block) {
211
+ if let Err ( e) = Self :: reveal_crv3_commits ( netuid) {
212
+ log:: warn!(
213
+ "Failed to reveal commits for subnet {} due to error: {:?}" ,
214
+ netuid,
215
+ e
216
+ ) ;
217
+ } ;
218
+
219
+ // Restart counters.
220
+ BlocksSinceLastStep :: < T > :: insert ( netuid, 0 ) ;
221
+ LastMechansimStepBlock :: < T > :: insert ( netuid, current_block) ;
222
+
223
+ // Get and drain the subnet pending emission.
224
+ let pending_alpha: u64 = PendingEmission :: < T > :: get ( netuid) ;
225
+ PendingEmission :: < T > :: insert ( netuid, 0 ) ;
226
+
227
+ // Get and drain the subnet pending root divs.
228
+ let pending_tao: u64 = PendingRootDivs :: < T > :: get ( netuid) ;
229
+ PendingRootDivs :: < T > :: insert ( netuid, 0 ) ;
230
+
231
+ // Get this amount as alpha that was swapped for pending root divs.
232
+ let pending_swapped: u64 = PendingAlphaSwapped :: < T > :: get ( netuid) ;
233
+ PendingAlphaSwapped :: < T > :: insert ( netuid, 0 ) ;
234
+
235
+ // Get owner cut and drain.
236
+ let owner_cut: u64 = PendingOwnerCut :: < T > :: get ( netuid) ;
237
+ PendingOwnerCut :: < T > :: insert ( netuid, 0 ) ;
238
+
239
+ // Drain pending root divs, alpha emission, and owner cut.
240
+ Self :: drain_pending_emission (
241
+ netuid,
242
+ pending_alpha,
243
+ pending_tao,
244
+ pending_swapped,
245
+ owner_cut,
246
+ ) ;
247
+ } else {
248
+ // Increment
249
+ BlocksSinceLastStep :: < T > :: mutate ( netuid, |total| * total = total. saturating_add ( 1 ) ) ;
250
+ }
251
+ }
252
252
}
253
253
254
254
pub fn drain_pending_emission (
0 commit comments