223223 runtimeInputs = stdPkgs ;
224224 text = ''
225225 # Inputs:
226+ # [$CC_DIR]
227+ # [$CC_EPOCH]
226228 # [$DEBUG]
227229 # [$ENV]
228230 # [$ERA_CMD]
@@ -242,9 +244,12 @@ in {
242244 export START_TIME='' ${START_TIME:-$(date --utc +"%Y-%m-%dT%H:%M:%SZ" --date " now +30 min")}
243245 export SLOT_LENGTH='' ${SLOT_LENGTH:-1000}
244246 export SECURITY_PARAM='' ${SECURITY_PARAM:-36}
247+ export NUM_CC_KEYS='' ${NUM_CC_KEYS:-1}
245248 export NUM_GENESIS_KEYS='' ${NUM_GENESIS_KEYS:-3}
246249 export TESTNET_MAGIC='' ${TESTNET_MAGIC:-42}
247250 export GENESIS_DIR='' ${GENESIS_DIR:-"./workbench/custom"}
251+ export CC_DIR='' ${CC_DIR:-"./workbench/custom/envs/custom/cc-keys"}
252+ export CC_EPOCH='' ${CC_EPOCH:-1000000}
248253
249254 if [ "'' ${UNSTABLE_LIB:-}" = "true" ]; then
250255 export TEMPLATE_DIR='' ${TEMPLATE_DIR:-"${ localFlake . inputs . iohk-nix-ng } /cardano-lib/testnet-template"}
@@ -303,11 +308,41 @@ in {
303308 > "$GENESIS_DIR/utxo-keys/rich-utxo.addr"
304309 chmod 0600 "$GENESIS_DIR/utxo-keys/rich-utxo.addr"
305310
311+ JSON_UPDATES=$( (for i in $(seq 1 "$NUM_CC_KEYS"); do
312+ echo "{\"keyHash-$(cardano-cli latest governance committee key-hash --verification-key-file "$CC_DIR/cc-$i-cold.vkey")\": $CC_EPOCH}"
313+ done) | jq -s add)
314+
315+ jq --sort-keys \
316+ --argjson jsonUpdates "$JSON_UPDATES" \
317+ '.committee.members = $jsonUpdates' \
318+ < "$GENESIS_DIR/conway-genesis.json" \
319+ | sponge "$GENESIS_DIR/conway-genesis.json"
320+
306321 # Remove once the cardano-node new tracing is default in nixosModules.
307322 jq '. += {UseTraceDispatcher: false}' \
308323 < "$GENESIS_DIR/node-config.json" \
309324 | sponge "$GENESIS_DIR/node-config.json"
310325
326+ # Calculate genesis hashes and inject them into the node config file
327+ HASH_BYRON=$("'' ${CARDANO_CLI_NO_ERA[@]}" byron genesis print-genesis-hash --genesis-json "$GENESIS_DIR/byron-genesis.json")
328+ HASH_SHELLEY=$("'' ${CARDANO_CLI_NO_ERA[@]}" legacy genesis hash --genesis "$GENESIS_DIR/shelley-genesis.json")
329+ HASH_ALONZO=$("'' ${CARDANO_CLI_NO_ERA[@]}" legacy genesis hash --genesis "$GENESIS_DIR/alonzo-genesis.json")
330+ HASH_CONWAY=$("'' ${CARDANO_CLI_NO_ERA[@]}" legacy genesis hash --genesis "$GENESIS_DIR/conway-genesis.json")
331+ jq --sort-keys \
332+ --arg hashByron "$HASH_BYRON" \
333+ --arg hashShelley "$HASH_SHELLEY" \
334+ --arg hashAlonzo "$HASH_ALONZO" \
335+ --arg hashConway "$HASH_CONWAY" \
336+ '. += {
337+ ByronGenesisHash: $hashByron,
338+ ShelleyGenesisHash: $hashShelley,
339+ AlonzoGenesisHash: $hashAlonzo,
340+ ConwayGenesisHash: $hashConway,
341+ UseTraceDispatcher: false
342+ }' \
343+ < "$GENESIS_DIR/node-config.json" \
344+ | sponge "$GENESIS_DIR/node-config.json"
345+
311346 # Shape the genesis output directory to match secrets layout expected
312347 # by cardano-parts for environments and groups. This makes for easier
313348 # import of new environment secrets.
0 commit comments