@@ -31,6 +31,7 @@ use monad_crypto::{
3131use monad_executor:: ExecutorMetrics ;
3232use monad_executor_glue:: PeerEntry ;
3333use monad_types:: { Epoch , NodeId , Round } ;
34+ use serde:: { Deserialize , Serialize } ;
3435use tracing:: { debug, warn} ;
3536
3637pub mod discovery;
@@ -47,7 +48,8 @@ pub enum PortTag {
4748 UDP = 1 ,
4849}
4950
50- #[ derive( Debug , Clone , Copy , PartialEq , Eq , RlpEncodable , RlpDecodable ) ]
51+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , RlpEncodable , RlpDecodable , Deserialize , Serialize ) ]
52+ #[ serde( deny_unknown_fields) ]
5153pub struct Port {
5254 pub tag : u8 ,
5355 pub port : u16 ,
@@ -70,7 +72,8 @@ impl Port {
7072 }
7173}
7274
73- #[ derive( Debug , Clone , PartialEq , Eq ) ]
75+ #[ derive( Debug , Clone , PartialEq , Eq , Deserialize , Serialize ) ]
76+ #[ serde( deny_unknown_fields) ]
7477struct WireNameRecordV1 {
7578 pub ip : Ipv4Addr ,
7679 pub port : u16 ,
@@ -112,7 +115,8 @@ impl WireNameRecordV1 {
112115 }
113116}
114117
115- #[ derive( Debug , Clone , PartialEq , Eq ) ]
118+ #[ derive( Debug , Clone , PartialEq , Eq , Deserialize , Serialize ) ]
119+ #[ serde( deny_unknown_fields) ]
116120struct PortList < const N : usize > ( ArrayVec < Port , N > ) ;
117121
118122impl < const N : usize > Encodable for PortList < N > {
@@ -182,7 +186,8 @@ impl<const N: usize> PortList<N> {
182186 }
183187}
184188
185- #[ derive( Debug , Clone , PartialEq , Eq ) ]
189+ #[ derive( Debug , Clone , PartialEq , Eq , Deserialize , Serialize ) ]
190+ #[ serde( deny_unknown_fields) ]
186191struct WireNameRecordV2 {
187192 pub ip : Ipv4Addr ,
188193 pub ports : PortList < 8 > ,
@@ -256,13 +261,15 @@ impl WireNameRecordV2 {
256261 }
257262}
258263
259- #[ derive( Debug , Clone , PartialEq , Eq ) ]
264+ #[ derive( Debug , Clone , PartialEq , Eq , Deserialize , Serialize ) ]
265+ #[ serde( deny_unknown_fields) ]
260266enum VersionedNameRecord {
261267 V1 ( WireNameRecordV1 ) ,
262268 V2 ( WireNameRecordV2 ) ,
263269}
264270
265- #[ derive( Debug , Clone , PartialEq , Eq ) ]
271+ #[ derive( Debug , Clone , PartialEq , Eq , Deserialize , Serialize ) ]
272+ #[ serde( deny_unknown_fields) ]
266273pub struct NameRecord {
267274 record : VersionedNameRecord ,
268275}
@@ -384,7 +391,9 @@ impl Decodable for NameRecord {
384391#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
385392pub enum Capability { }
386393
387- #[ derive( Debug , Clone , PartialEq , RlpEncodable , RlpDecodable , Eq ) ]
394+ #[ derive( Debug , Clone , PartialEq , RlpEncodable , RlpDecodable , Eq , Deserialize , Serialize ) ]
395+ #[ serde( deny_unknown_fields) ]
396+ #[ serde( bound = "ST: CertificateSignatureRecoverable" ) ]
388397pub struct MonadNameRecord < ST : CertificateSignatureRecoverable > {
389398 pub name_record : NameRecord ,
390399 pub signature : ST ,
0 commit comments