Skip to content

Commit 7ec6862

Browse files
authored
Merge pull request #768 from input-output-hk/ch1bo/eb-production-demo
Leios prototype demo February
2 parents d47975a + 99d7eab commit 7ec6862

File tree

19 files changed

+447
-143
lines changed

19 files changed

+447
-143
lines changed

demo/pre-commit-hooks.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
extends: relaxed
2727
rules:
2828
line-length:
29-
max: 120
29+
max: 180
3030
'';
3131
}

demo/proto-devnet/config/config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ TraceOptions:
8989
ChainSync.Client:
9090
severity: Debug
9191
ChainSync.Local:
92-
severity: Notice
92+
severity: Silence
9393
ChainSync.Remote:
9494
severity: Notice
9595
ChainSync.Remote.Serialised:
@@ -123,7 +123,7 @@ TraceOptions:
123123
Net.AcceptPolicy:
124124
severity: Debug
125125
Net.ConnectionManager.Local:
126-
severity: Debug
126+
severity: Silence
127127
Net.ConnectionManager.Remote:
128128
severity: Debug
129129
Net.ConnectionManager.Remote.ConnectionManagerCounters:
@@ -137,19 +137,19 @@ TraceOptions:
137137
Net.ErrorPolicy.Remote:
138138
severity: Debug
139139
Net.Handshake.Local:
140-
severity: Debug
140+
severity: Silence
141141
Net.Handshake.Remote:
142142
severity: Debug
143143
Net.InboundGovernor:
144144
severity: Warning
145145
Net.InboundGovernor.Local:
146-
severity: Debug
146+
severity: Silence
147147
Net.InboundGovernor.Remote:
148148
severity: Debug
149149
Net.InboundGovernor.Transition:
150150
severity: Debug
151151
Net.Mux.Local:
152-
severity: Notice
152+
severity: Silence
153153
Net.Mux.Remote:
154154
severity: Notice
155155
Net.PeerSelection:
@@ -174,7 +174,7 @@ TraceOptions:
174174
Net.Peers.PublicRoot:
175175
severity: Debug
176176
Net.Server.Local:
177-
severity: Debug
177+
severity: Silence
178178
Net.Server.Remote:
179179
severity: Debug
180180
Net.Subscription.DNS:
@@ -194,9 +194,9 @@ TraceOptions:
194194
StateQueryServer:
195195
severity: Notice
196196
TxSubmission.Local:
197-
severity: Notice
197+
severity: Silence
198198
TxSubmission.LocalServer:
199-
severity: Notice
199+
severity: Silence
200200
TxSubmission.MonitorClient:
201201
severity: Notice
202202
TxSubmission.Remote:

demo/proto-devnet/config/genesis/byron-genesis.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"startTime": 1657186415,
33
"protocolConsts": {
4-
"k": 10,
4+
"k": 432,
55
"protocolMagic": 164
66
},
77
"blockVersionData": {

demo/proto-devnet/config/genesis/shelley-genesis.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"networkMagic": 164,
55
"slotLength": 0.1,
66
"activeSlotsCoeff": 5.0e-2,
7-
"securityParam": 5,
8-
"epochLength": 500,
7+
"securityParam": 432,
8+
"epochLength": 86400,
99
"slotsPerKESPeriod": 129600,
1010
"maxKESEvolutions": 60,
1111
"maxLovelaceSupply": 100000000000000,

demo/proto-devnet/config/topology.template.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"bootstrapPeers": [],
32
"localRoots": [
43
{
54
"accessPoints": [],

demo/proto-devnet/process-compose.yaml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,60 @@
11
version: "0.5"
22
is_strict: true
33

4+
# NOTE: Elevated processes (is_elevated: true) run via sudo, which does not
5+
# preserve environment variables. We must explicitly pass needed variables
6+
# inline in the command for them to be available in elevated scripts.
7+
48
processes:
9+
InitNamespaces:
10+
is_elevated: true
11+
command: |
12+
RATE="${RATE}" \
13+
DELAY="${DELAY}" \
14+
IP_NODE1="${IP_NODE1}" \
15+
IP_NODE2="${IP_NODE2}" \
16+
IP_NODE3="${IP_NODE3}" \
17+
IP_HOST="${IP_HOST}" \
18+
bash "${SOURCE_DIR}/scripts/init-namespaces.sh"
19+
520
Node1:
6-
environment:
7-
- NODE_ID=1
8-
command: bash "${SOURCE_DIR}/run-node.sh"
21+
is_elevated: true
22+
command: |
23+
NODE_DIR="${WORKING_DIR}/node1" \
24+
IP="${IP_NODE1}" \
25+
PORT="${PORT_NODE1}" \
26+
ip netns exec proto-devnet:node1 bash "${SOURCE_DIR}/run-node.sh"
927
log_location: "${WORKING_DIR}/node1/node.log"
28+
depends_on:
29+
InitNamespaces:
30+
condition: process_completed_successfully
1031

1132
Node2:
12-
environment:
13-
- NODE_ID=2
14-
command: bash "${SOURCE_DIR}/run-node.sh"
33+
is_elevated: true
34+
command: |
35+
NODE_DIR="${WORKING_DIR}/node2" \
36+
IP="${IP_NODE2}" \
37+
PORT="${PORT_NODE2}" \
38+
ip netns exec proto-devnet:node2 bash "${SOURCE_DIR}/run-node.sh"
1539
log_location: "${WORKING_DIR}/node2/node.log"
40+
depends_on:
41+
InitNamespaces:
42+
condition: process_completed_successfully
1643

1744
Node3:
18-
environment:
19-
- NODE_ID=3
20-
command: bash "${SOURCE_DIR}/run-node.sh"
45+
is_elevated: true
46+
command: |
47+
NODE_DIR="${WORKING_DIR}/node3" \
48+
IP="${IP_NODE3}" \
49+
PORT="${PORT_NODE3}" \
50+
ip netns exec proto-devnet:node3 bash "${SOURCE_DIR}/run-node.sh"
2151
log_location: "${WORKING_DIR}/node3/node.log"
52+
depends_on:
53+
InitNamespaces:
54+
condition: process_completed_successfully
2255

2356
TxGenerator:
24-
command: sleep 5 && tx-generator json_highlevel gen.json
25-
working_dir: ${WORKING_DIR}
57+
command: while [ ! -S ${WORKING_DIR}/node1/node.socket ]; do sleep 0.5; done && cd ${WORKING_DIR} && tx-generator json_highlevel gen.json
2658
depends_on:
2759
Node1:
2860
condition: process_started

demo/proto-devnet/run-node.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# Generic node run script that uses NODE_ID environment variable
5-
# Expects WORKING_DIR and NODE_ID to be set
6-
7-
NODE_DIR="$WORKING_DIR/node${NODE_ID}"
4+
# Generic node run script
5+
# Expects NODE_DIR, IP, and PORT to be set
86

97
cd "$NODE_DIR"
108

11-
# Select ip and port from environment variables using NODE_ID
12-
ip="IP_NODE${NODE_ID}"
13-
port="PORT_NODE${NODE_ID}"
14-
159
export LEIOS_DB_PATH="leios.db"
1610

11+
# Make socket accessible to non-root (node runs elevated for namespace access)
12+
(while [ ! -S "node.socket" ]; do sleep 0.1; done; chmod a+rw "node.socket") &
13+
1714
# Run cardano-node
1815
cardano-node run \
1916
--config "config.yaml" \
20-
--host-addr "${!ip}" \
21-
--port "${!port}" \
17+
--host-addr "$IP" \
18+
--port "$PORT" \
2219
--topology "topology.json" \
2320
--database-path "db" \
2421
--socket-path "node.socket" \

demo/proto-devnet/run.sh

Lines changed: 75 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,62 @@ set -eo pipefail
99
set -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}"
2125
set +a
2226

2327
# Check for required commands
2428
REQUIRED_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

3539
MISSING_COMMANDS=()
3640
for 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
4044
done
4145

4246
if [ ${#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
5155
fi
5256

5357
# Check if WORKING_DIR already exists
5458
if [ -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
6468
fi
6569
echo "Initializing proto-devnet in $WORKING_DIR"
6670

@@ -77,51 +81,51 @@ startTimeEpoch=$(date +%s)
7781
startTimeIso=$(date -u -d "@$startTimeEpoch" +"%Y-%m-%dT%H:%M:%SZ")
7882

7983
jq --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

8286
jq --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
8690
nodes=(1 2 3)
8791
for 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
125129
done
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"
140144
envsubst <"${CONFIG_DIR}/alloy.template" >"${WORKING_DIR}/alloy"
141145

142146
echo "Starting proto-devnet with process-compose..."
147+
echo " Traffic control: ${RATE} / ${DELAY}"
143148
process-compose --no-server -f "${SOURCE_DIR}/process-compose.yaml"

0 commit comments

Comments
 (0)