Skip to content

Commit c411178

Browse files
authored
Merge pull request #1334 from opentensor/devnet-ready
devnet deploy 2/24/2025
2 parents f8ad7e5 + 2d70704 commit c411178

23 files changed

+663
-833
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub mod pallet {
2929
use frame_system::pallet_prelude::*;
3030
use pallet_evm_chain_id::{self, ChainId};
3131
use sp_runtime::BoundedVec;
32+
use substrate_fixed::types::I96F32;
3233

3334
/// The main data structure of the module.
3435
#[pallet::pallet]
@@ -1377,6 +1378,28 @@ pub mod pallet {
13771378
}
13781379
Ok(())
13791380
}
1381+
1382+
///
1383+
///
1384+
/// # Arguments
1385+
/// * `origin` - The origin of the call, which must be the root account.
1386+
/// * `precompile_id` - The identifier of the EVM precompile to toggle.
1387+
/// * `enabled` - The new enablement state of the precompile.
1388+
///
1389+
/// # Errors
1390+
/// * `BadOrigin` - If the caller is not the root account.
1391+
///
1392+
/// # Weight
1393+
/// Weight is handled by the `#[pallet::weight]` attribute.
1394+
#[pallet::call_index(63)]
1395+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1396+
pub fn sudo_set_subnet_moving_alpha(origin: OriginFor<T>, alpha: I96F32) -> DispatchResult {
1397+
ensure_root(origin)?;
1398+
pallet_subtensor::SubnetMovingAlpha::<T>::set(alpha);
1399+
1400+
log::debug!("SubnetMovingAlphaSet( alpha: {:?} )", alpha);
1401+
Ok(())
1402+
}
13801403
}
13811404
}
13821405

pallets/admin-utils/src/tests/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use pallet_subtensor::Error as SubtensorError;
1010
use pallet_subtensor::Event;
1111
use sp_consensus_grandpa::AuthorityId as GrandpaId;
1212
use sp_core::{Pair, U256, ed25519};
13+
use substrate_fixed::types::I96F32;
1314

1415
use crate::Error;
1516
use crate::pallet::PrecompileEnable;
@@ -1449,3 +1450,19 @@ fn test_sudo_toggle_evm_precompile() {
14491450
assert!(final_enabled);
14501451
});
14511452
}
1453+
1454+
#[test]
1455+
fn test_sudo_root_sets_subnet_moving_alpha() {
1456+
new_test_ext().execute_with(|| {
1457+
let alpha: I96F32 = I96F32::saturating_from_num(0.5);
1458+
let initial = pallet_subtensor::SubnetMovingAlpha::<Test>::get();
1459+
assert!(initial != alpha);
1460+
1461+
assert_ok!(AdminUtils::sudo_set_subnet_moving_alpha(
1462+
<<Test as Config>::RuntimeOrigin>::root(),
1463+
alpha
1464+
));
1465+
1466+
assert_eq!(pallet_subtensor::SubnetMovingAlpha::<Test>::get(), alpha);
1467+
});
1468+
}

pallets/subtensor/src/epoch/run_epoch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<T: Config> Pallet<T> {
390390
.iter()
391391
.map(|updated| updated.saturating_add(activity_cutoff) < current_block)
392392
.collect();
393-
log::trace!("Inactive: {:?}", inactive.clone());
393+
log::debug!("Inactive: {:?}", inactive.clone());
394394

395395
// Logical negation of inactive.
396396
let active: Vec<bool> = inactive.iter().map(|&b| !b).collect();
@@ -406,14 +406,14 @@ impl<T: Config> Pallet<T> {
406406
let hotkeys: Vec<(u16, T::AccountId)> =
407407
<Keys<T> as IterableStorageDoubleMap<u16, u16, T::AccountId>>::iter_prefix(netuid)
408408
.collect();
409-
log::trace!("hotkeys: {:?}", &hotkeys);
409+
log::debug!("hotkeys: {:?}", &hotkeys);
410410

411411
// Access network stake as normalized vector.
412412
let (mut total_stake, _alpha_stake, _tao_stake): (Vec<I64F64>, Vec<I64F64>, Vec<I64F64>) =
413413
Self::get_stake_weights_for_network(netuid);
414414
inplace_normalize_64(&mut total_stake);
415415
let stake: Vec<I32F32> = vec_fixed64_to_fixed32(total_stake);
416-
log::trace!("Normalised Stake: {:?}", &stake);
416+
log::debug!("Normalised Stake: {:?}", &stake);
417417

418418
// =======================
419419
// == Validator permits ==
@@ -448,7 +448,7 @@ impl<T: Config> Pallet<T> {
448448

449449
// Normalize active stake.
450450
inplace_normalize(&mut active_stake);
451-
log::trace!("Active Stake:\n{:?}\n", &active_stake);
451+
log::debug!("Active Stake:\n{:?}\n", &active_stake);
452452

453453
// =============
454454
// == Weights ==

pallets/subtensor/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -998,18 +998,6 @@ pub mod pallet {
998998
#[pallet::storage] // --- MAP ( cold ) --> Vec<hot> | Returns the vector of hotkeys controlled by this coldkey.
999999
pub type OwnedHotkeys<T: Config> =
10001000
StorageMap<_, Blake2_128Concat, T::AccountId, Vec<T::AccountId>, ValueQuery>;
1001-
#[pallet::storage]
1002-
/// (DEPRECATED) DMAP ( hot, cold ) --> stake | Returns the stake under a coldkey prefixed by hotkey.
1003-
pub type Stake<T: Config> = StorageDoubleMap<
1004-
_,
1005-
Blake2_128Concat,
1006-
T::AccountId,
1007-
Identity,
1008-
T::AccountId,
1009-
u64,
1010-
ValueQuery,
1011-
DefaultZeroU64<T>,
1012-
>;
10131001

10141002
#[pallet::storage] // --- DMAP ( cold ) --> () | Maps coldkey to if a coldkey swap is scheduled.
10151003
pub type ColdkeySwapScheduled<T: Config> =

pallets/subtensor/src/macros/hooks.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ mod hooks {
6363
// Populate OwnedHotkeys map for coldkey swap. Doesn't update storage vesion.
6464
// Storage version v6 -> v7
6565
.saturating_add(migrations::migrate_populate_owned_hotkeys::migrate_populate_owned::<T>())
66-
// Populate StakingHotkeys map for coldkey swap. Doesn't update storage vesion.
67-
// Storage version v7 -> v8
68-
.saturating_add(migrations::migrate_populate_staking_hotkeys::migrate_populate_staking_hotkeys::<T>())
69-
// Fix total coldkey stake.
70-
// Storage version v8 -> v9
71-
.saturating_add(migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::<T>())
7266
// Migrate Delegate Ids on chain
7367
.saturating_add(migrations::migrate_chain_identity::migrate_set_hotkey_identities::<T>())
7468
// Migrate Commit-Reval 2.0
@@ -83,7 +77,9 @@ mod hooks {
8377
// Set the min burn across all subnets to a new minimum
8478
.saturating_add(migrations::migrate_set_min_burn::migrate_set_min_burn::<T>())
8579
// Set the min difficulty across all subnets to a new minimum
86-
.saturating_add(migrations::migrate_set_min_difficulty::migrate_set_min_difficulty::<T>());
80+
.saturating_add(migrations::migrate_set_min_difficulty::migrate_set_min_difficulty::<T>())
81+
// Remove Stake map entries
82+
.saturating_add(migrations::migrate_remove_stake_map::migrate_remove_stake_map::<T>());
8783
weight
8884
}
8985

pallets/subtensor/src/migrations/migrate_fix_total_coldkey_stake.rs

Lines changed: 0 additions & 91 deletions
This file was deleted.

pallets/subtensor/src/migrations/migrate_populate_staking_hotkeys.rs

Lines changed: 0 additions & 83 deletions
This file was deleted.

pallets/subtensor/src/migrations/migrate_rao.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use frame_support::IterableStorageMap;
44
use frame_support::{traits::Get, weights::Weight};
55
use sp_runtime::format;
66
use substrate_fixed::types::I96F32;
7-
use substrate_fixed::types::U64F64;
87

98
use super::*;
109

@@ -36,29 +35,30 @@ pub fn migrate_rao<T: Config>() -> Weight {
3635
DynamicBlock::<T>::set(Pallet::<T>::get_current_block_as_u64());
3736

3837
// Migrate all TAO to root.
39-
Stake::<T>::iter().for_each(|(hotkey, coldkey, stake)| {
40-
// Increase SubnetTAO on root.
41-
SubnetTAO::<T>::mutate(0, |total| {
42-
*total = total.saturating_add(stake);
43-
});
44-
// Increase SubnetAlphaOut on root.
45-
SubnetAlphaOut::<T>::mutate(0, |total| {
46-
*total = total.saturating_add(stake);
47-
});
48-
// Set all the stake on root 0 subnet.
49-
Alpha::<T>::mutate((hotkey.clone(), coldkey.clone(), 0), |total| {
50-
*total = total.saturating_add(U64F64::saturating_from_num(stake))
51-
});
52-
TotalHotkeyShares::<T>::mutate(hotkey.clone(), 0, |total| {
53-
*total = total.saturating_add(U64F64::saturating_from_num(stake))
54-
});
55-
// Set the total stake on the hotkey
56-
TotalHotkeyAlpha::<T>::mutate(hotkey.clone(), 0, |total| {
57-
*total = total.saturating_add(stake)
58-
});
59-
// 6 reads and 6 writes.
60-
weight = weight.saturating_add(T::DbWeight::get().reads_writes(6, 6));
61-
});
38+
// This migration has already run, leaving this only for reference for now, since this is a recent migration
39+
// Stake::<T>::iter().for_each(|(hotkey, coldkey, stake)| {
40+
// // Increase SubnetTAO on root.
41+
// SubnetTAO::<T>::mutate(0, |total| {
42+
// *total = total.saturating_add(stake);
43+
// });
44+
// // Increase SubnetAlphaOut on root.
45+
// SubnetAlphaOut::<T>::mutate(0, |total| {
46+
// *total = total.saturating_add(stake);
47+
// });
48+
// // Set all the stake on root 0 subnet.
49+
// Alpha::<T>::mutate((hotkey.clone(), coldkey.clone(), 0), |total| {
50+
// *total = total.saturating_add(U64F64::saturating_from_num(stake))
51+
// });
52+
// TotalHotkeyShares::<T>::mutate(hotkey.clone(), 0, |total| {
53+
// *total = total.saturating_add(U64F64::saturating_from_num(stake))
54+
// });
55+
// // Set the total stake on the hotkey
56+
// TotalHotkeyAlpha::<T>::mutate(hotkey.clone(), 0, |total| {
57+
// *total = total.saturating_add(stake)
58+
// });
59+
// // 6 reads and 6 writes.
60+
// weight = weight.saturating_add(T::DbWeight::get().reads_writes(6, 6));
61+
// });
6262

6363
// Convert subnets and give them lock.
6464
// Set global weight to 18% from the start

0 commit comments

Comments
 (0)