Docker compose consensus layer config (#482)
* Same consensus node list for all nodes * Extract duplicate code and add debug info * Update initial net peer list script * Remove unused envvar
This commit is contained in:
parent
e50561839d
commit
eeb88b9430
14
compose.yml
14
compose.yml
|
@ -10,9 +10,11 @@ services:
|
|||
volumes:
|
||||
- ./testnet:/etc/nomos
|
||||
environment:
|
||||
- OVERLAY_SUPER_MAJORITY_THRESHOLD=${DOCKER_COMPOSE_SUPER_MAJORITY_THRESHOLD:-1}
|
||||
- NET_NODE_KEY=${DOCKER_COMPOSE_BOOSTRAP_NET_NODE_KEY:-1000000000000000000000000000000000000000000000000000000000000000}
|
||||
command: /etc/nomos/bootstrap_config.yaml
|
||||
- BOOTSTRAP_NODE_KEY=${DOCKER_COMPOSE_BOOSTRAP_NET_NODE_KEY:-1000000000000000000000000000000000000000000000000000000000000000}
|
||||
- LIBP2P_NODE_MASK=${DOCKER_COMPOSE_LIBP2P_NODE_KEY_MASK:-2000000000000000000000000000000000000000000000000000000000000000}
|
||||
- LIBP2P_REPLICAS=${DOCKER_COMPOSE_LIBP2P_REPLICAS:-1}
|
||||
- OVERLAY_NODES=${DOCKER_COMPOSE_OVERLAY_NODES:-1000000000000000000000000000000000000000000000000000000000000000}
|
||||
entrypoint: /etc/nomos/scripts/run_bootstrap_node.sh
|
||||
|
||||
libp2p-node:
|
||||
build:
|
||||
|
@ -29,14 +31,14 @@ services:
|
|||
- mix-node-1
|
||||
- mix-node-2
|
||||
environment:
|
||||
- OVERLAY_SUPER_MAJORITY_THRESHOLD=${DOCKER_COMPOSE_SUPER_MAJORITY_THRESHOLD:-1}
|
||||
- LIBP2P_REPLICAS=${DOCKER_COMPOSE_LIBP2P_REPLICAS:-1}
|
||||
- ETCDCTL_ENDPOINTS=${DOCKER_COMPOSE_ETCDCTL_ENDPOINTS:-etcd:2379}
|
||||
- ETCDCTL_API=${DOCKER_COMPOSE_ETCDCTL_API:-3}
|
||||
- NODE_MASK=${DOCKER_COMPOSE_LIBP2P_NODE_KEY_MASK:-2000000000000000000000000000000000000000000000000000000000000000}
|
||||
- LIBP2P_NODE_MASK=${DOCKER_COMPOSE_LIBP2P_NODE_KEY_MASK:-2000000000000000000000000000000000000000000000000000000000000000}
|
||||
- OVERLAY_NODES=${DOCKER_COMPOSE_OVERLAY_NODES:-1000000000000000000000000000000000000000000000000000000000000000}
|
||||
- OVERLAY_SUPER_MAJORITY_THRESHOLD=${DOCKER_COMPOSE_SUPER_MAJORITY_THRESHOLD:-1}
|
||||
- NET_INITIAL_PEERS=${DOCKER_COMPOSE_NET_INITIAL_PEERS:-/dns/bootstrap/tcp/3000}
|
||||
entrypoint: /etc/nomos/configure_node.sh
|
||||
entrypoint: /etc/nomos/scripts/run_nomos_node.sh
|
||||
|
||||
mix-node-0:
|
||||
build:
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# This node id will be used to generate consensus node list.
|
||||
tmp_node_id=0
|
||||
# OVERLAY_NODES might be set in compose.yml.
|
||||
tmp_overlay_nodes=$OVERLAY_NODES
|
||||
|
||||
# All spawned nodes should be added to consensus configuration.
|
||||
for i in $(seq 1 $LIBP2P_REPLICAS); do
|
||||
tmp_node_id=$((tmp_node_id + 1))
|
||||
node_key=$(/etc/nomos/scripts/node_key_from_id.sh "$LIBP2P_NODE_MASK" "$tmp_node_id")
|
||||
|
||||
if [ -z "$tmp_overlay_nodes" ]; then
|
||||
tmp_overlay_nodes=$node_key
|
||||
else
|
||||
tmp_overlay_nodes="${tmp_overlay_nodes},${node_key}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${tmp_overlay_nodes}"
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Usage: $0 <libp2p_node_mask> <node_id>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
libp2p_node_mask=$1
|
||||
node_id=$2
|
||||
|
||||
node_key_from_id() {
|
||||
echo "${libp2p_node_mask}" | sed "s/.\{${#node_id}\}$/${node_id}/"
|
||||
}
|
||||
|
||||
node_key_from_id
|
|
@ -1,9 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
# NODE_MASK is set via compose.yml file.
|
||||
|
||||
# LIBP2P_NODE_MASK is set via compose.yml file.
|
||||
node_key_from_id() {
|
||||
echo "${NODE_MASK}" | sed "s/.\{${#NODE_ID}\}$/${NODE_ID}/"
|
||||
echo "${LIBP2P_NODE_MASK}" | sed "s/.\{${#NODE_ID}\}$/${NODE_ID}/"
|
||||
}
|
||||
|
||||
END=$LIBP2P_REPLICAS
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
CONSENSUS_PRIV_KEY=$BOOTSTRAP_NODE_KEY
|
||||
NET_NODE_KEY=$BOOTSTRAP_NODE_KEY
|
||||
OVERLAY_NODES=$(/etc/nomos/scripts/consensus_node_list.sh)
|
||||
|
||||
export CONSENSUS_PRIV_KEY \
|
||||
OVERLAY_NODES \
|
||||
NET_NODE_KEY
|
||||
|
||||
echo "I am a container ${HOSTNAME} node ${NET_NODE_KEY}"
|
||||
echo "CONSENSUS_PRIV_KEY: ${CONSENSUS_PRIV_KEY}"
|
||||
echo "OVERLAY_NODES: ${OVERLAY_NODES}"
|
||||
|
||||
exec /usr/bin/nomos-node /etc/nomos/bootstrap_config.yaml
|
|
@ -3,8 +3,9 @@
|
|||
set -e
|
||||
|
||||
# Set env variables for nomos-node.
|
||||
NET_NODE_KEY=$(./etc/nomos/register_node.sh)
|
||||
NET_NODE_KEY=$(/etc/nomos/scripts/register_node.sh)
|
||||
CONSENSUS_PRIV_KEY=$NET_NODE_KEY
|
||||
OVERLAY_NODES=$(/etc/nomos/scripts/consensus_node_list.sh)
|
||||
|
||||
node_ids=$(etcdctl get "/node/" --prefix --keys-only)
|
||||
for node_id in $node_ids; do
|
||||
|
@ -12,11 +13,9 @@ for node_id in $node_ids; do
|
|||
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
|
||||
if [ -z "$NET_INITIAL_PEERS" ]; then
|
||||
NET_INITIAL_PEERS=$node_multiaddr
|
||||
else
|
||||
OVERLAY_NODES="${OVERLAY_NODES},${node_key}"
|
||||
NET_INITIAL_PEERS="${NET_INITIAL_PEERS},${node_multiaddr}"
|
||||
fi
|
||||
done
|
||||
|
@ -27,5 +26,8 @@ export CONSENSUS_PRIV_KEY \
|
|||
NET_INITIAL_PEERS
|
||||
|
||||
echo "I am a container ${HOSTNAME} node ${NET_NODE_KEY}"
|
||||
echo "CONSENSUS_PRIV_KEY: ${CONSENSUS_PRIV_KEY}"
|
||||
echo "OVERLAY_NODES: ${OVERLAY_NODES}"
|
||||
echo "NET_INITIAL_PEERS: ${NET_INITIAL_PEERS}"
|
||||
|
||||
exec /usr/bin/nomos-node /etc/nomos/libp2p_config.yaml
|
Loading…
Reference in New Issue