Skip to content

Commit 615bf79

Browse files
committed
feat(scripts): support empty and mixed UTXO backends
- Add "empty" as a valid option for UTXO_BACKEND and MIXED_UTXO_BACKENDS in both common-start-fast and common-start-slow scripts. - Implement logic to rotate through mixed UTXO backends for block producing nodes, defaulting to "empty" (unset) when specified. - Update testnet.json documentation to clarify that the default backend is "empty" (mem without configuration) if unset.
1 parent 1b99296 commit 615bf79

File tree

5 files changed

+76
-15
lines changed

5 files changed

+76
-15
lines changed

src/cardonnay_scripts/scripts/common/common-start-fast

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ initialize_globals() {
5656
fi
5757

5858
case "${UTXO_BACKEND:=""}" in
59-
"" | mem | disk | disklmdb)
59+
"" | mem | disk | disklmdb | empty)
6060
;;
6161
*)
6262
echo "Unknown \`UTXO_BACKEND\`: '$UTXO_BACKEND', line $LINENO in ${BASH_SOURCE[0]}" >&2
@@ -65,6 +65,21 @@ initialize_globals() {
6565
esac
6666
readonly UTXO_BACKEND
6767

68+
local backend
69+
UTXO_BACKENDS=()
70+
for backend in ${MIXED_UTXO_BACKENDS:=""}; do
71+
case "$backend" in
72+
mem | disk | disklmdb | empty)
73+
UTXO_BACKENDS+=("$backend")
74+
;;
75+
*)
76+
echo "Unknown \`MIXED_UTXO_BACKENDS\` entry: '$backend', line $LINENO in ${BASH_SOURCE[0]}" >&2
77+
exit 1
78+
;;
79+
esac
80+
done
81+
readonly UTXO_BACKENDS
82+
6883
SECURITY_PARAM="$(jq '.securityParam' < "${SCRIPT_DIR}/genesis.spec.json")"
6984
readonly SECURITY_PARAM
7085
NETWORK_MAGIC="$(jq '.networkMagic' < "${SCRIPT_DIR}/genesis.spec.json")"
@@ -187,22 +202,39 @@ get_genesis_data() {
187202

188203
edit_node_configs() {
189204
local live_tables_base="${STATE_CLUSTER_NAME}/lmdb"
190-
local conf fname node_name pool_num
205+
local conf fname node_name pool_num utxo_backend
191206

192207
for conf in "$SCRIPT_DIR"/config-*.json; do
193208
[ -e "$conf" ] || { echo "No config files found in ${SCRIPT_DIR}, line $LINENO in ${BASH_SOURCE[0]}" >&2; exit 1; }
194209
fname="${conf##*/}"
195210
node_name="${fname##config-}"
196211
node_name="${node_name%.json}"
197212

213+
if [ "$fname" = "config-bft1.json" ]; then
214+
pool_num=""
215+
else
216+
pool_num="${fname##*-pool}"
217+
pool_num="${pool_num%.json}"
218+
fi
219+
220+
utxo_backend="${UTXO_BACKEND}"
221+
# Rotate through the mixed backends for block producing nodes, if set.
222+
if [ -n "$pool_num" ] && [ "${#UTXO_BACKENDS[@]}" -gt 0 ]; then
223+
index=$(( (pool_num - 1) % ${#UTXO_BACKENDS[@]} ))
224+
utxo_backend="${UTXO_BACKENDS[$index]}"
225+
fi
226+
if [ "$utxo_backend" = "empty" ]; then
227+
utxo_backend=""
228+
fi
229+
198230
jq \
199231
--arg byron_hash "$BYRON_GENESIS_HASH" \
200232
--arg shelley_hash "$SHELLEY_GENESIS_HASH" \
201233
--arg alonzo_hash "$ALONZO_GENESIS_HASH" \
202234
--arg conway_hash "$CONWAY_GENESIS_HASH" \
203235
--arg dijkstra_hash "$DIJKSTRA_GENESIS_HASH" \
204236
--argjson prot_ver "$PROTOCOL_VERSION" \
205-
--arg backend "$UTXO_BACKEND" \
237+
--arg backend "$utxo_backend" \
206238
--arg live_tables_path "${live_tables_base}-${node_name}" \
207239
'.ByronGenesisHash = $byron_hash
208240
| .ShelleyGenesisHash = $shelley_hash
@@ -241,13 +273,11 @@ edit_node_configs() {
241273
if [ -z "${ENABLE_LEGACY:-}" ]; then
242274

243275
if [ -n "${MIXED_P2P:-}" ]; then
244-
if [ "$fname" = "config-bft1.json" ]; then
276+
if [ -z "$pool_num" ]; then
245277
cp -f "$SCRIPT_DIR"/topology-bft1.json "$STATE_CLUSTER"
246278
continue
247279
fi
248280

249-
pool_num="${fname##*-pool}"
250-
pool_num="${pool_num%.json}"
251281
if [ "$((pool_num % 2))" != 0 ]; then
252282
cp -f "${SCRIPT_DIR}/topology-pool${pool_num}.json" "$STATE_CLUSTER"
253283
continue

src/cardonnay_scripts/scripts/common/common-start-slow

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ initialize_globals() {
6262
fi
6363

6464
case "${UTXO_BACKEND:=""}" in
65-
"" | mem | disk | disklmdb)
65+
"" | mem | disk | disklmdb | empty)
6666
;;
6767
*)
6868
echo "Unknown \`UTXO_BACKEND\`: '$UTXO_BACKEND', line $LINENO in ${BASH_SOURCE[0]}" >&2
@@ -71,6 +71,21 @@ initialize_globals() {
7171
esac
7272
readonly UTXO_BACKEND
7373

74+
local backend
75+
UTXO_BACKENDS=()
76+
for backend in ${MIXED_UTXO_BACKENDS:=""}; do
77+
case "$backend" in
78+
mem | disk | disklmdb | empty)
79+
UTXO_BACKENDS+=("$backend")
80+
;;
81+
*)
82+
echo "Unknown \`MIXED_UTXO_BACKENDS\` entry: '$backend', line $LINENO in ${BASH_SOURCE[0]}" >&2
83+
exit 1
84+
;;
85+
esac
86+
done
87+
readonly UTXO_BACKENDS
88+
7489
SECURITY_PARAM="$(jq '.securityParam' < "${SCRIPT_DIR}/genesis.spec.json")"
7590
readonly SECURITY_PARAM
7691
NETWORK_MAGIC="$(jq '.networkMagic' < "${SCRIPT_DIR}/genesis.spec.json")"
@@ -189,21 +204,39 @@ get_genesis_data() {
189204

190205
edit_node_configs() {
191206
local live_tables_base="${STATE_CLUSTER_NAME}/lmdb"
192-
local conf fname node_name pool_num
207+
local conf fname node_name pool_num utxo_backend
193208

194209
for conf in "$SCRIPT_DIR"/config-*.json; do
195210
[ -e "$conf" ] || { echo "No config files found in ${SCRIPT_DIR}, line $LINENO in ${BASH_SOURCE[0]}" >&2; exit 1; }
196211
fname="${conf##*/}"
197212
node_name="${fname##config-}"
198213
node_name="${node_name%.json}"
199214

215+
if [ "$fname" = "config-bft1.json" ]; then
216+
pool_num=""
217+
else
218+
pool_num="${fname##*-pool}"
219+
pool_num="${pool_num%.json}"
220+
fi
221+
222+
utxo_backend="${UTXO_BACKEND}"
223+
# Rotate through the mixed backends for block producing nodes, if set.
224+
if [ -n "$pool_num" ] && [ "${#UTXO_BACKENDS[@]}" -gt 0 ]; then
225+
index=$(( (pool_num - 1) % ${#UTXO_BACKENDS[@]} ))
226+
utxo_backend="${UTXO_BACKENDS[$index]}"
227+
fi
228+
if [ "$utxo_backend" = "empty" ]; then
229+
utxo_backend=""
230+
fi
231+
232+
200233
jq \
201234
--arg byron_hash "$BYRON_GENESIS_HASH" \
202235
--arg shelley_hash "$SHELLEY_GENESIS_HASH" \
203236
--arg alonzo_hash "$ALONZO_GENESIS_HASH" \
204237
--arg conway_hash "$CONWAY_GENESIS_HASH" \
205238
--arg dijkstra_hash "$DIJKSTRA_GENESIS_HASH" \
206-
--arg backend "$UTXO_BACKEND" \
239+
--arg backend "$utxo_backend" \
207240
--arg live_tables_path "${live_tables_base}-${node_name}" \
208241
'.ByronGenesisHash = $byron_hash
209242
| .ShelleyGenesisHash = $shelley_hash
@@ -236,13 +269,11 @@ edit_node_configs() {
236269

237270
if [ -z "${ENABLE_LEGACY:-}" ]; then
238271
if [ -n "${MIXED_P2P:-}" ]; then
239-
if [ "$fname" = "config-bft1.json" ]; then
272+
if [ -z "$pool_num" ]; then
240273
cp -f "$SCRIPT_DIR"/topology-bft1.json "$STATE_CLUSTER"
241274
continue
242275
fi
243276

244-
pool_num="${fname##*-pool}"
245-
pool_num="${pool_num%.json}"
246277
if [ "$((pool_num % 2))" != 0 ]; then
247278
cp -f "${SCRIPT_DIR}/topology-pool${pool_num}.json" "$STATE_CLUSTER"
248279
continue

src/cardonnay_scripts/scripts/conway_fast/testnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"SMASH": "if set, will start and configure smash",
77
"ENABLE_LEGACY": "if set, local cluster will use legacy networking",
88
"MIXED_P2P": "if set, local cluster will use P2P for some nodes and legacy topology for others",
9-
"UTXO_BACKEND": "'mem', 'disk' or 'disklmdb', default is 'mem' (or legacy) if unset",
9+
"UTXO_BACKEND": "'mem', 'disk', 'disklmdb' or `empty`, default is `empty` (mem without configuration) if unset",
1010
"NO_CC": "if set, will not create committee",
1111
"DRY_RUN": "if set, will not start the cluster",
1212
"PROTOCOL_VERSION": "if set, will use the specified protocol version (e.g., 11 for latest Conway, etc.)"

src/cardonnay_scripts/scripts/conway_slow/testnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"SMASH": "if set, will start and configure smash",
77
"ENABLE_LEGACY": "if set, local cluster will use legacy networking",
88
"MIXED_P2P": "if set, local cluster will use P2P for some nodes and legacy topology for others",
9-
"UTXO_BACKEND": "'mem', 'disk' or 'disklmdb', default is 'mem' (or legacy) if unset",
9+
"UTXO_BACKEND": "'mem', 'disk', 'disklmdb' or `empty`, default is `empty` (mem without configuration) if unset",
1010
"NO_CC": "if set, will not create committee",
1111
"DRY_RUN": "if set, will not start the cluster",
1212
"PROTOCOL_VERSION": "if set, will use the specified protocol version (e.g., 11 for latest Conway, etc.)"

src/cardonnay_scripts/scripts/mainnet_fast/testnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"SMASH": "if set, will start and configure smash",
77
"ENABLE_LEGACY": "if set, local cluster will use legacy networking",
88
"MIXED_P2P": "if set, local cluster will use P2P for some nodes and legacy topology for others",
9-
"UTXO_BACKEND": "'mem', 'disk' or 'disklmdb', default is 'mem' (or legacy) if unset",
9+
"UTXO_BACKEND": "'mem', 'disk', 'disklmdb' or `empty`, default is `empty` (mem without configuration) if unset",
1010
"NO_CC": "if set, will not create committee",
1111
"DRY_RUN": "if set, will not start the cluster",
1212
"PROTOCOL_VERSION": "if set, will use the specified protocol version (e.g., 11 for latest Conway, etc.)"

0 commit comments

Comments
 (0)