Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change domain id of cosmos localnet to random #2977

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rust/hyperlane-core/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ pub enum KnownHyperlaneDomain {
ScrollSepolia = 534351,

/// Cosmos local chains
CosmosTest26657 = 26657,
CosmosTest26658 = 26658,
CosmosTest99990 = 99990,
CosmosTest99991 = 99991,
}

#[derive(Clone)]
Expand Down Expand Up @@ -200,7 +200,7 @@ impl KnownHyperlaneDomain {
Goerli, Mumbai, Fuji, ArbitrumGoerli, OptimismGoerli, BinanceSmartChainTestnet,
Alfajores, MoonbaseAlpha, Sepolia, PolygonZkEvmTestnet, LineaGoerli, BaseGoerli, ScrollSepolia, Chiado
],
LocalTestChain: [Test1, Test2, Test3, FuelTest1, SealevelTest1, SealevelTest2, CosmosTest26657, CosmosTest26658],
LocalTestChain: [Test1, Test2, Test3, FuelTest1, SealevelTest1, SealevelTest2, CosmosTest99990, CosmosTest99991],
})
}

Expand All @@ -215,7 +215,7 @@ impl KnownHyperlaneDomain {
],
HyperlaneDomainProtocol::Fuel: [FuelTest1],
HyperlaneDomainProtocol::Sealevel: [SealevelTest1, SealevelTest2],
HyperlaneDomainProtocol::Cosmos: [CosmosTest26657, CosmosTest26658],
HyperlaneDomainProtocol::Cosmos: [CosmosTest99990, CosmosTest99991],
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions rust/utils/run-locally/src/cosmos/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ fn link_network(
) {
let validator_addr = validator.addr(hrp);

let dest_domain = if network.domain == 26657 {
26658
let dest_domain = if network.domain == 99990 {
99991
} else {
26657
99990
};

// hook routing
Expand Down
36 changes: 21 additions & 15 deletions rust/utils/run-locally/src/cosmos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub struct CosmosNetwork {
pub launch_resp: CosmosResp,
pub deployments: Deployments,
pub chain_id: String,
pub metrics: u32,
pub domain: u32,
}

Expand All @@ -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<AgentHandles>,
pub relayer: AgentHandles,
Expand Down Expand Up @@ -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")
Expand All @@ -274,6 +275,7 @@ fn launch_cosmos_validator(
fn launch_cosmos_relayer(
agent_config_path: PathBuf,
relay_chains: Vec<String>,
metrics: u32,
debug: bool,
) -> AgentHandles {
let relayer_bin = concat_path(format!("../../{AGENT_BIN_PATH}"), "relayer");
Expand All @@ -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
Expand Down Expand Up @@ -347,18 +349,20 @@ fn run_locally() {
};

let port_start = 26600u32;
let domain_start = 26657u32;
let metrics_start = 9090u32;
let domain_start = 99990u32;
let node_count = 2;

let nodes = (0..node_count)
.map(|i| {
(
launch_cosmos_node(CosmosConfig {
node_port_base: port_start + (i * 10),
chain_id: format!("cosmos-test-{}", i + 26657),
chain_id: format!("cosmos-test-{}", i + domain_start),
..default_config.clone()
}),
format!("cosmos-test-{}", i + 26657),
format!("cosmos-test-{}", i + domain_start),
metrics_start + i,
domain_start + i,
)
})
Expand All @@ -371,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(),
Expand All @@ -381,14 +385,14 @@ fn run_locally() {
domain,
);

(launch_resp, deployments, chain_id, domain)
(launch_resp, deployments, chain_id, metrics, domain)
})
.collect::<Vec<_>>();

// 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::<Vec<CosmosNetwork>>();

Expand Down Expand Up @@ -448,9 +452,11 @@ fn run_locally() {
.into_values()
.map(|agent_config| launch_cosmos_validator(agent_config, agent_config_path.clone(), debug))
.collect::<Vec<_>>();
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::<Vec<_>>(),
hpl_rly_metrics,
debug,
);

Expand Down Expand Up @@ -516,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 {
Expand All @@ -536,7 +542,7 @@ fn run_locally() {
}
}

fn termination_invariants_met(_messages_expected: u32) -> eyre::Result<bool> {
fn termination_invariants_met(_metrics: u32, _messages_expected: u32) -> eyre::Result<bool> {
daniel-savu marked this conversation as resolved.
Show resolved Hide resolved
Ok(true)
// TODO: uncomment once CI passes consistently on Ubuntu
// let gas_payments_scraped = fetch_metric(
Expand Down
2 changes: 2 additions & 0 deletions rust/utils/run-locally/src/cosmos/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
Loading