@@ -9,58 +9,62 @@ set -eo pipefail
99set -a
1010: " ${WORKING_DIR:= tmp-devnet} "
1111: " ${SOURCE_DIR:= $(cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)} "
12- : " ${IP_NODE1:= 127.0 .0.1 } "
12+ : " ${IP_NODE1:= 172.28 .0.10 } "
1313: " ${PORT_NODE1:= 3001} "
14- : " ${IP_NODE2:= 127.0 .0.1 } "
14+ : " ${IP_NODE2:= 172.28 .0.20 } "
1515: " ${PORT_NODE2:= 3002} "
16- : " ${IP_NODE3:= 127.0 .0.1 } "
16+ : " ${IP_NODE3:= 172.28 .0.30 } "
1717: " ${PORT_NODE3:= 3003} "
1818: " ${METRICS_PORT_NODE1:= 12901} "
1919: " ${METRICS_PORT_NODE2:= 12902} "
2020: " ${METRICS_PORT_NODE3:= 12903} "
21+ : " ${IP_HOST:= 172.28.0.1} "
22+ # Traffic control settings (symmetric, applied to all edges)
23+ : " ${RATE:= 10Mbps} "
24+ : " ${DELAY:= 200ms} "
2125set +a
2226
2327# Check for required commands
2428REQUIRED_COMMANDS=(
25- " process-compose"
26- " sqlite3"
27- " jq"
28- " yq"
29- " envsubst"
30- " cardano-node"
31- " cardano-cli"
32- " tx-generator"
29+ " process-compose"
30+ " sqlite3"
31+ " jq"
32+ " yq"
33+ " envsubst"
34+ " cardano-node"
35+ " cardano-cli"
36+ " tx-generator"
3337)
3438
3539MISSING_COMMANDS=()
3640for cmd in " ${REQUIRED_COMMANDS[@]} " ; do
37- if ! command -v " $cmd " & > /dev/null; then
38- MISSING_COMMANDS+=(" $cmd " )
39- fi
41+ if ! command -v " $cmd " & > /dev/null; then
42+ MISSING_COMMANDS+=(" $cmd " )
43+ fi
4044done
4145
4246if [ ${# MISSING_COMMANDS[@]} -gt 0 ]; then
43- echo " Error: The following required commands are not available:"
44- for cmd in " ${MISSING_COMMANDS[@]} " ; do
45- echo " - $cmd "
46- done
47- echo " "
48- echo " Please install the missing commands or use nix:"
49- echo " nix run github:input-output-hk/ouroboros-leios#demo-proto-devnet"
50- exit 1
47+ echo " Error: The following required commands are not available:"
48+ for cmd in " ${MISSING_COMMANDS[@]} " ; do
49+ echo " - $cmd "
50+ done
51+ echo " "
52+ echo " Please install the missing commands or use nix:"
53+ echo " nix run github:input-output-hk/ouroboros-leios#demo-proto-devnet"
54+ exit 1
5155fi
5256
5357# Check if WORKING_DIR already exists
5458if [ -d " $WORKING_DIR " ]; then
55- echo " Working directory already exists: $WORKING_DIR "
56- read -r -rp " Remove and re-initialize? (Y/n): " response
57- if [[ " $response " =~ ^[Yy]$ || -z " $response " ]]; then
58- chmod a+w -R " $WORKING_DIR "
59- rm -rf " $WORKING_DIR "
60- else
61- echo " Aborting."
62- exit 0
63- fi
59+ echo " Working directory already exists: $WORKING_DIR "
60+ read -r -rp " Remove and re-initialize? (Y/n): " response
61+ if [[ " $response " =~ ^[Yy]$ || -z " $response " ]]; then
62+ chmod a+w -R " $WORKING_DIR "
63+ rm -rf " $WORKING_DIR "
64+ else
65+ echo " Aborting."
66+ exit 0
67+ fi
6468fi
6569echo " Initializing proto-devnet in $WORKING_DIR "
6670
@@ -77,51 +81,51 @@ startTimeEpoch=$(date +%s)
7781startTimeIso=$( date -u -d " @$startTimeEpoch " +" %Y-%m-%dT%H:%M:%SZ" )
7882
7983jq --argjson time " $startTimeEpoch " ' .startTime = $time' \
80- " $CONFIG_DIR /genesis/byron-genesis.json" > " $WORKING_DIR /genesis/byron-genesis.json"
84+ " $CONFIG_DIR /genesis/byron-genesis.json" > " $WORKING_DIR /genesis/byron-genesis.json"
8185
8286jq --arg time " $startTimeIso " ' .systemStart = $time' \
83- " $CONFIG_DIR /genesis/shelley-genesis.json" > " $WORKING_DIR /genesis/shelley-genesis.json"
87+ " $CONFIG_DIR /genesis/shelley-genesis.json" > " $WORKING_DIR /genesis/shelley-genesis.json"
8488
8589# Set up each node
8690nodes=(1 2 3)
8791for i in " ${nodes[@]} " ; do
88- NODE_NAME=" node$i "
89- NODE_DIR=" $WORKING_DIR /$NODE_NAME "
90- POOL_DIR=" $CONFIG_DIR /pools-keys/pool$i "
91-
92- echo " Setting up $NODE_NAME in $NODE_DIR "
93- mkdir -p " $NODE_DIR "
94-
95- # Copy config files
96- cat " $CONFIG_DIR /config.yaml" |
97- yq " .TraceOptionNodeName = \" $NODE_NAME \" " |
98- yq " .TraceOptions.\"\" .backends[1] = \" PrometheusSimple 127 .0.0.1 $(( 12900 + "$i ")) \" " \
99- > " $NODE_DIR /config.yaml"
100-
101- # Generate upstream endpoints to other nodes
102- accessPoints=$( for j in " ${nodes[@]} " ; do
103- # Except self
104- if [ " $i " -ne " $j " ]; then
105- port=" PORT_NODE$j "
106- address=" IP_NODE$j "
107- echo " { \" port\" : ${! port} , \" address\" : \" ${! address} \" }"
108- fi
109- done | jq -s ' .' )
110- jq \
111- --argjson accessPoints " $accessPoints " \
112- ' .localRoots[0].accessPoints = $accessPoints' \
113- " $CONFIG_DIR /topology.template.json" > " $NODE_DIR /topology.json"
114-
115- # Symlink genesis files (shared, read-only)
116- ln -s " ../genesis/byron-genesis.json" " $NODE_DIR /"
117- ln -s " ../genesis/shelley-genesis.json" " $NODE_DIR /"
118- ln -s " ../genesis/alonzo-genesis.json" " $NODE_DIR /"
119- ln -s " ../genesis/conway-genesis.json" " $NODE_DIR /"
120- ln -s " ../genesis/dijkstra-genesis.json" " $NODE_DIR /"
121-
122- # Copy pool keys and set permissions
123- cp -r " $POOL_DIR " " $NODE_DIR /keys"
124- chmod 400 " $NODE_DIR /keys" /* .skey
92+ NODE_NAME=" node$i "
93+ NODE_DIR=" $WORKING_DIR /$NODE_NAME "
94+ POOL_DIR=" $CONFIG_DIR /pools-keys/pool$i "
95+
96+ echo " Setting up $NODE_NAME in $NODE_DIR "
97+ mkdir -p " $NODE_DIR "
98+
99+ # Copy config files
100+ cat " $CONFIG_DIR /config.yaml" |
101+ yq " .TraceOptionNodeName = \" $NODE_NAME \" " |
102+ yq " .TraceOptions.\"\" .backends[1] = \" PrometheusSimple 0 .0.0.0 $(( 12900 + "$i ")) \" " \
103+ > " $NODE_DIR /config.yaml"
104+
105+ # Generate upstream endpoints to other nodes
106+ accessPoints=$( for j in " ${nodes[@]} " ; do
107+ # Except self
108+ if [ " $i " -ne " $j " ]; then
109+ port=" PORT_NODE$j "
110+ address=" IP_NODE$j "
111+ echo " { \" port\" : ${! port} , \" address\" : \" ${! address} \" }"
112+ fi
113+ done | jq -s ' .' )
114+ jq \
115+ --argjson accessPoints " $accessPoints " \
116+ ' .localRoots[0].accessPoints = $accessPoints' \
117+ " $CONFIG_DIR /topology.template.json" > " $NODE_DIR /topology.json"
118+
119+ # Symlink genesis files (shared, read-only)
120+ ln -s " ../genesis/byron-genesis.json" " $NODE_DIR /"
121+ ln -s " ../genesis/shelley-genesis.json" " $NODE_DIR /"
122+ ln -s " ../genesis/alonzo-genesis.json" " $NODE_DIR /"
123+ ln -s " ../genesis/conway-genesis.json" " $NODE_DIR /"
124+ ln -s " ../genesis/dijkstra-genesis.json" " $NODE_DIR /"
125+
126+ # Copy pool keys and set permissions
127+ cp -r " $POOL_DIR " " $NODE_DIR /keys"
128+ chmod 400 " $NODE_DIR /keys" /* .skey
125129done
126130
127131# Copy utxo-keys for tx-generator and set permissions
@@ -140,4 +144,5 @@ envsubst <"${CONFIG_DIR}/gen.template.json" >"${WORKING_DIR}/gen.json"
140144envsubst < " ${CONFIG_DIR} /alloy.template" > " ${WORKING_DIR} /alloy"
141145
142146echo " Starting proto-devnet with process-compose..."
147+ echo " Traffic control: ${RATE} / ${DELAY} "
143148process-compose --no-server -f " ${SOURCE_DIR} /process-compose.yaml"
0 commit comments