From 8275fc781749e4313e3545b4f8581e207e7994a1 Mon Sep 17 00:00:00 2001 From: Gusto Date: Thu, 28 Sep 2023 15:37:09 +0300 Subject: [PATCH] Update libp2p node config --- Dockerfile | 2 +- compose.yml | 22 ++++++- testnet/Dockerfile | 10 +-- testnet/config.yaml | 64 ------------------- .../{configure_node.sh => run_libp2p_node.sh} | 0 testnet/run_mix_node.sh | 31 +++++++++ 6 files changed, 59 insertions(+), 70 deletions(-) delete mode 100644 testnet/config.yaml rename testnet/{configure_node.sh => run_libp2p_node.sh} (100%) create mode 100755 testnet/run_mix_node.sh diff --git a/Dockerfile b/Dockerfile index 2471df6c..447de407 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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' \ diff --git a/compose.yml b/compose.yml index 7803c4c0..f35b5bbb 100644 --- a/compose.yml +++ b/compose.yml @@ -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 diff --git a/testnet/Dockerfile b/testnet/Dockerfile index b646f437..9c837a90 100644 --- a/testnet/Dockerfile +++ b/testnet/Dockerfile @@ -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' \ @@ -8,13 +8,15 @@ RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' \ # 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 ---------------------------------------------------------- diff --git a/testnet/config.yaml b/testnet/config.yaml deleted file mode 100644 index 5e31a282..00000000 --- a/testnet/config.yaml +++ /dev/null @@ -1,64 +0,0 @@ -log: - backend: "Stdout" - format: "Json" - level: "debug" -consensus: - private_key: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - fountain_settings: null - overlay_settings: - nodes: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]] - number_of_committees: 1 - current_leader: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - leader: - cur: 0 - committee_membership: !Sad - entropy: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - -network: - backend: - host: 0.0.0.0 - port: 3000 - log_level: "fatal" - node_key: "0000000000000000000000000000000000000000000000000000000000000001" - discV5BootstrapNodes: [] - initial_peers: [] - relayTopics: [] - # Mixclient configuration to communicate with mixnodes. - # The libp2p network backend always requires this mixclient configuration - # (cannot be disabled for now). - mixnet_client: - # A mixclient mode. For details, see the documentation of the "mixnet" crate. - # - Sender - # - !SenderReceiver [mixnode_client_listen_address] - mode: Sender - # A mixnet topology, which contains the information of all mixnodes in the mixnet. - # (The topology is static for now.) - topology: - # Each mixnet layer consists of a list of mixnodes. - layers: - - nodes: - - address: 127.0.0.1:7777 # A listen address of the mixnode - # A ed25519 public key for encrypting Sphinx packets for the mixnode - public_key: "0000000000000000000000000000000000000000000000000000000000000000" - # A max number of connections that will stay connected to mixnodes in the first mixnet layer. - connection_pool_size: 255 - # A range of total delay that will be set to each Sphinx packets - # sent to the mixnet for timing obfuscation. - # Panics if start > end. - mixnet_delay: - start: "0ms" - end: "0ms" - -http: - backend: - address: 0.0.0.0:8080 - cors_origins: [] - -da: - da_protocol: - num_attestations: 1 - backend: - max_capacity: 10 - evicting_period: - secs: 3600 - nanos: 0 diff --git a/testnet/configure_node.sh b/testnet/run_libp2p_node.sh similarity index 100% rename from testnet/configure_node.sh rename to testnet/run_libp2p_node.sh diff --git a/testnet/run_mix_node.sh b/testnet/run_mix_node.sh new file mode 100755 index 00000000..0ee22d37 --- /dev/null +++ b/testnet/run_mix_node.sh @@ -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