Runs the ABCI server. If a CancellationToken is provided (i.e. Some(token)), the server future is wrapped with cancellation logic. Otherwise, it just awaits the server future.
(
settings: Settings,
cancel_token: Option<CancellationToken>,
)
| 37 | /// Runs the ABCI server. If a CancellationToken is provided (i.e. Some(token)), |
| 38 | /// the server future is wrapped with cancellation logic. Otherwise, it just awaits the server future. |
| 39 | pub async fn run( |
| 40 | settings: Settings, |
| 41 | cancel_token: Option<CancellationToken>, |
| 42 | ) -> anyhow::Result<()> { |
| 43 | let tendermint_rpc_url = settings.tendermint_rpc_url()?; |
| 44 | tracing::info!("Connecting to Tendermint at {tendermint_rpc_url}"); |
| 45 | |
| 46 | let tendermint_client: tendermint_rpc::HttpClient = |
| 47 | tendermint_rpc::HttpClient::new(tendermint_rpc_url) |
| 48 | .context("failed to create Tendermint client")?; |
| 49 | |
| 50 | // Prometheus metrics |
| 51 | let metrics_registry = if settings.metrics.enabled { |
| 52 | let registry = prometheus::Registry::new_custom( |
| 53 | Some("ipc".to_string()), |
| 54 | Some([("subnet_id".to_string(), settings.ipc.subnet_id.to_string())].into()), |
| 55 | ) |
| 56 | .context("failed to create Prometheus registry")?; |
| 57 | |
| 58 | register_default_metrics(®istry).context("failed to register default metrics")?; |
| 59 | register_topdown_metrics(®istry).context("failed to register topdown metrics")?; |
| 60 | register_interpreter_metrics(®istry) |
| 61 | .context("failed to register interpreter metrics")?; |
| 62 | register_consensus_metrics(®istry).context("failed to register consensus metrics")?; |
| 63 | |
| 64 | Some(registry) |
| 65 | } else { |
| 66 | None |
| 67 | }; |
| 68 | |
| 69 | let validator = match settings.validator_key { |
| 70 | Some(ref key) => { |
| 71 | let sk = key.path(settings.home_dir()); |
| 72 | if sk.exists() && sk.is_file() { |
| 73 | let sk = read_secret_key(&sk).context("failed to read validator key")?; |
| 74 | let addr = to_address(&sk, &key.kind)?; |
| 75 | tracing::info!("validator key address: {addr} detected"); |
| 76 | Some((sk, addr)) |
| 77 | } else { |
| 78 | bail!("validator key does not exist: {}", sk.to_string_lossy()); |
| 79 | } |
| 80 | } |
| 81 | None => { |
| 82 | tracing::debug!("validator key not configured"); |
| 83 | None |
| 84 | } |
| 85 | }; |
| 86 | |
| 87 | let validator_keypair = validator.as_ref().map(|(sk, _)| { |
| 88 | let mut bz = sk.serialize(); |
| 89 | let sk = libp2p::identity::secp256k1::SecretKey::try_from_bytes(&mut bz) |
| 90 | .expect("secp256k1 secret key"); |
| 91 | let kp = libp2p::identity::secp256k1::Keypair::from(sk); |
| 92 | libp2p::identity::Keypair::from(kp) |
| 93 | }); |
| 94 | |
| 95 | let testing_settings = match settings.testing.as_ref() { |
| 96 | Some(_) if current_network() == Network::Mainnet => { |
nothing calls this directly
no test coverage detected