@@ -31,7 +31,7 @@ use monad_consensus_state::ConsensusConfig;
3131use monad_consensus_types:: { metrics:: Metrics , validator_data:: ValidatorSetDataWithEpoch } ;
3232use monad_control_panel:: ipc:: ControlPanelIpcReceiver ;
3333use monad_crypto:: certificate_signature:: {
34- CertificateKeyPair , CertificateSignaturePubKey , CertificateSignatureRecoverable , PubKey ,
34+ CertificateSignaturePubKey , CertificateSignatureRecoverable , PubKey ,
3535} ;
3636use monad_dataplane:: DataplaneBuilder ;
3737use monad_eth_block_policy:: EthBlockPolicy ;
@@ -51,7 +51,7 @@ use monad_peer_discovery::{
5151use monad_pprof:: start_pprof_server;
5252use monad_raptorcast:: {
5353 config:: { RaptorCastConfig , RaptorCastConfigPrimary } ,
54- RAPTORCAST_SOCKET ,
54+ AUTHENTICATED_RAPTORCAST_SOCKET , RAPTORCAST_SOCKET ,
5555} ;
5656use monad_router_multi:: MultiRouter ;
5757use monad_state:: { MonadMessage , MonadStateBuilder , VerifiedMonadMessage } ;
@@ -507,9 +507,16 @@ fn build_raptorcast_router<ST, SCT, M, OM>(
507507 locked_epoch_validators : Vec < ValidatorSetDataWithEpoch < SCT > > ,
508508 current_epoch : Epoch ,
509509 current_round : Round ,
510- ) -> MultiRouter < ST , M , OM , MonadEvent < ST , SCT , ExecutionProtocolType > , PeerDiscovery < ST > >
510+ ) -> MultiRouter <
511+ ST ,
512+ M ,
513+ OM ,
514+ MonadEvent < ST , SCT , ExecutionProtocolType > ,
515+ PeerDiscovery < ST > ,
516+ monad_raptorcast:: auth:: WireAuthProtocol ,
517+ >
511518where
512- ST : CertificateSignatureRecoverable ,
519+ ST : CertificateSignatureRecoverable < KeyPairType = monad_secp :: KeyPair > ,
513520 SCT : SignatureCollection < NodeIdPubKey = CertificateSignaturePubKey < ST > > ,
514521 M : Message < NodeIdPubKey = CertificateSignaturePubKey < ST > >
515522 + Decodable
@@ -523,6 +530,10 @@ where
523530 IpAddr :: V4 ( node_config. network . bind_address_host ) ,
524531 node_config. network . bind_address_port ,
525532 ) ;
533+ let authenticated_bind_address = node_config
534+ . network
535+ . authenticated_bind_address_port
536+ . map ( |port| SocketAddr :: new ( IpAddr :: V4 ( node_config. network . bind_address_host ) , port) ) ;
526537 let Some ( SocketAddr :: V4 ( name_record_address) ) = resolve_domain_v4 (
527538 & NodeId :: new ( identity. pubkey ( ) ) ,
528539 & peer_discovery_config. self_address ,
@@ -535,6 +546,7 @@ where
535546
536547 tracing:: debug!(
537548 ?bind_address,
549+ ?authenticated_bind_address,
538550 ?name_record_address,
539551 "Monad-node starting, pid: {}" ,
540552 process:: id( )
@@ -554,18 +566,35 @@ where
554566 . with_tcp_rps_burst (
555567 network_config. tcp_rate_limit_rps ,
556568 network_config. tcp_rate_limit_burst ,
557- )
558- . extend_udp_sockets ( vec ! [ monad_dataplane:: UdpSocketConfig {
559- socket_addr: bind_address,
560- label: RAPTORCAST_SOCKET . to_string( ) ,
561- } ] ) ;
569+ ) ;
570+
571+ let mut udp_sockets = vec ! [ monad_dataplane:: UdpSocketConfig {
572+ socket_addr: bind_address,
573+ label: RAPTORCAST_SOCKET . to_string( ) ,
574+ } ] ;
575+ if let Some ( auth_addr) = authenticated_bind_address {
576+ udp_sockets. push ( monad_dataplane:: UdpSocketConfig {
577+ socket_addr : auth_addr,
578+ label : AUTHENTICATED_RAPTORCAST_SOCKET . to_string ( ) ,
579+ } ) ;
580+ }
581+ dp_builder = dp_builder. extend_udp_sockets ( udp_sockets) ;
562582
563583 let self_id = NodeId :: new ( identity. pubkey ( ) ) ;
564- let self_record = NameRecord :: new (
565- * name_record_address. ip ( ) ,
566- name_record_address. port ( ) ,
567- peer_discovery_config. self_record_seq_num ,
568- ) ;
584+ let self_record = match network_config. authenticated_bind_address_port {
585+ Some ( auth_port) => NameRecord :: new_with_authentication (
586+ * name_record_address. ip ( ) ,
587+ name_record_address. port ( ) ,
588+ network_config. bind_address_port ,
589+ auth_port,
590+ peer_discovery_config. self_record_seq_num ,
591+ ) ,
592+ None => NameRecord :: new (
593+ * name_record_address. ip ( ) ,
594+ network_config. bind_address_port ,
595+ peer_discovery_config. self_record_seq_num ,
596+ ) ,
597+ } ;
569598 let self_record = MonadNameRecord :: new ( self_record, & identity) ;
570599 assert ! (
571600 self_record. signature == peer_discovery_config. self_name_record_sig,
@@ -658,10 +687,14 @@ where
658687 rng : ChaCha8Rng :: from_entropy ( ) ,
659688 } ;
660689
690+ let shared_key = Arc :: new ( identity) ;
691+ let wireauth_config = monad_wireauth:: Config :: default ( ) ;
692+ let auth_protocol = monad_raptorcast:: auth:: WireAuthProtocol :: new ( wireauth_config, & shared_key) ;
693+
661694 MultiRouter :: new (
662695 self_id,
663696 RaptorCastConfig {
664- shared_key : Arc :: new ( identity ) ,
697+ shared_key,
665698 mtu : network_config. mtu ,
666699 udp_message_max_age_ms : network_config. udp_message_max_age_ms ,
667700 primary_instance : RaptorCastConfigPrimary {
@@ -677,6 +710,7 @@ where
677710 peer_discovery_builder,
678711 current_epoch,
679712 epoch_validators,
713+ auth_protocol,
680714 )
681715}
682716
0 commit comments