@@ -67,12 +67,14 @@ pub mod pallet {
6767 traits:: {
6868 tokens:: fungible, OriginTrait , QueryPreimage , StorePreimage , UnfilteredDispatchable ,
6969 } ,
70+ BoundedVec ,
7071 } ;
7172 use frame_system:: pallet_prelude:: * ;
7273 use sp_core:: H256 ;
7374 use sp_runtime:: traits:: { Dispatchable , TrailingZeroInput } ;
7475 use sp_std:: vec;
7576 use sp_std:: vec:: Vec ;
77+ use subtensor_macros:: freeze_struct;
7678
7779 #[ cfg( not( feature = "std" ) ) ]
7880 use alloc:: boxed:: Box ;
@@ -129,6 +131,36 @@ pub mod pallet {
129131 pub placeholder2 : u8 ,
130132 }
131133
134+ /// Struct for NeuronCertificate.
135+ pub type NeuronCertificateOf = NeuronCertificate ;
136+ /// Data structure for NeuronCertificate information.
137+ #[ freeze_struct( "1c232be200d9ec6c" ) ]
138+ #[ derive( Decode , Encode , Default , TypeInfo , PartialEq , Eq , Clone , Debug ) ]
139+ pub struct NeuronCertificate {
140+ /// The neuron TLS public key
141+ pub public_key : BoundedVec < u8 , ConstU32 < 64 > > ,
142+ /// The algorithm used to generate the public key
143+ pub algorithm : u8 ,
144+ }
145+
146+ impl TryFrom < Vec < u8 > > for NeuronCertificate {
147+ type Error = ( ) ;
148+
149+ fn try_from ( value : Vec < u8 > ) -> Result < Self , Self :: Error > {
150+ if value. len ( ) > 65 {
151+ return Err ( ( ) ) ;
152+ }
153+ // take the first byte as the algorithm
154+ let algorithm = value. first ( ) . ok_or ( ( ) ) ?;
155+ // and the rest as the public_key
156+ let certificate = value. get ( 1 ..) . ok_or ( ( ) ) ?. to_vec ( ) ;
157+ Ok ( Self {
158+ public_key : BoundedVec :: try_from ( certificate) . map_err ( |_| ( ) ) ?,
159+ algorithm : * algorithm,
160+ } )
161+ }
162+ }
163+
132164 /// Struct for Prometheus.
133165 pub type PrometheusInfoOf = PrometheusInfo ;
134166
@@ -1162,6 +1194,17 @@ pub mod pallet {
11621194 /// --- MAP ( netuid, hotkey ) --> axon_info
11631195 pub type Axons < T : Config > =
11641196 StorageDoubleMap < _ , Identity , u16 , Blake2_128Concat , T :: AccountId , AxonInfoOf , OptionQuery > ;
1197+ /// --- MAP ( netuid, hotkey ) --> certificate
1198+ #[ pallet:: storage]
1199+ pub type NeuronCertificates < T : Config > = StorageDoubleMap <
1200+ _ ,
1201+ Identity ,
1202+ u16 ,
1203+ Blake2_128Concat ,
1204+ T :: AccountId ,
1205+ NeuronCertificateOf ,
1206+ OptionQuery ,
1207+ > ;
11651208 #[ pallet:: storage]
11661209 /// --- MAP ( netuid, hotkey ) --> prometheus_info
11671210 pub type Prometheus < T : Config > = StorageDoubleMap <
@@ -1538,6 +1581,10 @@ where
15381581 let transaction_fee = 0 ;
15391582 Ok ( ( CallType :: Serve , transaction_fee, who. clone ( ) ) )
15401583 }
1584+ Some ( Call :: serve_axon_tls { .. } ) => {
1585+ let transaction_fee = 0 ;
1586+ Ok ( ( CallType :: Serve , transaction_fee, who. clone ( ) ) )
1587+ }
15411588 Some ( Call :: register_network { .. } ) => {
15421589 let transaction_fee = 0 ;
15431590 Ok ( ( CallType :: RegisterNetwork , transaction_fee, who. clone ( ) ) )
0 commit comments