Skip to content

Commit 3f44be0

Browse files
authored
Merge pull request #259 from opentensor/fix_weights
fix weights issue
2 parents 95c447d + 6935528 commit 3f44be0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

pallets/subtensor/src/epoch.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,13 @@ impl<T: Config> Pallet<T> {
733733
for (uid_i, weights_i) in
734734
<Weights<T> as IterableStorageDoubleMap<u16, u16, Vec<(u16, u16)>>>::iter_prefix(netuid)
735735
{
736+
if uid_i >= n as u16 {
737+
continue;
738+
}
736739
for (uid_j, weight_ij) in weights_i.iter() {
740+
if *uid_j >= n as u16 {
741+
continue;
742+
}
737743
weights[uid_i as usize].push((*uid_j, I32F32::from_num(*weight_ij)));
738744
}
739745
}

pallets/subtensor/src/root.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,9 @@ impl<T: Config> Pallet<T> {
825825
let _ = Keys::<T>::clear_prefix(netuid, u32::max_value(), None);
826826
let _ = Bonds::<T>::clear_prefix(netuid, u32::max_value(), None);
827827

828+
// --- 8. Removes the weights for this subnet (do not remove).
829+
let _ = Weights::<T>::clear_prefix(netuid, u32::max_value(), None);
830+
828831
// --- 9. Iterate over stored weights and fill the matrix.
829832
for (uid_i, weights_i) in
830833
<Weights<T> as IterableStorageDoubleMap<u16, u16, Vec<(u16, u16)>>>::iter_prefix(

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
121121
// `spec_version`, and `authoring_version` are the same between Wasm and native.
122122
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
123123
// the compatible custom types.
124-
spec_version: 143,
124+
spec_version: 144,
125125
impl_version: 1,
126126
apis: RUNTIME_API_VERSIONS,
127127
transaction_version: 1,

0 commit comments

Comments
 (0)