Skip to content

Commit c84fadd

Browse files
committed
fix weights issue
1 parent 95c447d commit c84fadd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pallets/subtensor/src/epoch.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ 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 {
737+
continue;
738+
}
736739
for (uid_j, weight_ij) in weights_i.iter() {
737740
weights[uid_i as usize].push((*uid_j, I32F32::from_num(*weight_ij)));
738741
}

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(

0 commit comments

Comments
 (0)