Skip to content

Commit

Permalink
Update libp2p node config
Browse files Browse the repository at this point in the history
  • Loading branch information
bacv committed Oct 17, 2023
1 parent f14df0c commit 8275fc7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BUILD IMAGE ---------------------------------------------------------

FROM rust:1.72.0-slim-bullseye AS builder
FROM rust:1.72.1-slim-bullseye AS builder

# Using backports for go 1.19
RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' \
Expand Down
22 changes: 21 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,27 @@ services:
- NODE_MASK=${DOCKER_COMPOSE_LIBP2P_NODE_KEY_MASK:-2000000000000000000000000000000000000000000000000000000000000000}
- OVERLAY_NODES=${DOCKER_COMPOSE_OVERLAY_NODES:-1000000000000000000000000000000000000000000000000000000000000000}
- NET_INITIAL_PEERS=${DOCKER_COMPOSE_NET_INITIAL_PEERS:-/dns/bootstrap/tcp/3000}
entrypoint: /etc/nomos/configure_node.sh
entrypoint: /etc/nomos/run_libp2p_node.sh

mix-node:
build:
context: .
dockerfile: testnet/Dockerfile
volumes:
- ./testnet:/etc/nomos
deploy:
replicas: ${DOCKER_COMPOSE_MIXNET_REPLICAS:-1}
depends_on:
- bootstrap
- etcd
environment:
- DOCKER_REPLICAS=${DOCKER_COMPOSE_MIXNET_REPLICAS:-1}
- ETCDCTL_ENDPOINTS=${DOCKER_COMPOSE_ETCDCTL_ENDPOINTS:-etcd:2379}
- ETCDCTL_API=${DOCKER_COMPOSE_ETCDCTL_API:-3}
- NODE_MASK=${DOCKER_COMPOSE_MIXNET_NODE_KEY_MASK:-2000000000000000000000000000000000000000000000000000000000000000}
- OVERLAY_NODES=${DOCKER_COMPOSE_OVERLAY_NODES:-1000000000000000000000000000000000000000000000000000000000000000}
- NET_INITIAL_PEERS=${DOCKER_COMPOSE_NET_INITIAL_PEERS:-/dns/bootstrap/tcp/3000}
entrypoint: /etc/nomos/run_mix_node.sh

etcd:
image: quay.io/coreos/etcd:v3.4.15
Expand Down
10 changes: 6 additions & 4 deletions testnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# BUILD IMAGE ---------------------------------------------------------

FROM rust:1.72.0-slim-bullseye AS builder
FROM rust:1.72.1-slim-bullseye AS builder

# Using backports for go 1.19
RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' \
>> /etc/apt/sources.list

# Dependecies for publishing documentation.
RUN apt-get update && apt-get install -yq \
git clang etcd-client
git clang etcd-client libssl-dev \
golang-src/bullseye-backports \
golang-doc/bullseye-backports \
golang/bullseye-backports

WORKDIR /nomos
COPY . .

RUN cargo build --release -p nomos-node
RUN cargo build --release -p mixnode
RUN cargo build --release --all

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

Expand Down
64 changes: 0 additions & 64 deletions testnet/config.yaml

This file was deleted.

File renamed without changes.
31 changes: 31 additions & 0 deletions testnet/run_mix_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

set -e

# Set env variables for nomos-node.
NET_NODE_KEY=$(./etc/nomos/register_node.sh)
CONSENSUS_PRIV_KEY=$NET_NODE_KEY

node_ids=$(etcdctl get "/node/" --prefix --keys-only)
for node_id in $node_ids; do
node_key=$(etcdctl get "/config${node_id}/key" --print-value-only)
node_ip=$(etcdctl get "/config${node_id}/ip" --print-value-only)
node_multiaddr="/ip4/${node_ip}/tcp/3000"

if [ -z "$OVERLAY_NODES" ]; then
OVERLAY_NODES=$node_key
NET_INITIAL_PEERS=$node_multiaddr
else
OVERLAY_NODES="${OVERLAY_NODES},${node_key}"
NET_INITIAL_PEERS="${NET_INITIAL_PEERS},${node_multiaddr}"
fi
done

export CONSENSUS_PRIV_KEY \
OVERLAY_NODES \
NET_NODE_KEY \
NET_INITIAL_PEERS

echo "I am a container ${HOSTNAME} node ${NET_NODE_KEY}"

exec /usr/bin/nomos-node /etc/nomos/config.yaml

0 comments on commit 8275fc7

Please sign in to comment.