MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / run

Function run

fendermint/app/src/service/node.rs:39–235  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

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.
39pub 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(&registry).context("failed to register default metrics")?;
59 register_topdown_metrics(&registry).context("failed to register topdown metrics")?;
60 register_interpreter_metrics(&registry)
61 .context("failed to register interpreter metrics")?;
62 register_consensus_metrics(&registry).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 => {

Callers

nothing calls this directly

Calls 15

read_secret_keyFunction · 0.85
current_networkFunction · 0.85
open_dbFunction · 0.85
start_topdown_if_enabledFunction · 0.85
ApplicationServiceClass · 0.85
tendermint_rpc_urlMethod · 0.80
contextMethod · 0.80
to_stringMethod · 0.80
home_dirMethod · 0.80
existsMethod · 0.80
download_dirMethod · 0.80
spawn_post_init_tasksMethod · 0.80

Tested by

no test coverage detected