@@ -36,7 +36,7 @@ use monad_merkle::{MerkleHash, MerkleProof, MerkleTree};
3636use  monad_raptor:: SOURCE_SYMBOLS_MIN ; 
3737use  monad_types:: { Epoch ,  NodeId ,  Stake } ; 
3838use  rand:: seq:: SliceRandom ; 
39- use  tracing:: { debug ,   warn} ; 
39+ use  tracing:: warn; 
4040
4141use  crate :: { 
4242    decoding:: { DecoderCache ,  DecodingContext ,  TryDecodeError ,  TryDecodeStatus } , 
@@ -173,22 +173,16 @@ impl<ST: CertificateSignatureRecoverable> UdpState<ST> {
173173                continue ; 
174174            } 
175175
176-             let  maybe_broadcast_mode = match  ( 
177-                 parsed_message. broadcast , 
178-                 parsed_message. secondary_broadcast , 
179-             )  { 
180-                 ( true ,  false )  => Some ( BroadcastMode :: Primary ) , 
181-                 ( false ,  true )  => Some ( BroadcastMode :: Secondary ) , 
182-                 ( false ,  false )  => None , 
183-                 ( true ,  true )  => { 
184-                     // invalid to have both primary and secondary broadcast bit set 
185-                     debug ! ( 
186-                         ?parsed_message. author, 
187-                         "Receiving invalid message with both broadcast and secondary broadcast bit set" 
188-                     ) ; 
189-                     continue ; 
190-                 } 
191-             } ; 
176+             let  maybe_broadcast_mode =
177+                 match  ( parsed_message. broadcast ,  parsed_message. secondary_broadcast )  { 
178+                     ( true ,  false )  => Some ( BroadcastMode :: Primary ) , 
179+                     ( false ,  true )  => Some ( BroadcastMode :: Secondary ) , 
180+                     ( false ,  false )  => None , 
181+                     ( true ,  true )  => { 
182+                         // InvalidBroadcastBits 
183+                         unreachable ! ( ) 
184+                     } 
185+                 } ; 
192186
193187            // Note: The check that parsed_message.author is valid is already 
194188            // done in iterate_rebroadcast_peers(), but we want to drop invalid 
@@ -890,6 +884,7 @@ pub enum MessageValidationError {
890884        max :  u64 , 
891885        delta :  i64 , 
892886    } , 
887+     InvalidBroadcastBits , 
893888} 
894889
895890/// - 65 bytes => Signature of sender over hash(rest of message up to merkle proof, concatenated with merkle root) 
@@ -948,6 +943,10 @@ where
948943    let  secondary_broadcast = ( cursor_broadcast_tree_depth &  ( 1  << 6 ) )  != 0 ; 
949944    let  tree_depth = cursor_broadcast_tree_depth &  0b0000_1111 ;  // bottom 4 bits 
950945
946+     if  broadcast && secondary_broadcast { 
947+         return  Err ( MessageValidationError :: InvalidBroadcastBits ) ; 
948+     } 
949+ 
951950    if  !( MIN_MERKLE_TREE_DEPTH ..=MAX_MERKLE_TREE_DEPTH ) . contains ( & tree_depth)  { 
952951        return  Err ( MessageValidationError :: InvalidTreeDepth ) ; 
953952    } 
0 commit comments