| 797 | network_committee.push((our_public_key, our_ip)); |
| 798 | network_committee.sort(); |
| 799 | } |
| 800 | |
| 801 | // Start prometheus endpoint (merges Summit + commonware runtime metrics) |
| 802 | #[cfg(feature = "prom")] |
| 803 | { |
| 804 | use crate::prom::hooks::Hooks; |
| 805 | use crate::prom::server::{MetricServer, MetricServerConfig}; |
| 806 | use std::net::SocketAddr; |
| 807 | |
| 808 | let hooks = Hooks::builder().build(); |
| 809 | |
| 810 | let listen_addr = format!("{}:{}", flags.prom_ip, flags.prom_port) |
| 811 | .parse::<SocketAddr>() |
| 812 | .unwrap(); |
| 813 | let config = MetricServerConfig::new(listen_addr, hooks, Some(context.child("prom"))); |
| 814 | let stop_signal = context.stopped(); |
| 815 | MetricServer::new(config).serve(stop_signal).await.unwrap(); |
| 816 | } |
| 817 | |
| 818 | // configure network |
| 819 | let network_committee_ingress: Vec<_> = |
| 820 | if let Some(ref bootstrappers_path) = flags.bootstrappers { |
| 821 | Bootstrappers::load_from_file(bootstrappers_path) |
| 822 | .expect("Failed to load bootstrappers file") |
| 823 | .to_ingress_list() |
| 824 | .expect("Failed to parse bootstrappers") |
| 825 | } else { |
| 826 | network_committee |
| 827 | .iter() |
| 828 | .map(|(pk, addr)| (pk.clone(), Ingress::from(*addr))) |
| 829 | .collect() |
| 830 | }; |
| 831 | |
| 832 | let listen = wildcard_listen_for(our_ip, flags.port); |
| 833 | // Bind the live p2p authentication domain to immutable chain identity so a |
| 834 | // peer from a different deployment that reuses this namespace and the same |
| 835 | // node keys cannot authenticate against us. |
| 836 | let p2p_domain = summit_types::chain_domain(genesis.config_digest()); |
| 837 | let namespace = p2p_domain.as_slice(); |
| 838 | let max_message_size = genesis.max_message_size_bytes as u32; |
| 839 | |
| 840 | let (engine, p2p, rpc_handle) = if let Some(index) = flags.observer { |
| 841 | let signer = ExtPrivateKey::derive_child_signer(&key_store.node_key, namespace, index); |
| 842 | // The observer's network identity is exactly this P2P signer's public |
| 843 | // key; capture it here so the engine and resolver reuse the same derived |
| 844 | // key rather than deriving it a second time (which could drift). |
| 845 | let observer_network_key = Some(signer.public_key()); |
| 846 | let mut p2p_cfg = authenticated::discovery::Config::recommended( |
| 847 | signer, |
| 848 | namespace, |
| 849 | listen, |
| 850 | our_ip, |
| 851 | network_committee_ingress, |
| 852 | crate::config::startup_peer_limit(&initial_state), |
| 853 | max_message_size, |
| 854 | ); |
| 855 | p2p_cfg.mailbox_size = MAILBOX_SIZE; |
| 856 | start_network_and_engine( |