From d3e30b3d57272edcd8faf6d1a9325b60253f929e Mon Sep 17 00:00:00 2001 From: byeongsu-hong Date: Sun, 26 Nov 2023 16:42:31 +0000 Subject: [PATCH] parameterize metrics port --- rust/utils/run-locally/src/cosmos/mod.rs | 31 +++++++++++++--------- rust/utils/run-locally/src/cosmos/types.rs | 2 ++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/rust/utils/run-locally/src/cosmos/mod.rs b/rust/utils/run-locally/src/cosmos/mod.rs index bb8d722c70..324162b0b7 100644 --- a/rust/utils/run-locally/src/cosmos/mod.rs +++ b/rust/utils/run-locally/src/cosmos/mod.rs @@ -173,6 +173,7 @@ pub struct CosmosNetwork { pub launch_resp: CosmosResp, pub deployments: Deployments, pub chain_id: String, + pub metrics: u32, pub domain: u32, } @@ -182,17 +183,17 @@ impl Drop for CosmosNetwork { } } -impl From<(CosmosResp, Deployments, String, u32)> for CosmosNetwork { - fn from(v: (CosmosResp, Deployments, String, u32)) -> Self { +impl From<(CosmosResp, Deployments, String, u32, u32)> for CosmosNetwork { + fn from(v: (CosmosResp, Deployments, String, u32, u32)) -> Self { Self { launch_resp: v.0, deployments: v.1, chain_id: v.2, - domain: v.3, + metrics: v.3, + domain: v.4, } } } - pub struct CosmosHyperlaneStack { pub validators: Vec, pub relayer: AgentHandles, @@ -258,7 +259,7 @@ fn launch_cosmos_validator( .hyp_env("ORIGINCHAINNAME", agent_config.name) .hyp_env("REORGPERIOD", "100") .hyp_env("DB", validator_base_db.to_str().unwrap()) - .hyp_env("METRICSPORT", agent_config.domain_id.to_string()) + .hyp_env("METRICSPORT", agent_config.metrics_port.to_string()) .hyp_env("VALIDATOR_SIGNER_TYPE", agent_config.signer.typ) .hyp_env("VALIDATOR_KEY", agent_config.signer.key.clone()) .hyp_env("VALIDATOR_PREFIX", "osmo") @@ -274,6 +275,7 @@ fn launch_cosmos_validator( fn launch_cosmos_relayer( agent_config_path: PathBuf, relay_chains: Vec, + metrics: u32, debug: bool, ) -> AgentHandles { let relayer_bin = concat_path(format!("../../{AGENT_BIN_PATH}"), "relayer"); @@ -290,7 +292,7 @@ fn launch_cosmos_relayer( .hyp_env("ALLOWLOCALCHECKPOINTSYNCERS", "true") .hyp_env("TRACING_LEVEL", if debug { "debug" } else { "info" }) .hyp_env("GASPAYMENTENFORCEMENT", "[{\"type\": \"none\"}]") - .hyp_env("METRICSPORT", 9093.to_string()) + .hyp_env("METRICSPORT", metrics.to_string()) .spawn("RLY"); relayer @@ -347,10 +349,10 @@ fn run_locally() { }; let port_start = 26600u32; + let metrics_start = 9090u32; let domain_start = 99990u32; let node_count = 2; - let nodes = (0..node_count) .map(|i| { ( @@ -360,6 +362,7 @@ fn run_locally() { ..default_config.clone() }), format!("cosmos-test-{}", i + domain_start), + metrics_start + i, domain_start + i, ) }) @@ -372,8 +375,8 @@ fn run_locally() { let nodes = nodes .into_iter() - .map(|v| (v.0.join(), v.1, v.2)) - .map(|(launch_resp, chain_id, domain)| { + .map(|v| (v.0.join(), v.1, v.2, v.3)) + .map(|(launch_resp, chain_id, metrics, domain)| { let deployments = deploy_cw_hyperlane( launch_resp.cli(&osmosisd), launch_resp.endpoint.clone(), @@ -382,14 +385,14 @@ fn run_locally() { domain, ); - (launch_resp, deployments, chain_id, domain) + (launch_resp, deployments, chain_id, metrics, domain) }) .collect::>(); // nodes with base deployments let nodes = nodes .into_iter() - .map(|v| (v.0, v.1.join(), v.2, v.3)) + .map(|v| (v.0, v.1.join(), v.2, v.3, v.4)) .map(|v| v.into()) .collect::>(); @@ -449,9 +452,11 @@ fn run_locally() { .into_values() .map(|agent_config| launch_cosmos_validator(agent_config, agent_config_path.clone(), debug)) .collect::>(); + let hpl_rly_metrics = metrics_start + node_count + 1u32; let hpl_rly = launch_cosmos_relayer( agent_config_path, agent_config_out.chains.into_keys().collect::>(), + hpl_rly_metrics, debug, ); @@ -517,7 +522,7 @@ fn run_locally() { let mut failure_occurred = false; loop { // look for the end condition. - if termination_invariants_met(dispatched_messages).unwrap_or(false) { + if termination_invariants_met(hpl_rly_metrics, dispatched_messages).unwrap_or(false) { // end condition reached successfully break; } else if (Instant::now() - loop_start).as_secs() > TIMEOUT_SECS { @@ -537,7 +542,7 @@ fn run_locally() { } } -fn termination_invariants_met(_messages_expected: u32) -> eyre::Result { +fn termination_invariants_met(_metrics: u32, _messages_expected: u32) -> eyre::Result { Ok(true) // TODO: uncomment once CI passes consistently on Ubuntu // let gas_payments_scraped = fetch_metric( diff --git a/rust/utils/run-locally/src/cosmos/types.rs b/rust/utils/run-locally/src/cosmos/types.rs index 8632687b15..072a8b04b1 100644 --- a/rust/utils/run-locally/src/cosmos/types.rs +++ b/rust/utils/run-locally/src/cosmos/types.rs @@ -113,6 +113,7 @@ pub struct AgentUrl { pub struct AgentConfig { pub name: String, pub domain_id: u32, + pub metrics_port: u32, pub mailbox: String, pub interchain_gas_paymaster: String, pub validator_announce: String, @@ -144,6 +145,7 @@ impl AgentConfig { AgentConfig { name: format!("cosmostest{}", network.domain), domain_id: network.domain, + metrics_port: network.metrics, mailbox: to_hex_addr(&network.deployments.mailbox), interchain_gas_paymaster: to_hex_addr(&network.deployments.igp), validator_announce: to_hex_addr(&network.deployments.va),