Skip to content

Commit 33a5052

Browse files
committed
Merge remote-tracking branch 'origin/devnet-ready' into forbid-saturating-math-lint
2 parents fb94917 + 7c329f9 commit 33a5052

31 files changed

+925
-841
lines changed

docs/rust-setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Use a terminal shell to execute the following commands:
2424
```bash
2525
sudo apt update
2626
# May prompt for location information
27-
sudo apt install -y git clang curl libssl-dev llvm libudev-dev
27+
sudo apt install -y git clang curl libssl-dev llvm libudev-dev make pkg-config protobuf-compiler
2828
```
2929

3030
### Arch Linux

pallets/admin-utils/src/lib.rs

Lines changed: 22 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,27 @@ 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+
/// * `alpha` - The new moving alpha value for the SubnetMovingAlpha.
1387+
///
1388+
/// # Errors
1389+
/// * `BadOrigin` - If the caller is not the root account.
1390+
///
1391+
/// # Weight
1392+
/// Weight is handled by the `#[pallet::weight]` attribute.
1393+
#[pallet::call_index(63)]
1394+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1395+
pub fn sudo_set_subnet_moving_alpha(origin: OriginFor<T>, alpha: I96F32) -> DispatchResult {
1396+
ensure_root(origin)?;
1397+
pallet_subtensor::SubnetMovingAlpha::<T>::set(alpha);
1398+
1399+
log::debug!("SubnetMovingAlphaSet( alpha: {:?} )", alpha);
1400+
Ok(())
1401+
}
13801402
}
13811403
}
13821404

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/dispatches.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,5 +1882,30 @@ mod dispatches {
18821882
allow_partial,
18831883
)
18841884
}
1885+
1886+
/// Attempts to associate a hotkey with a coldkey.
1887+
///
1888+
/// # Arguments
1889+
/// * `origin` - The origin of the transaction, which must be signed by the coldkey that owns the `hotkey`.
1890+
/// * `hotkey` - The hotkey to associate with the coldkey.
1891+
///
1892+
/// # Note
1893+
/// Will charge based on the weight even if the hotkey is already associated with a coldkey.
1894+
#[pallet::call_index(91)]
1895+
#[pallet::weight((
1896+
Weight::from_parts(3_000_000, 0).saturating_add(T::DbWeight::get().reads_writes(3, 3)),
1897+
DispatchClass::Operational,
1898+
Pays::Yes
1899+
))]
1900+
pub fn try_associate_hotkey(
1901+
origin: T::RuntimeOrigin,
1902+
hotkey: T::AccountId,
1903+
) -> DispatchResult {
1904+
let coldkey = ensure_signed(origin)?;
1905+
1906+
let _ = Self::do_try_associate_hotkey(&coldkey, &hotkey);
1907+
1908+
Ok(())
1909+
}
18851910
}
18861911
}

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.

0 commit comments

Comments
 (0)