Skip to content

Commit baa73dd

Browse files
committed
update moving prices outside of coinbase
1 parent 5e27910 commit baa73dd

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

pallets/subtensor/src/coinbase/block_step.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ impl<T: Config + pallet_drand::Config> Pallet<T> {
2121

2222
// --- 3. Reveal matured weights.
2323
Self::reveal_crv3_commits();
24+
// --- 4. Run emission through network.
2425
Self::run_coinbase(block_emission);
25-
// --- 4. Set pending children on the epoch; but only after the coinbase has been run.
26+
// --- 5. Update moving prices AFTER using them for emissions.
27+
Self::update_moving_prices();
28+
// --- 6. Set pending children on the epoch; but only after the coinbase has been run.
2629
Self::try_set_pending_children(block_number);
27-
// --- 5. Run auto-claim root divs.
30+
// --- 7. Run auto-claim root divs.
2831
Self::run_auto_claim_root_divs(last_block_hash);
29-
// --- 6. Populate root coldkey maps.
32+
// --- 8. Populate root coldkey maps.
3033
Self::populate_root_coldkey_staking_maps();
3134

3235
// Return ok.
@@ -264,6 +267,16 @@ impl<T: Config + pallet_drand::Config> Pallet<T> {
264267
}
265268
}
266269

270+
pub fn update_moving_prices() {
271+
let subnets_to_emit_to: Vec<NetUid> =
272+
Self::get_subnets_to_emit_to(&Self::get_all_subnet_netuids());
273+
// Only update price EMA for subnets that we emit to.
274+
for netuid_i in subnets_to_emit_to.iter() {
275+
// Update moving prices after using them above.
276+
Self::update_moving_price(*netuid_i);
277+
}
278+
}
279+
267280
pub fn reveal_crv3_commits() {
268281
let netuids: Vec<NetUid> = Self::get_all_subnet_netuids();
269282
for netuid in netuids.into_iter().filter(|netuid| *netuid != NetUid::ROOT) {

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,8 @@ impl<T: Config> Pallet<T> {
215215
*total = total.saturating_add(tou64!(pending_alpha).into());
216216
});
217217
}
218-
219-
// --- 7. Update moving prices after using them in the emission calculation.
220-
// Only update price EMA for subnets that we emit to.
221-
for netuid_i in subnets_to_emit_to.iter() {
222-
// Update moving prices after using them above.
223-
Self::update_moving_price(*netuid_i);
224-
}
225-
226-
// --- 8. Drain pending emission through the subnet based on tempo.
218+
219+
// --- Drain pending emissions for all subnets hat are at their tempo.
227220
// Run the epoch for *all* subnets, even if we don't emit anything.
228221
for &netuid in subnets.iter() {
229222

0 commit comments

Comments
 (0)