Skip to content

Commit dfabf43

Browse files
committed
Merge devnet-ready
2 parents 46f0295 + 1f27c9f commit dfabf43

File tree

8 files changed

+973
-172
lines changed

8 files changed

+973
-172
lines changed

pallets/subtensor/src/coinbase/block_emission.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ impl<T: Config> Pallet<T> {
6868
}
6969

7070
// Set Alpha in emission.
71-
let alpha_out_emission = I96F32::saturating_from_num(2)
72-
.saturating_mul(float_alpha_block_emission)
73-
.saturating_sub(alpha_in_emission);
71+
let alpha_out_emission = float_alpha_block_emission;
7472

7573
// Log results.
7674
log::debug!("{:?} - tao_in_emission: {:?}", netuid, tao_in_emission);

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 215 additions & 117 deletions
Large diffs are not rendered by default.

pallets/subtensor/src/migrations/migrate_rao.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ pub fn migrate_rao<T: Config>() -> Weight {
9898
SubnetOwnerHotkey::<T>::insert(netuid, owner_coldkey.clone());
9999
// Associate the coldkey to coldkey.
100100
Pallet::<T>::create_account_if_non_existent(&owner_coldkey, &owner_coldkey);
101-
// Register the owner_coldkey as neuron to the network.
102-
let _neuron_uid: u16 = Pallet::<T>::register_neuron(*netuid, &owner_coldkey);
101+
102+
// Only register the owner coldkey if it's not already a hotkey on the subnet.
103+
if !Uids::<T>::contains_key(*netuid, &owner_coldkey) {
104+
// Register the owner_coldkey as neuron to the network.
105+
let _neuron_uid: u16 = Pallet::<T>::register_neuron(*netuid, &owner_coldkey);
106+
}
103107
// Register the neuron immediately.
104108
if !Identities::<T>::contains_key(owner_coldkey.clone()) {
105109
// Set the identitiy for the Owner coldkey if non existent.

pallets/subtensor/src/rpc_info/metagraph.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use frame_support::pallet_prelude::{Decode, Encode};
66
use substrate_fixed::types::I64F64;
77
use subtensor_macros::freeze_struct;
88

9-
#[freeze_struct("eff674535ea437ae")]
9+
#[freeze_struct("bce2310daa502e48")]
1010
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
1111
pub struct Metagraph<T: Config> {
1212
// Subnet index
@@ -82,7 +82,7 @@ pub struct Metagraph<T: Config> {
8282
// Metagraph info.
8383
hotkeys: Vec<T::AccountId>, // hotkey per UID
8484
coldkeys: Vec<T::AccountId>, // coldkey per UID
85-
identities: Vec<ChainIdentityOf>, // coldkeys identities
85+
identities: Vec<Option<ChainIdentityOf>>, // coldkeys identities
8686
axons: Vec<AxonInfo>, // UID axons.
8787
active: Vec<bool>, // Avtive per UID
8888
validator_permit: Vec<bool>, // Val permit per UID
@@ -114,15 +114,15 @@ impl<T: Config> Pallet<T> {
114114
let mut hotkeys: Vec<T::AccountId> = vec![];
115115
let mut coldkeys: Vec<T::AccountId> = vec![];
116116
let mut block_at_registration: Vec<Compact<u64>> = vec![];
117-
let mut identities: Vec<ChainIdentityOf> = vec![];
117+
let mut identities: Vec<Option<ChainIdentityOf>> = vec![];
118118
let mut axons: Vec<AxonInfo> = vec![];
119119
for uid in 0..n {
120120
let hotkey = Keys::<T>::get(netuid, uid);
121121
let coldkey = Owner::<T>::get(hotkey.clone());
122122
hotkeys.push(hotkey.clone());
123123
coldkeys.push(coldkey.clone());
124124
block_at_registration.push(BlockAtRegistration::<T>::get(netuid, uid).into());
125-
identities.push(Identities::<T>::get(coldkey.clone())?);
125+
identities.push(Identities::<T>::get(coldkey.clone()));
126126
axons.push(Self::get_axon_info(netuid, &hotkey));
127127
}
128128
let mut tao_dividends_per_hotkey: Vec<(T::AccountId, Compact<u64>)> = vec![];

pallets/subtensor/src/subnets/registration.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,29 @@ impl<T: Config> Pallet<T> {
119119
Error::<T>::NotEnoughBalanceToStake
120120
);
121121

122-
// --- 8. Ensure the remove operation from the coldkey is a success.
123-
let actual_burn_amount =
124-
Self::remove_balance_from_coldkey_account(&coldkey, registration_cost)?;
125-
126-
// Tokens are swapped and then burned.
127-
let burned_alpha: u64 = Self::swap_tao_for_alpha(netuid, actual_burn_amount);
128-
SubnetAlphaOut::<T>::mutate(netuid, |total| *total = total.saturating_sub(burned_alpha));
129-
130-
// --- 9. If the network account does not exist we will create it here.
122+
// If the network account does not exist we will create it here.
131123
Self::create_account_if_non_existent(&coldkey, &hotkey);
132124

133-
// --- 10. Ensure that the pairing is correct.
125+
// --- 8. Ensure that the pairing is correct.
134126
ensure!(
135127
Self::coldkey_owns_hotkey(&coldkey, &hotkey),
136128
Error::<T>::NonAssociatedColdKey
137129
);
138130

139-
// Possibly there is no neuron slots at all.
131+
// --- 9. Possibly there are no neuron slots at all.
140132
ensure!(
141133
Self::get_max_allowed_uids(netuid) != 0,
142134
Error::<T>::NoNeuronIdAvailable
143135
);
144136

137+
// --- 10. Ensure the remove operation from the coldkey is a success.
138+
let actual_burn_amount =
139+
Self::remove_balance_from_coldkey_account(&coldkey, registration_cost)?;
140+
141+
// Tokens are swapped and then burned.
142+
let burned_alpha: u64 = Self::swap_tao_for_alpha(netuid, actual_burn_amount);
143+
SubnetAlphaOut::<T>::mutate(netuid, |total| *total = total.saturating_sub(burned_alpha));
144+
145145
// Actually perform the registration.
146146
let neuron_uid: u16 = Self::register_neuron(netuid, &hotkey);
147147

0 commit comments

Comments
 (0)