@@ -72,6 +72,7 @@ pub mod pallet {
7272 use frame_system:: pallet_prelude:: * ;
7373 use sp_core:: H256 ;
7474 use sp_runtime:: traits:: { Dispatchable , TrailingZeroInput } ;
75+ use sp_std:: collections:: vec_deque:: VecDeque ;
7576 use sp_std:: vec;
7677 use sp_std:: vec:: Vec ;
7778 use subtensor_macros:: freeze_struct;
@@ -568,6 +569,11 @@ pub mod pallet {
568569 0
569570 }
570571 #[ pallet:: type_value]
572+ /// Default minimum stake for weights.
573+ pub fn DefaultRevealPeriodEpochs < T : Config > ( ) -> u64 {
574+ 1
575+ }
576+ #[ pallet:: type_value]
571577 /// Value definition for vector of u16.
572578 pub fn EmptyU16Vec < T : Config > ( ) -> Vec < u16 > {
573579 vec ! [ ]
@@ -629,11 +635,6 @@ pub mod pallet {
629635 T :: InitialServingRateLimit :: get ( )
630636 }
631637 #[ pallet:: type_value]
632- /// Default value for weight commit reveal interval.
633- pub fn DefaultWeightCommitRevealInterval < T : Config > ( ) -> u64 {
634- 1000
635- }
636- #[ pallet:: type_value]
637638 /// Default value for weight commit/reveal enabled.
638639 pub fn DefaultCommitRevealWeightsEnabled < T : Config > ( ) -> bool {
639640 false
@@ -1032,10 +1033,6 @@ pub mod pallet {
10321033 StorageMap < _ , Identity , u16 , u64 , ValueQuery , DefaultAdjustmentAlpha < T > > ;
10331034 #[ pallet:: storage]
10341035 /// --- MAP ( netuid ) --> interval
1035- pub type WeightCommitRevealInterval < T > =
1036- StorageMap < _ , Identity , u16 , u64 , ValueQuery , DefaultWeightCommitRevealInterval < T > > ;
1037- #[ pallet:: storage]
1038- /// --- MAP ( netuid ) --> interval
10391036 pub type CommitRevealWeightsEnabled < T > =
10401037 StorageMap < _ , Identity , u16 , bool , ValueQuery , DefaultCommitRevealWeightsEnabled < T > > ;
10411038 #[ pallet:: storage]
@@ -1254,16 +1251,20 @@ pub mod pallet {
12541251 /// ITEM( weights_min_stake )
12551252 pub type WeightsMinStake < T > = StorageValue < _ , u64 , ValueQuery , DefaultWeightsMinStake < T > > ;
12561253 #[ pallet:: storage]
1257- /// --- MAP (netuid, who) --> (hash, weight) | Returns the hash and weight committed by an account for a given netuid.
1254+ /// --- MAP (netuid, who) --> VecDeque< (hash, commit_block)> | Stores a queue of commits for an account on a given netuid.
12581255 pub type WeightCommits < T : Config > = StorageDoubleMap <
12591256 _ ,
12601257 Twox64Concat ,
12611258 u16 ,
12621259 Twox64Concat ,
12631260 T :: AccountId ,
1264- ( H256 , u64 ) ,
1261+ VecDeque < ( H256 , u64 ) > ,
12651262 OptionQuery ,
12661263 > ;
1264+ #[ pallet:: storage]
1265+ /// --- Map (netuid) --> Number of epochs allowed for commit reveal periods
1266+ pub type RevealPeriodEpochs < T : Config > =
1267+ StorageMap < _ , Twox64Concat , u16 , u64 , ValueQuery , DefaultRevealPeriodEpochs < T > > ;
12671268
12681269 /// ==================
12691270 /// ==== Genesis =====
@@ -1460,6 +1461,18 @@ where
14601461 Err ( InvalidTransaction :: Custom ( 2 ) . into ( ) )
14611462 }
14621463 }
1464+ Some ( Call :: batch_reveal_weights { netuid, .. } ) => {
1465+ if Self :: check_weights_min_stake ( who) {
1466+ let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
1467+ Ok ( ValidTransaction {
1468+ priority,
1469+ longevity : 1 ,
1470+ ..Default :: default ( )
1471+ } )
1472+ } else {
1473+ Err ( InvalidTransaction :: Custom ( 6 ) . into ( ) )
1474+ }
1475+ }
14631476 Some ( Call :: set_weights { netuid, .. } ) => {
14641477 if Self :: check_weights_min_stake ( who) {
14651478 let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
0 commit comments