Skip to content

Commit e72d2ed

Browse files
committed
chore: local-env wizard mode improvements (#580)
Added: - Entrypoint scripts will only start a node if they notice existing configuration. This allows to restart a node without reconfiguring network, as well as upgrading a node image.
1 parent 80ed268 commit e72d2ed

File tree

4 files changed

+100
-56
lines changed

4 files changed

+100
-56
lines changed

dev/local-environment/configurations/wizard/governance-authority/entrypoint.sh

+35-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
11
#!/bin/bash
22

3-
echo "Installing dependencies..."
3+
start_node() {
4+
echo "Starting the node..."
5+
export MC__FIRST_EPOCH_TIMESTAMP_MILLIS=$(cat /shared/MC__FIRST_EPOCH_TIMESTAMP_MILLIS)
6+
7+
/usr/local/bin/partner-chains-node \
8+
--validator \
9+
--chain=/shared/chain-spec.json \
10+
--node-key-file=/data/chains/partner_chains_template/network/secret_ed25519 \
11+
--base-path=/data \
12+
--keystore-path=/data/chains/partner_chains_template/keystore \
13+
--unsafe-rpc-external \
14+
--rpc-port=9933 \
15+
--rpc-cors=all \
16+
--prometheus-port=9615 \
17+
--prometheus-external \
18+
--state-pruning=archive \
19+
--blocks-pruning=archive &
20+
wait
21+
}
22+
23+
if [ -f "/shared/partner-chains-wizard-1.ready" ]; then
24+
echo "/shared/partner-chains-wizard-1.ready exists. Skipping configuration and starting the node..."
25+
start_node
26+
exit 0
27+
fi
28+
429

30+
echo "Installing dependencies..."
531
apt -qq update &> /dev/null
632
apt -qq -y install expect curl jq ncat &> /dev/null
7-
833
cp /usr/local/bin/partner-chains-node /partner-chains-node
934

10-
echo "Beginning configuration..."
11-
1235

36+
echo "Beginning configuration..."
1337
echo "Generating keys..."
1438
expect <<EOF
1539
spawn ./partner-chains-node wizards generate-keys
@@ -21,7 +45,6 @@ EOF
2145

2246

2347
echo "Waiting for the Cardano network to sync and for Ogmios to start..."
24-
2548
while true; do
2649
if nc -z ogmios $OGMIOS_PORT; then
2750
break
@@ -50,11 +73,11 @@ send "ogmios\r"
5073
expect "Ogmios port (1337)"
5174
send "\r"
5275
expect "path to the payment verification file (payment.vkey)"
53-
send "keys/funded_address.vkey\r"
76+
send "/keys/funded_address.vkey\r"
5477
expect "Select an UTXO to use as the genesis UTXO"
5578
send "\r"
5679
expect "path to the payment signing key file (payment.skey)"
57-
send "keys/funded_address.skey\r"
80+
send "/keys/funded_address.skey\r"
5881
expect "Do you want to configure a native token for you Partner Chain? (Y/n)"
5982
send "n\r"
6083
expect eof
@@ -63,7 +86,7 @@ EOF
6386

6487
echo "Waiting for permissioned candidate's keys to be generated..."
6588
while true; do
66-
if [ -f "/shared/partner-chains-wizard-2.ready" ]; then
89+
if [ -f "/shared/partner-chains-wizard-2-keys.ready" ]; then
6790
break
6891
else
6992
sleep 1
@@ -108,7 +131,6 @@ echo "Copying chain-spec.json file to /shared/chain-spec.json..."
108131
cp chain-spec.json /shared/chain-spec.json
109132
echo "chain-spec.json generation complete."
110133

111-
112134
echo "Copying pc-chain-config.json file to /shared/pc-chain-config.json..."
113135
cp pc-chain-config.json /shared/pc-chain-config.json
114136

@@ -129,28 +151,21 @@ expect "Ogmios hostname (ogmios)"
129151
send "\r"
130152
expect "Ogmios port (1337)"
131153
send "\r"
132-
expect "path to the payment signing key file (keys/funded_address.skey)"
154+
expect "path to the payment signing key file (/keys/funded_address.skey)"
133155
send "\r"
134156
expect "Do you want to set/update the D-parameter on the main chain? (y/N)"
135157
send "y\r"
136158
expect "Enter P, the number of permissioned candidates seats, as a non-negative integer. (0)"
137159
send "2\r"
138160
expect "Enter R, the number of registered candidates seats, as a non-negative integer. (0)"
139161
send "1\r"
140-
expect "path to the payment signing key file (keys/funded_address.skey)"
162+
expect "path to the payment signing key file (/keys/funded_address.skey)"
141163
send "\r"
142164
expect "Done. Main chain state is set."
143165
expect eof
144166
EOF
145167

146-
168+
touch /shared/partner-chains-wizard-1.ready
147169
echo "Partner Chain configuration is complete, and will be able to start after two mainchain epochs."
148170

149-
echo "Starting the node..."
150-
expect <<EOF
151-
spawn ./partner-chains-node wizards start-node
152-
expect "Proceed? (Y/n)"
153-
send "\r"
154-
set timeout -1
155-
expect eof
156-
EOF
171+
start_node

dev/local-environment/configurations/wizard/permissioned/entrypoint.sh

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
#!/bin/bash
22

33
echo "Installing dependencies..."
4-
54
apt -qq update &> /dev/null
65
apt -qq -y install expect jq &> /dev/null
6+
cp /usr/local/bin/partner-chains-node /data/partner-chains-node
7+
cd /data
78

8-
cp /usr/local/bin/partner-chains-node /partner-chains-node
99

10-
echo "Beginning configuration..."
10+
if [ -f "/shared/partner-chains-wizard-2.ready" ]; then
11+
echo "/shared/partner-chains-wizard-2.ready exists. Skipping configuration and starting the node..."
12+
expect <<EOF
13+
spawn ./partner-chains-node wizards start-node
14+
expect "Proceed? (Y/n)"
15+
send "Y\r"
16+
set timeout -1
17+
expect eof
18+
EOF
19+
exit 0
20+
fi
1121

1222

23+
echo "Beginning configuration..."
1324
echo "Generating keys..."
1425
expect <<EOF
1526
spawn ./partner-chains-node wizards generate-keys
1627
set timeout 60
1728
expect "node base path (./data)"
18-
send "\r"
29+
send ".\r"
1930
expect "All done!"
2031
expect eof
2132
EOF
2233

2334
cp partner-chains-public-keys.json /shared/partner-chains-public-keys.json
24-
touch /shared/partner-chains-wizard-2.ready
35+
touch /shared/partner-chains-wizard-2-keys.ready
2536

2637

2738
echo "Waiting for chain-spec.json and pc-chain-config.json to be ready..."
@@ -33,13 +44,15 @@ while true; do
3344
fi
3445
done
3546

36-
cp /shared/chain-spec.json .
37-
cp /shared/pc-chain-config.json .
38-
47+
cp /shared/chain-spec.json /data/chain-spec.json
48+
cp /shared/pc-chain-config.json /data/pc-chain-config.json
3949

4050
echo "Configuring Node P2P port..."
4151
jq '.node_p2p_port = 30334' pc-resources-config.json > tmp.json && mv tmp.json pc-resources-config.json
4252

53+
touch /shared/partner-chains-wizard-2.ready
54+
echo "Configuration complete."
55+
4356
echo "Starting the node..."
4457
expect <<EOF
4558
spawn ./partner-chains-node wizards start-node

dev/local-environment/configurations/wizard/registered/entrypoint.sh

+29-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
#!/bin/bash
22

33
echo "Installing dependencies..."
4-
54
apt -qq update &> /dev/null
65
apt -qq -y install expect jq &> /dev/null
6+
cp /usr/local/bin/partner-chains-node /data/partner-chains-node
7+
cd /data
78

8-
cp /usr/local/bin/partner-chains-node /partner-chains-node
99

10-
echo "Beginning configuration..."
10+
start_node() {
11+
echo "Starting the node..."
12+
expect <<EOF
13+
spawn ./partner-chains-node wizards start-node
14+
expect "Proceed? (Y/n)"
15+
send "Y\r"
16+
set timeout -1
17+
expect eof
18+
EOF
19+
}
20+
21+
22+
if [ -f "/shared/partner-chains-wizard-3.ready" ]; then
23+
echo "/shared/partner-chains-wizard-3.ready exists. Skipping configuration..."
24+
start_node
25+
exit 0
26+
fi
1127

1228

29+
echo "Beginning configuration..."
1330
echo "Generating keys..."
1431
expect <<EOF
1532
spawn ./partner-chains-node wizards generate-keys
1633
set timeout 60
1734
expect "node base path (./data)"
18-
send "\r"
35+
send ".\r"
1936
expect eof
2037
EOF
2138

@@ -29,8 +46,8 @@ while true; do
2946
fi
3047
done
3148

32-
cp /shared/chain-spec.json .
33-
cp /shared/pc-chain-config.json .
49+
cp /shared/chain-spec.json /data/chain-spec.json
50+
cp /shared/pc-chain-config.json /data/pc-chain-config.json
3451

3552

3653
echo "Registering candidate..."
@@ -44,7 +61,7 @@ send "ogmios\r"
4461
expect "Ogmios port (1337)"
4562
send "\r"
4663
expect "path to the payment verification file (payment.vkey)"
47-
send "keys/funded_address.vkey\r"
64+
send "/keys/funded_address.vkey\r"
4865
expect "Select UTXO to use for registration"
4966
send "\r"
5067
expect eof
@@ -61,7 +78,7 @@ register2_output=$(expect <<EOF
6178
spawn $register2_command
6279
set timeout 60
6380
expect "Path to mainchain signing key file (cold.skey)"
64-
send "keys/cold.skey\r"
81+
send "/keys/cold.skey\r"
6582
expect "/partner-chains-node wizards register3"
6683
expect eof
6784
catch wait result
@@ -77,7 +94,7 @@ expect <<EOF
7794
spawn $register3_command
7895
set timeout 300
7996
expect "path to the payment signing key file (payment.skey)"
80-
send "keys/funded_address.skey\r"
97+
send "/keys/funded_address.skey\r"
8198
expect "Ogmios protocol (http/https)"
8299
send "\r"
83100
expect "Ogmios hostname (ogmios)"
@@ -94,13 +111,7 @@ EOF
94111
echo "Configuring Node P2P port..."
95112
jq '.node_p2p_port = 30335' pc-resources-config.json > tmp.json && mv tmp.json pc-resources-config.json
96113

97-
echo "Starting the node..."
98-
expect <<EOF
99-
spawn ./partner-chains-node wizards start-node
100-
expect "Proceed? (Y/n)"
101-
send "Y\r"
102-
set timeout -1
103-
expect eof
104-
EOF
114+
touch /shared/partner-chains-wizard-3.ready
115+
echo "Registration complete."
105116

106-
# tail -f /dev/null
117+
start_node

dev/local-environment/modules/partner-chains-wizard.txt

+15-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
user: "0:0"
77
volumes:
88
- shared-volume:/shared
9+
- partner-chains-node-1-data:/data
910
- ./configurations/cardano/keys/funded_address.skey:/keys/funded_address.skey
1011
- ./configurations/cardano/keys/funded_address.vkey:/keys/funded_address.vkey
1112
- ./configurations/wizard/governance-authority/entrypoint.sh:/entrypoint.sh
1213
environment:
13-
- OGMIOS_PORT=${OGMIOS_PORT}
14-
- POSTGRES_PORT=${POSTGRES_PORT}
15-
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
14+
OGMIOS_PORT: ${OGMIOS_PORT}
15+
POSTGRES_PORT: ${POSTGRES_PORT}
16+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
17+
DB_SYNC_POSTGRES_CONNECTION_STRING: "postgres://postgres:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/cexplorer"
18+
SIDECHAIN_BLOCK_BENEFICIARY: "0000000000000000000000000000000000000000000000000000000000000001"
19+
CARDANO_SECURITY_PARAMETER: "5"
20+
CARDANO_ACTIVE_SLOTS_COEFF: "0.4"
21+
MC__FIRST_EPOCH_NUMBER: "0"
22+
MC__FIRST_SLOT_NUMBER: "0"
23+
MC__EPOCH_DURATION_MILLIS: "120000"
24+
BLOCK_STABILITY_MARGIN: "0"
1625
ports:
1726
- "30333:30333"
18-
- "9933:9944"
27+
- "9933:9933"
1928
entrypoint: ["/bin/bash", "/entrypoint.sh"]
2029

2130
partner-chains-wizard-2:
@@ -25,13 +34,11 @@
2534
user: "0:0"
2635
volumes:
2736
- shared-volume:/shared
37+
- partner-chains-node-2-data:/data
2838
- ./configurations/wizard/permissioned/entrypoint.sh:/entrypoint.sh
2939
environment:
3040
- POSTGRES_PORT=${POSTGRES_PORT}
3141
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
32-
ports:
33-
- "30334:30334"
34-
- "9934:9944"
3542
entrypoint: ["/bin/bash", "/entrypoint.sh"]
3643

3744
partner-chains-wizard-3:
@@ -41,6 +48,7 @@
4148
user: "0:0"
4249
volumes:
4350
- shared-volume:/shared
51+
- partner-chains-node-3-data:/data
4452
- ./configurations/cardano/keys/funded_address.skey:/keys/funded_address.skey
4553
- ./configurations/cardano/keys/funded_address.vkey:/keys/funded_address.vkey
4654
- ./configurations/cardano/keys/cold.skey:/keys/cold.skey
@@ -49,7 +57,4 @@
4957
environment:
5058
- POSTGRES_PORT=${POSTGRES_PORT}
5159
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
52-
ports:
53-
- "30335:30335"
54-
- "9935:9944"
5560
entrypoint: ["/bin/bash", "/entrypoint.sh"]

0 commit comments

Comments
 (0)