@@ -72,6 +72,7 @@ pub mod pallet {
72
72
use frame_system:: pallet_prelude:: * ;
73
73
use sp_core:: H256 ;
74
74
use sp_runtime:: traits:: { Dispatchable , TrailingZeroInput } ;
75
+ use sp_std:: collections:: vec_deque:: VecDeque ;
75
76
use sp_std:: vec;
76
77
use sp_std:: vec:: Vec ;
77
78
use subtensor_macros:: freeze_struct;
@@ -568,6 +569,11 @@ pub mod pallet {
568
569
0
569
570
}
570
571
#[ pallet:: type_value]
572
+ /// Default minimum stake for weights.
573
+ pub fn DefaultRevealPeriodEpochs < T : Config > ( ) -> u64 {
574
+ 1
575
+ }
576
+ #[ pallet:: type_value]
571
577
/// Value definition for vector of u16.
572
578
pub fn EmptyU16Vec < T : Config > ( ) -> Vec < u16 > {
573
579
vec ! [ ]
@@ -629,11 +635,6 @@ pub mod pallet {
629
635
T :: InitialServingRateLimit :: get ( )
630
636
}
631
637
#[ 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]
637
638
/// Default value for weight commit/reveal enabled.
638
639
pub fn DefaultCommitRevealWeightsEnabled < T : Config > ( ) -> bool {
639
640
false
@@ -1032,10 +1033,6 @@ pub mod pallet {
1032
1033
StorageMap < _ , Identity , u16 , u64 , ValueQuery , DefaultAdjustmentAlpha < T > > ;
1033
1034
#[ pallet:: storage]
1034
1035
/// --- MAP ( netuid ) --> interval
1035
- pub type WeightCommitRevealInterval < T > =
1036
- StorageMap < _ , Identity , u16 , u64 , ValueQuery , DefaultWeightCommitRevealInterval < T > > ;
1037
- #[ pallet:: storage]
1038
- /// --- MAP ( netuid ) --> interval
1039
1036
pub type CommitRevealWeightsEnabled < T > =
1040
1037
StorageMap < _ , Identity , u16 , bool , ValueQuery , DefaultCommitRevealWeightsEnabled < T > > ;
1041
1038
#[ pallet:: storage]
@@ -1254,16 +1251,20 @@ pub mod pallet {
1254
1251
/// ITEM( weights_min_stake )
1255
1252
pub type WeightsMinStake < T > = StorageValue < _ , u64 , ValueQuery , DefaultWeightsMinStake < T > > ;
1256
1253
#[ 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.
1258
1255
pub type WeightCommits < T : Config > = StorageDoubleMap <
1259
1256
_ ,
1260
1257
Twox64Concat ,
1261
1258
u16 ,
1262
1259
Twox64Concat ,
1263
1260
T :: AccountId ,
1264
- ( H256 , u64 ) ,
1261
+ VecDeque < ( H256 , u64 ) > ,
1265
1262
OptionQuery ,
1266
1263
> ;
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 > > ;
1267
1268
1268
1269
/// ==================
1269
1270
/// ==== Genesis =====
@@ -1460,6 +1461,18 @@ where
1460
1461
Err ( InvalidTransaction :: Custom ( 2 ) . into ( ) )
1461
1462
}
1462
1463
}
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
+ }
1463
1476
Some ( Call :: set_weights { netuid, .. } ) => {
1464
1477
if Self :: check_weights_min_stake ( who) {
1465
1478
let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
0 commit comments