Skip to content

Commit b744de5

Browse files
fix: local-environment-dynamic support for 0 permissioned nodes
1 parent 319e5e0 commit b744de5

File tree

3 files changed

+62
-12
lines changed

3 files changed

+62
-12
lines changed

dev/local-environment-dynamic/configurations/cardano/entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,12 @@ if [ "$NUM_REGISTERED_NODES_TO_PROCESS" -gt 0 ]; then
843843
echo "[LOG] $NODE_LOG_NAME Pool ID: $POOL_ID"
844844

845845
# Pool parameters (minimal for local env)
846-
PLEDGE=0 # No pledge required for this setup
846+
PLEDGE=0 # No pledge required for local environment
847847
POOL_COST=0 # Minimal cost
848848
POOL_MARGIN="0/1000" # 0% margin
849849

850+
echo "[LOG] $NODE_LOG_NAME Pledge: $PLEDGE lovelace"
851+
850852
echo "[DEBUG] Attempting to run stake-pool registration-certificate command..."
851853

852854
if ! cardano-cli latest stake-pool registration-certificate \

dev/local-environment-dynamic/configurations/partner-chains-setup/entrypoint.sh

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,16 @@ echo "Generating chain-spec.json file for Partnerchain Nodes..."
302302

303303
echo "Configuring Initial Validators with SS58 Address ID..."
304304
echo "[" > initial_validators.json
305+
306+
# Add permissioned nodes as validators
307+
validator_count=0
305308
for ((i=1; i<=NUM_PERMISSIONED_NODES_TO_PROCESS; i++)); do
306309
node_name="permissioned-$i"
307310
validator_id=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/sidechain.json")
308311
aura_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/aura.json")
309312
grandpa_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/grandpa.json")
310313

311-
if [ $i -gt 1 ]; then
314+
if [ $validator_count -gt 0 ]; then
312315
echo "," >> initial_validators.json
313316
fi
314317

@@ -321,7 +324,28 @@ for ((i=1; i<=NUM_PERMISSIONED_NODES_TO_PROCESS; i++)); do
321324
}
322325
]
323326
EOF
327+
validator_count=$((validator_count + 1))
324328
done
329+
330+
# If no permissioned nodes, use registered-1 as initial validator
331+
if [ "$NUM_PERMISSIONED_NODES_TO_PROCESS" -eq 0 ] && [ "$NUM_REGISTERED_NODES_TO_PROCESS" -gt 0 ]; then
332+
node_name="registered-1"
333+
validator_id=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/sidechain.json")
334+
aura_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/aura.json")
335+
grandpa_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/grandpa.json")
336+
337+
cat <<EOF >> initial_validators.json
338+
[
339+
"$validator_id",
340+
{
341+
"aura": "$aura_ss58",
342+
"grandpa": "$grandpa_ss58"
343+
}
344+
]
345+
EOF
346+
validator_count=$((validator_count + 1))
347+
fi
348+
325349
echo "]" >> initial_validators.json
326350

327351
# Update chain-spec.json with initial validators
@@ -330,13 +354,16 @@ mv chain-spec.json.tmp chain-spec.json
330354

331355
echo "Configuring Initial Authorities with SS58 Public Key ID..."
332356
echo "[" > initial_authorities.json
357+
358+
# Add permissioned nodes as authorities
359+
authority_count=0
333360
for ((i=1; i<=NUM_PERMISSIONED_NODES_TO_PROCESS; i++)); do
334361
node_name="permissioned-$i"
335362
validator_id=$(jq -r '.ss58PublicKey' "/shared/node-keys/$node_name/keys/sidechain.json")
336363
aura_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/aura.json")
337364
grandpa_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/grandpa.json")
338365

339-
if [ $i -gt 1 ]; then
366+
if [ $authority_count -gt 0 ]; then
340367
echo "," >> initial_authorities.json
341368
fi
342369

@@ -351,7 +378,30 @@ for ((i=1; i<=NUM_PERMISSIONED_NODES_TO_PROCESS; i++)); do
351378
}
352379
}
353380
EOF
381+
authority_count=$((authority_count + 1))
354382
done
383+
384+
# If no permissioned nodes, use registered-1 as initial authority
385+
if [ "$NUM_PERMISSIONED_NODES_TO_PROCESS" -eq 0 ] && [ "$NUM_REGISTERED_NODES_TO_PROCESS" -gt 0 ]; then
386+
node_name="registered-1"
387+
validator_id=$(jq -r '.ss58PublicKey' "/shared/node-keys/$node_name/keys/sidechain.json")
388+
aura_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/aura.json")
389+
grandpa_ss58=$(jq -r '.ss58Address' "/shared/node-keys/$node_name/keys/grandpa.json")
390+
391+
cat <<EOF >> initial_authorities.json
392+
{
393+
"Permissioned": {
394+
"id": "$validator_id",
395+
"keys": {
396+
"aura": "$aura_ss58",
397+
"grandpa": "$grandpa_ss58"
398+
}
399+
}
400+
}
401+
EOF
402+
authority_count=$((authority_count + 1))
403+
fi
404+
355405
echo "]" >> initial_authorities.json
356406

357407
jq --slurpfile authorities initial_authorities.json '.genesis.runtimeGenesis.config.sessionCommitteeManagement.initialAuthorities = $authorities[0]' chain-spec.json > chain-spec.json.tmp

dev/local-environment-dynamic/setup.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

3-
NUM_DBSYNC_INSTANCES=3
4-
NUM_PERMISSIONED_NODES_TO_PROCESS=5
3+
NUM_DBSYNC_INSTANCES=1
4+
NUM_PERMISSIONED_NODES_TO_PROCESS=1
55
NUM_REGISTERED_NODES_TO_PROCESS=5
66

77
PARTNER_CHAINS_NODE_IMAGE="ghcr.io/input-output-hk/partner-chains/partner-chains-node-unstable:latest"
@@ -432,8 +432,9 @@ mkdir /data/keystore
432432
cp /shared/node-keys/$node_name/keystore/* /data/keystore/
433433
chmod -R 777 /data/keystore
434434
435-
NODE_KEY=\$(openssl rand -hex 32)
436-
PEER_ID=\$(echo "\$NODE_KEY" | /usr/local/bin/partner-chains-node key inspect-node-key)
435+
# Use fixed node key for registered-1 when it's the bootnode
436+
NODE_KEY='b0c7b085c8df4d8f0add881a39d90a0f29edd265dba1b9c2db5564f8e1b1a02a'
437+
PEER_ID='12D3KooWD7ou3cgmVbMttbAXNvXPwna8LkRUko849YE8oWv5NGZP'
437438
438439
export MC__FIRST_EPOCH_TIMESTAMP_MILLIS=\$(cat /shared/MC__FIRST_EPOCH_TIMESTAMP_MILLIS)
439440
@@ -466,11 +467,8 @@ EOF
466467
if [ "$NUM_PERMISSIONED_NODES_TO_PROCESS" -gt 0 ]; then
467468
bootnode_address="/dns/partner-chains-node-permissioned-1/tcp/30333/p2p/12D3KooWD7ou3cgmVbMttbAXNvXPwna8LkRUko849YE8oWv5NGZP"
468469
else
469-
# This assumes registered-1 is the bootnode
470-
# Note: This part of the script doesn't know the peer ID of registered-1 ahead of time.
471-
# This is a limitation. For a dynamic setup, a more robust discovery mechanism would be needed.
472-
# For now, we'll point to its service name and hope for the best.
473-
bootnode_address="/dns/partner-chains-node-registered-1/tcp/30333"
470+
# registered-1 is the bootnode with fixed peer ID
471+
bootnode_address="/dns/partner-chains-node-registered-1/tcp/30333/p2p/12D3KooWD7ou3cgmVbMttbAXNvXPwna8LkRUko849YE8oWv5NGZP"
474472
fi
475473
cat > configurations/partner-chains-nodes/$node_name/entrypoint.sh <<EOF
476474
#!/bin/sh

0 commit comments

Comments
 (0)