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

Increment ports of "odd" parachains to avoid port conflicts #306

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion node/src/container_chain_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct SpawnedContainersMonitor {
/// stopping time and reference count.
list: VecDeque<SpawnedContainer>,
/// Count the number of times a container chain has been started
count: usize,
pub count: usize,
}

pub struct SpawnedContainer {
Expand Down
42 changes: 42 additions & 0 deletions node/src/container_chain_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,48 @@ impl ContainerChainSpawner {
container_chain_para_id
);

let odd_parachain = {
let state = state.lock().expect("poison error");
let monitor_id = state.spawned_containers_monitor.count;

monitor_id % 2 == 1
};

if odd_parachain {
log::info!("This is an odd parachain, incrementing all the ports by 1");
// Increment all the ports by 1 to avoid conflicts with the other running container chain
container_chain_cli
.base
.base
.prometheus_params
.prometheus_port = Some(
container_chain_cli
.base
.base
.prometheus_params
.prometheus_port
.unwrap_or(9617)
.saturating_add(1),
);
container_chain_cli.base.base.network_params.port = Some(
container_chain_cli
.base
.base
.network_params
.port
.unwrap_or(30335)
.saturating_add(1),
);
container_chain_cli.base.base.rpc_port = Some(
container_chain_cli
.base
.base
.rpc_port
.unwrap_or(9946)
.saturating_add(1),
);
}

// Update CLI params
container_chain_cli.base.para_id = Some(container_chain_para_id.into());

Expand Down
Loading