Skip to content

Commit 6dca681

Browse files
authored
Merge pull request #691 from opentensor/fix-identity-migration
fix identity migration
2 parents f991965 + 3233133 commit 6dca681

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pallets/subtensor/src/macros/hooks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ mod hooks {
6868
.saturating_add(migrations::migrate_populate_staking_hotkeys::migrate_populate_staking_hotkeys::<T>())
6969
// Fix total coldkey stake.
7070
// Storage version v8 -> v9
71-
.saturating_add(migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::<T>());
71+
.saturating_add(migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::<T>())
72+
// Migrate Delegate Ids on chain
73+
.saturating_add(migrations::migrate_chain_identity::migrate_set_hotkey_identities::<T>());
7274
weight
7375
}
7476

pallets/subtensor/src/migrations/migrate_chain_identity.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn string_to_bounded_vec(input: &str) -> Result<BoundedVec<u8, ConstU32<1024>>,
3131
}
3232

3333
pub fn migrate_set_hotkey_identities<T: Config>() -> Weight {
34-
let migration_name = b"fix_total_coldkey_stake_v7".to_vec();
34+
let migration_name = b"migrate_identities".to_vec();
3535

3636
// Initialize the weight with one read operation.
3737
let mut weight = T::DbWeight::get().reads(1);
@@ -140,17 +140,22 @@ pub fn migrate_set_hotkey_identities<T: Config>() -> Weight {
140140
&& identity.description.len() <= 1024
141141
&& identity.additional.len() <= 1024;
142142
if !is_valid {
143+
log::info!("Bytes not correct");
143144
continue;
144145
}
145146

146147
// Get the owning coldkey.
147148
let coldkey = Owner::<T>::get(decoded_hotkey.clone());
149+
log::info!("ColdKey: {:?}", decoded_hotkey);
150+
148151
weight = weight.saturating_add(T::DbWeight::get().reads(1));
149152

150153
// Sink into the map.
151154
Identities::<T>::insert(coldkey.clone(), identity.clone());
152155
weight = weight.saturating_add(T::DbWeight::get().writes(1));
153156
}
157+
} else {
158+
log::info!("Failed to decode JSON");
154159
}
155160
// Mark the migration as completed
156161
HasMigrationRun::<T>::insert(&migration_name, true);

0 commit comments

Comments
 (0)