subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

remove stake records with value 0

Open cuteolaf opened this issue 1 year ago • 5 comments
trafficstars

This is the definition of the storage item Stake.

#[pallet::storage] // --- DMAP ( hot, cold ) --> stake | Returns the stake under a coldkey prefixed by hotkey.
pub type Stake<T: Config> = StorageDoubleMap<
    _,
    Blake2_128Concat,
    T::AccountId,
    Identity,
    T::AccountId,
    u64,
    ValueQuery,
    DefaultAccountTake<T>,
>;

I have run a simple script to get all the records of this storage item and it showed that more than 60% of the records are having value 0.

33234 out of 53273 items are zero

It is defined with the option ValueQuery, with default value 0, so we don't need to keep these records.

cuteolaf avatar Dec 14 '23 16:12 cuteolaf

@camfairchild @Eugene-hu @shibshib @S0AndS0

cuteolaf avatar Dec 14 '23 16:12 cuteolaf

Would be good to remove zero valued items in the next runtime upgrade by storage migration.

cuteolaf avatar Dec 14 '23 16:12 cuteolaf

We'll include this in our dependency update and refactor branch, thank you for contributing.

Rubberbandits avatar Dec 22 '23 20:12 Rubberbandits

Please close in favour of https://github.com/opentensor/subtensor/pull/361

camfairchild avatar Apr 26 '24 00:04 camfairchild

We'll also need a migration to remove zero values that are already in the state. I am going to add it in dynamic branch for dtao.

gztensor avatar May 08 '24 15:05 gztensor

closing in favour of #361

distributedstatemachine avatar Jul 02 '24 15:07 distributedstatemachine