@@ -67,12 +67,14 @@ pub mod pallet {
67
67
traits:: {
68
68
tokens:: fungible, OriginTrait , QueryPreimage , StorePreimage , UnfilteredDispatchable ,
69
69
} ,
70
+ BoundedVec ,
70
71
} ;
71
72
use frame_system:: pallet_prelude:: * ;
72
73
use sp_core:: H256 ;
73
74
use sp_runtime:: traits:: { Dispatchable , TrailingZeroInput } ;
74
75
use sp_std:: vec;
75
76
use sp_std:: vec:: Vec ;
77
+ use subtensor_macros:: freeze_struct;
76
78
77
79
#[ cfg( not( feature = "std" ) ) ]
78
80
use alloc:: boxed:: Box ;
@@ -129,6 +131,36 @@ pub mod pallet {
129
131
pub placeholder2 : u8 ,
130
132
}
131
133
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
+
132
164
/// Struct for Prometheus.
133
165
pub type PrometheusInfoOf = PrometheusInfo ;
134
166
@@ -1162,6 +1194,17 @@ pub mod pallet {
1162
1194
/// --- MAP ( netuid, hotkey ) --> axon_info
1163
1195
pub type Axons < T : Config > =
1164
1196
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
+ > ;
1165
1208
#[ pallet:: storage]
1166
1209
/// --- MAP ( netuid, hotkey ) --> prometheus_info
1167
1210
pub type Prometheus < T : Config > = StorageDoubleMap <
@@ -1538,6 +1581,10 @@ where
1538
1581
let transaction_fee = 0 ;
1539
1582
Ok ( ( CallType :: Serve , transaction_fee, who. clone ( ) ) )
1540
1583
}
1584
+ Some ( Call :: serve_axon_tls { .. } ) => {
1585
+ let transaction_fee = 0 ;
1586
+ Ok ( ( CallType :: Serve , transaction_fee, who. clone ( ) ) )
1587
+ }
1541
1588
Some ( Call :: register_network { .. } ) => {
1542
1589
let transaction_fee = 0 ;
1543
1590
Ok ( ( CallType :: RegisterNetwork , transaction_fee, who. clone ( ) ) )
0 commit comments