Skip to content

Commit

Permalink
Nodes listen on all interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bacv committed Sep 30, 2024
1 parent 46ac91f commit cc567be
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
8 changes: 4 additions & 4 deletions compose.static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- "18080:18080/tcp"
volumes:
- ./testnet:/etc/nomos
- ./tests/kzgrs/kzgrs_test_params:/etc/nomos/kzgrs_test_params:z
- ./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z
depends_on:
- cfgsync
- graylog
Expand All @@ -37,7 +37,7 @@ services:
image: nomos:latest
volumes:
- ./testnet:/etc/nomos
- ./tests/kzgrs/kzgrs_test_params:/etc/nomos/kzgrs_test_params:z
- ./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z
depends_on:
- cfgsync
- graylog
Expand All @@ -54,7 +54,7 @@ services:
image: nomos:latest
volumes:
- ./testnet:/etc/nomos
- ./tests/kzgrs/kzgrs_test_params:/etc/nomos/kzgrs_test_params:z
- ./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z
depends_on:
- cfgsync
- graylog
Expand All @@ -71,7 +71,7 @@ services:
image: nomos:latest
volumes:
- ./testnet:/etc/nomos
- ./tests/kzgrs/kzgrs_test_params:/etc/nomos/kzgrs_test_params:z
- ./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z
depends_on:
- cfgsync
- graylog
Expand Down
8 changes: 5 additions & 3 deletions testnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BUILD IMAGE ---------------------------------------------------------

FROM rust:1.80.0-slim-bookworm AS builder
FROM rust:1.81.0-slim-bookworm AS builder

WORKDIR /nomos
COPY . .
Expand All @@ -18,14 +18,16 @@ RUN cargo build --release --all --features metrics

# NODE IMAGE ----------------------------------------------------------

FROM bitnami/minideb:latest
FROM bitnami/minideb:bookworm

LABEL maintainer="augustinas@status.im" \
source="https://github.com/logos-co/nomos-node" \
description="Nomos testnet image"

# nomos default ports
EXPOSE 3000 8080 9000 60000
EXPOSE 3000 8080 9000 60000

RUN apt-get update && apt-get install -y libssl3

COPY --from=builder /nomos/target/release/nomos-node /usr/bin/nomos-node
COPY --from=builder /nomos/target/release/nomos-cli /usr/bin/nomos-cli
Expand Down
2 changes: 1 addition & 1 deletion testnet/cfgsync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ num_samples: 1
num_subnets: 2
old_blobs_check_interval_secs: 5
blobs_validity_duration_secs: 60
global_params_path: "/etc/nomos/kzgrs_test_params"
global_params_path: "/kzgrs_test_params"
2 changes: 1 addition & 1 deletion testnet/cfgsync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ axum = { version = "0.6" }
clap = { version = "4", features = ["derive"] }
nomos-libp2p = { path = "../../nomos-libp2p" }
nomos-node = { path = "../../nodes/nomos-node" }
reqwest = { version = "0.11", features = ["json"] }
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
tests = { path = "../../tests" }
tokio = { version = "1.24", features = ["rt-multi-thread"] }
serde = { version = "1", features = ["derive"] }
Expand Down
37 changes: 13 additions & 24 deletions testnet/cfgsync/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, net::Ipv4Addr, str::FromStr};
// crates
use nomos_libp2p::{Multiaddr, PeerId};
use nomos_node::Config as NodeConfig;
use tests::{nodes::nomos::secret_key_to_peer_id, ConsensusConfig, DaConfig, Node, NomosNode};
use tests::{ConsensusConfig, DaConfig, Node, NomosNode};
// internal

const DEFAULT_NETWORK_PORT: u16 = 3000;
Expand Down Expand Up @@ -53,19 +53,19 @@ pub fn create_node_configs(
.collect();

for (config, host) in configs.iter_mut().zip(hosts.into_iter()) {
// Same node key is used for network and da_network.
let peer_id = secret_key_to_peer_id(config.da_network.backend.node_key.clone());

config.da_network.backend.addresses = new_peer_addresses.clone();
if let Some((multiaddr, _)) = host_da_peer_addresses.get(&peer_id) {
// Libp2p network config.
config.network.backend.inner.host = host.ip;
config.network.backend.inner.port = host.network_port;
config.network.backend.initial_peers = host_network_init_peers.clone();

// DA Libp2p network config.
config.da_network.backend.listening_address = multiaddr.clone();
}

// Libp2p network config.
config.network.backend.inner.host = Ipv4Addr::from_str("0.0.0.0").unwrap();
config.network.backend.inner.port = host.network_port;
config.network.backend.initial_peers = host_network_init_peers.clone();

// DA Libp2p network config.
config.da_network.backend.listening_address = Multiaddr::from_str(&format!(
"/ip4/0.0.0.0/udp/{}/quic-v1",
host.da_network_port,
))
.unwrap();

configured_hosts.insert(host.clone(), config.clone());
}
Expand Down Expand Up @@ -139,17 +139,9 @@ mod cfgsync_tests {
);

for (host, config) in configs.iter() {
let network_ip = config.network.backend.inner.host;
let network_port = config.network.backend.inner.port;

let da_network_addr = config.da_network.backend.listening_address.clone();
let da_network_ip: Ipv4Addr = da_network_addr
.iter()
.find_map(|protocol| match protocol {
Protocol::Ip4(ipv4) => Some(ipv4),
_ => None,
})
.unwrap();
let da_network_port = da_network_addr
.iter()
.find_map(|protocol| match protocol {
Expand All @@ -158,10 +150,7 @@ mod cfgsync_tests {
})
.unwrap();

assert_eq!(network_ip, host.ip);
assert_eq!(network_port, host.network_port);

assert_eq!(da_network_ip, host.ip);
assert_eq!(da_network_port, host.da_network_port);
}
}
Expand Down
7 changes: 4 additions & 3 deletions testnet/scripts/run_nomos_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

set -e

export CFG_FILE_PATH="/etc/nomos/config.yaml" \
export CFG_FILE_PATH="/config.yaml" \
CFG_SERVER_ADDR="http://cfgsync:4400" \
CFG_HOST_IP=$(hostname -i)
CFG_HOST_IP=$(hostname -i) \
RISC0_DEV_MODE=true

/usr/bin/cfgsync-client && \
exec /usr/bin/nomos-node CFG_FILE_PATH --with-metrics --log-backend gelf --log-addr graylog:12201
exec /usr/bin/nomos-node /config.yaml --with-metrics --log-backend gelf --log-addr graylog:12201
2 changes: 1 addition & 1 deletion tests/src/nodes/nomos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ fn build_mixnet_topology(mixnode_candidates: &[&Config]) -> MixnetTopology {
MixnetTopology::new(candidates, num_layers, 1, [1u8; 32]).unwrap()
}

pub fn secret_key_to_peer_id(node_key: nomos_libp2p::ed25519::SecretKey) -> PeerId {
fn secret_key_to_peer_id(node_key: nomos_libp2p::ed25519::SecretKey) -> PeerId {
PeerId::from_public_key(
&nomos_libp2p::ed25519::Keypair::from(node_key)
.public()
Expand Down

0 comments on commit cc567be

Please sign in to comment.