Skip to content

Commit f3baab0

Browse files
committed
imp: update nix job gen-custom-node-config-data for compat fork to plomin
1 parent 299c05f commit f3baab0

File tree

1 file changed

+25
-42
lines changed

1 file changed

+25
-42
lines changed

flakeModules/jobs.nix

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,14 @@ in {
363363
runtimeInputs = stdPkgs;
364364
text = ''
365365
# Inputs:
366+
# [$CC_DIR]
366367
# [$DEBUG]
367368
# [$ENV]
368369
# [$ERA_CMD]
369370
# [$GENESIS_DIR]
370371
# [$INITIAL_FUNDS]
371372
# [$MAX_SUPPLY]
373+
# [$NUM_CC_KEYS]
372374
# [$NUM_GENESIS_KEYS]
373375
# [$SECURITY_PARAM]
374376
# [$SLOT_LENGTH]
@@ -385,9 +387,11 @@ in {
385387
export START_TIME=''${START_TIME:-$(date --utc +"%Y-%m-%dT%H:%M:%SZ" --date " now +30 min")}
386388
export SLOT_LENGTH=''${SLOT_LENGTH:-1000}
387389
export SECURITY_PARAM=''${SECURITY_PARAM:-36}
390+
export NUM_CC_KEYS=''${NUM_CC_KEYS:-1}
388391
export NUM_GENESIS_KEYS=''${NUM_GENESIS_KEYS:-3}
389392
export TESTNET_MAGIC=''${TESTNET_MAGIC:-42}
390393
export GENESIS_DIR=''${GENESIS_DIR:-"./workbench/custom"}
394+
export CC_DIR=''${CC_DIR:-"./workbench/custom/envs/custom/cc-keys"}
391395
392396
if [ "''${UNSTABLE_LIB:-}" = "true" ]; then
393397
export TEMPLATE_DIR=''${TEMPLATE_DIR:-"${localFlake.inputs.iohk-nix-ng}/cardano-lib/testnet-template"}
@@ -413,6 +417,7 @@ in {
413417
"''${CARDANO_CLI[@]}" genesis create-testnet-data \
414418
--genesis-keys "$NUM_GENESIS_KEYS" \
415419
--utxo-keys 1 \
420+
--committee-keys "$NUM_CC_KEYS" \
416421
--total-supply "$MAX_SUPPLY" \
417422
--delegated-supply 0 \
418423
--testnet-magic "$TESTNET_MAGIC" \
@@ -422,27 +427,6 @@ in {
422427
--start-time "$START_TIME" \
423428
--out-dir "$GENESIS_DIR"
424429
425-
# Remove when node release is > 10.1.4
426-
if [ "''${UNSTABLE:-}" != "true" ]; then
427-
# cardano-cli "$ERA_CMD" genesis create-testnet-data doesn't provide a byron genesis
428-
# whereas -ng now does
429-
"''${CARDANO_CLI_NO_ERA[@]}" byron genesis genesis \
430-
--protocol-magic "$TESTNET_MAGIC" \
431-
--start-time "$(date +%s -d "$START_TIME")" \
432-
--k "$SECURITY_PARAM" \
433-
--n-poor-addresses 0 \
434-
--n-delegate-addresses "$NUM_GENESIS_KEYS" \
435-
--total-balance "$MAX_SUPPLY" \
436-
--delegate-share 0 \
437-
--avvm-entry-count 0 \
438-
--avvm-entry-balance 0 \
439-
--protocol-parameters-file "$TEMPLATE_DIR/byron.json" \
440-
--genesis-output-dir "$GENESIS_DIR/byron-config"
441-
442-
# Move the byron genesis into the same dir as shelley, alonzo, conway genesis files
443-
mv "$GENESIS_DIR/byron-config/genesis.json" "$GENESIS_DIR/byron-genesis.json"
444-
fi
445-
446430
# If initial funds is explicitly declared for the rich key, set it here
447431
if [ -n "''${INITIAL_FUNDS:-}" ]; then
448432
jq ".initialFunds[.initialFunds | to_entries | sort_by(.value)[-1].key] |= $INITIAL_FUNDS" \
@@ -461,6 +445,13 @@ in {
461445
< "$GENESIS_DIR/shelley-genesis.json" \
462446
| sponge "$GENESIS_DIR/shelley-genesis.json"
463447
448+
# Constitutional committee threshold will be set to 0 by default
449+
jq --sort-keys \
450+
--argjson jsonUpdates '{"numerator": 2, "denominator": 3}' \
451+
'.committee.threshold = $jsonUpdates' \
452+
< "$GENESIS_DIR/conway-genesis.json" \
453+
| sponge "$GENESIS_DIR/conway-genesis.json"
454+
464455
# Obtain a base node config and topology
465456
cp "$TEMPLATE_DIR/config.json" "$GENESIS_DIR/node-config.json"
466457
cp "$TEMPLATE_DIR/topology-empty-p2p.json" "$GENESIS_DIR/topology.json"
@@ -500,18 +491,9 @@ in {
500491
mv "genesis$((i + 1))/key.skey" "shelley.$(printf "%03d" "$i").skey"
501492
mv "genesis$((i + 1))/key.vkey" "shelley.$(printf "%03d" "$i").vkey"
502493
rmdir "genesis$((i + 1))/"
503-
504-
505-
# Remove when node release is > 10.1.4
506-
if [ "''${UNSTABLE:-}" != "true" ]; then
507-
mv ../byron-config/genesis-keys."$(printf "%03d" "$i")".key "byron.$(printf "%03d" "$i").key"
508-
fi
509494
done
510495
511-
# Remove if scope when node release is > 10.1.4
512-
if [ "''${UNSTABLE:-}" = "true" ]; then
513-
mv ../byron-gen-command/genesis-keys.000.key byron.000.key
514-
fi
496+
mv ../byron-gen-command/genesis-keys.000.key byron.000.key
515497
popd &> /dev/null
516498
517499
# Transform the delegate key subdirs into a create-cardano compatible layout
@@ -526,21 +508,21 @@ in {
526508
mv "delegate$((i + 1))/vrf.skey" "shelley.$(printf "%03d" "$i").vrf.skey"
527509
mv "delegate$((i + 1))/vrf.vkey" "shelley.$(printf "%03d" "$i").vrf.vkey"
528510
rmdir "delegate$((i + 1))/"
529-
530-
# Remove when node release is > 10.1.4
531-
if [ "''${UNSTABLE:-}" != "true" ]; then
532-
mv ../byron-config/delegate-keys."$(printf "%03d" "$i")".key "byron.$(printf "%03d" "$i").key"
533-
mv ../byron-config/delegation-cert."$(printf "%03d" "$i")".json "byron.$(printf "%03d" "$i").cert.json"
534-
fi
535511
done
536-
# Remove if scope and first case when node release is > 10.1.4
537-
if [ "''${UNSTABLE:-}" != "true" ]; then
538-
rmdir ../byron-config/
539-
else
512+
540513
mv ../byron-gen-command/delegate-keys.000.key byron.000.key
541514
mv ../byron-gen-command/delegation-cert.000.json byron.000.cert.json
542515
rmdir ../byron-gen-command/
543-
fi
516+
popd &> /dev/null
517+
518+
pushd "$GENESIS_DIR/cc-keys" &> /dev/null
519+
for ((i=0; i < "$NUM_CC_KEYS"; i++)); do
520+
mv "cc$((i + 1))/cc.cold.skey" "cc-$((i + 1))-cold.skey"
521+
mv "cc$((i + 1))/cc.cold.vkey" "cc-$((i + 1))-cold.vkey"
522+
mv "cc$((i + 1))/cc.hot.skey" "cc-$((i + 1))-hot.skey"
523+
mv "cc$((i + 1))/cc.hot.vkey" "cc-$((i + 1))-hot.vkey"
524+
rmdir "cc$((i + 1))/"
525+
done
544526
popd &> /dev/null
545527
546528
# Transform the rich key into a create-cardano compatible layout
@@ -570,6 +552,7 @@ in {
570552
mkdir -p envs/"$ENV" rundir
571553
mv delegate-keys envs/"$ENV"/
572554
mv genesis-keys envs/"$ENV"/
555+
mv cc-keys envs/"$ENV"/
573556
mv utxo-keys envs/"$ENV"/
574557
mv node-config.json ./*-genesis.json topology.json rundir/
575558
popd &> /dev/null

0 commit comments

Comments
 (0)