@@ -172,7 +172,7 @@ pub mod pallet {
172172 u16 ,
173173 Twox64Concat ,
174174 T :: AccountId ,
175- RevealedData < BalanceOf < T > , T :: MaxFields , BlockNumberFor < T > > ,
175+ Vec < ( Vec < u8 > , u64 ) > , // Reveals<(Data, RevealBlock)>
176176 OptionQuery ,
177177 > ;
178178
@@ -478,7 +478,6 @@ where
478478
479479impl < T : Config > Pallet < T > {
480480 pub fn reveal_timelocked_commitments ( ) -> DispatchResult {
481- let current_block = <frame_system:: Pallet < T > >:: block_number ( ) ;
482481 let index = TimelockedIndex :: < T > :: get ( ) ;
483482 for ( netuid, who) in index. clone ( ) {
484483 let Some ( mut registration) = <CommitmentOf < T > >:: get ( netuid, & who) else {
@@ -528,10 +527,7 @@ impl<T: Config> Pallet<T> {
528527 . ok ( ) ;
529528
530529 let Some ( sig) = sig else {
531- remain_fields. push ( Data :: TimelockEncrypted {
532- encrypted,
533- reveal_round,
534- } ) ;
530+ log:: warn!( "No sig after deserialization" ) ;
535531 continue ;
536532 } ;
537533
@@ -547,10 +543,7 @@ impl<T: Config> Pallet<T> {
547543 . ok ( ) ;
548544
549545 let Some ( commit) = commit else {
550- remain_fields. push ( Data :: TimelockEncrypted {
551- encrypted,
552- reveal_round,
553- } ) ;
546+ log:: warn!( "No commit after deserialization" ) ;
554547 continue ;
555548 } ;
556549
@@ -563,61 +556,41 @@ impl<T: Config> Pallet<T> {
563556 . unwrap_or_default ( ) ;
564557
565558 if decrypted_bytes. is_empty ( ) {
566- remain_fields. push ( Data :: TimelockEncrypted {
567- encrypted,
568- reveal_round,
569- } ) ;
559+ log:: warn!( "Bytes were decrypted for {:?} but they are empty" , who) ;
570560 continue ;
571561 }
572562
573- let mut reader = & decrypted_bytes[ ..] ;
574- let revealed_info: CommitmentInfo < T :: MaxFields > =
575- match Decode :: decode ( & mut reader) {
576- Ok ( info) => info,
577- Err ( e) => {
578- log:: warn!(
579- "Failed to decode decrypted data for {:?}: {:?}" ,
580- who,
581- e
582- ) ;
583- remain_fields. push ( Data :: TimelockEncrypted {
584- encrypted,
585- reveal_round,
586- } ) ;
587- continue ;
588- }
589- } ;
590-
591- revealed_fields. push ( revealed_info) ;
563+ revealed_fields. push ( decrypted_bytes) ;
592564 }
593565
594566 other => remain_fields. push ( other) ,
595567 }
596568 }
597569
598570 if !revealed_fields. is_empty ( ) {
599- let mut all_revealed_data = Vec :: new ( ) ;
600- for info in revealed_fields {
601- all_revealed_data. extend ( info. fields . into_inner ( ) ) ;
602- }
571+ let mut existing_reveals =
572+ RevealedCommitments :: < T > :: get ( netuid, & who) . unwrap_or_default ( ) ;
603573
604- let bounded_revealed = BoundedVec :: try_from ( all_revealed_data )
605- . map_err ( |_| "Could not build BoundedVec for revealed fields" ) ? ;
574+ let current_block = <frame_system :: Pallet < T > > :: block_number ( ) ;
575+ let block_u64 = current_block . saturated_into :: < u64 > ( ) ;
606576
607- let combined_revealed_info = CommitmentInfo {
608- fields : bounded_revealed ,
609- } ;
577+ // Push newly revealed items onto the tail of existing_reveals and emit the event
578+ for revealed_bytes in revealed_fields {
579+ existing_reveals . push ( ( revealed_bytes , block_u64 ) ) ;
610580
611- let revealed_data = RevealedData {
612- info : combined_revealed_info,
613- revealed_block : current_block,
614- deposit : registration. deposit ,
615- } ;
616- <RevealedCommitments < T > >:: insert ( netuid, & who, revealed_data) ;
617- Self :: deposit_event ( Event :: CommitmentRevealed {
618- netuid,
619- who : who. clone ( ) ,
620- } ) ;
581+ Self :: deposit_event ( Event :: CommitmentRevealed {
582+ netuid,
583+ who : who. clone ( ) ,
584+ } ) ;
585+ }
586+
587+ const MAX_REVEALS : usize = 10 ;
588+ if existing_reveals. len ( ) > MAX_REVEALS {
589+ let remove_count = existing_reveals. len ( ) . saturating_sub ( MAX_REVEALS ) ;
590+ existing_reveals. drain ( 0 ..remove_count) ;
591+ }
592+
593+ RevealedCommitments :: < T > :: insert ( netuid, & who, existing_reveals) ;
621594 }
622595
623596 registration. info . fields = BoundedVec :: try_from ( remain_fields)
0 commit comments