-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathentrypoint.sh
171 lines (143 loc) · 5.29 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
start_node() {
echo "Starting the node..."
export MC__FIRST_EPOCH_TIMESTAMP_MILLIS=$(cat /shared/MC__FIRST_EPOCH_TIMESTAMP_MILLIS)
/usr/local/bin/partner-chains-node \
--validator \
--chain=/shared/chain-spec.json \
--node-key-file=/data/chains/partner_chains_template/network/secret_ed25519 \
--base-path=/data \
--keystore-path=/data/chains/partner_chains_template/keystore \
--unsafe-rpc-external \
--rpc-port=9933 \
--rpc-cors=all \
--prometheus-port=9615 \
--prometheus-external \
--state-pruning=archive \
--blocks-pruning=archive &
wait
}
if [ -f "/shared/partner-chains-wizard-1.ready" ]; then
echo "/shared/partner-chains-wizard-1.ready exists. Skipping configuration and starting the node..."
start_node
exit 0
fi
echo "Installing dependencies..."
apt -qq update &> /dev/null
apt -qq -y install expect curl jq ncat &> /dev/null
cp /usr/local/bin/partner-chains-node /partner-chains-node
echo "Beginning configuration..."
echo "Generating keys..."
expect <<EOF
spawn ./partner-chains-node wizards generate-keys
set timeout 60
expect "node base path (./data)"
send "\r"
expect eof
EOF
echo "Waiting for the Cardano network to sync and for Ogmios to start..."
while true; do
if nc -z ogmios $OGMIOS_PORT; then
break
else
sleep 1
fi
done
echo "Preparing configuration..."
expect <<EOF
spawn ./partner-chains-node wizards prepare-configuration
set timeout 180
expect "node base path (./data)"
send "\r"
expect "Your bootnode should be accessible via:"
send "\r"
expect "Enter bootnode TCP port (3033)"
send "30333\r"
expect "Enter bootnode hostname (localhost)"
send "partner-chains-wizard-1\r"
expect "Ogmios protocol (http/https)"
send "\r"
expect "Ogmios hostname (localhost)"
send "ogmios\r"
expect "Ogmios port (1337)"
send "\r"
expect "path to the payment verification file (payment.vkey)"
send "/keys/funded_address.vkey\r"
expect "Select an UTXO to use as the genesis UTXO"
send "\r"
expect "path to the payment signing key file (payment.skey)"
send "/keys/funded_address.skey\r"
expect "Do you want to configure a native token for you Partner Chain? (Y/n)"
send "n\r"
expect eof
EOF
echo "Waiting for permissioned candidate's keys to be generated..."
while true; do
if [ -f "/shared/partner-chains-wizard-2-keys.ready" ]; then
break
else
sleep 1
fi
done
echo "Inserting permissioned candidates' keys into configuration..."
governance_authority_public_keys=$(cat partner-chains-public-keys.json)
permissioned_candidate_public_keys=$(cat /shared/partner-chains-public-keys.json)
jq '.initial_permissioned_candidates = [
'"$governance_authority_public_keys"',
'"$permissioned_candidate_public_keys"'
]' pc-chain-config.json > tmp.json && mv tmp.json pc-chain-config.json
echo "Creating chain spec..."
expect <<EOF
spawn ./partner-chains-node wizards create-chain-spec
expect "Do you want to continue? (Y/n)"
send "\r"
expect eof
EOF
echo "Set initial funds to Alice (ecdsa), ?, and Alice (sr25519)"
jq '.genesis.runtimeGenesis.config.balances.balances = [
["5C7C2Z5sWbytvHpuLTvzKunnnRwQxft1jiqrLD5rhucQ5S9X", 1000000000000000],
["5D9eDKbFt4JKaEndQvMmbJYnpX9ENUj8U9UUg1AxSa64FJxE", 1000000000000000],
["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", 1000000000000000]
]' chain-spec.json > tmp.json && mv tmp.json chain-spec.json
echo "Configuring Alice as sudo..."
jq '.genesis.runtimeGenesis.config.sudo = {
"key": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
}' chain-spec.json > tmp.json && mv tmp.json chain-spec.json
echo "Configuring Epoch Length..."
jq '.genesis.runtimeGenesis.config.sidechain.slotsPerEpoch = 5' chain-spec.json > tmp.json && mv tmp.json chain-spec.json
echo "Copying chain-spec.json file to /shared/chain-spec.json..."
cp chain-spec.json /shared/chain-spec.json
echo "chain-spec.json generation complete."
echo "Copying pc-chain-config.json file to /shared/pc-chain-config.json..."
cp pc-chain-config.json /shared/pc-chain-config.json
touch /shared/chain-spec.ready
echo "Setting up main chain state..."
expect <<EOF
spawn ./partner-chains-node wizards setup-main-chain-state
set timeout 300
expect "DB-Sync Postgres connection string (postgresql://postgres-user:postgres-password@localhost:5432/cexplorer)"
send "postgresql://postgres:$POSTGRES_PASSWORD@postgres:$POSTGRES_PORT/cexplorer\r"
expect "Do you want to set/update the permissioned candidates on the main chain with values from configuration file? (y/N)"
send "y\r"
expect "Ogmios protocol (http/https)"
send "\r"
expect "Ogmios hostname (ogmios)"
send "\r"
expect "Ogmios port (1337)"
send "\r"
expect "path to the payment signing key file (/keys/funded_address.skey)"
send "\r"
expect "Do you want to set/update the D-parameter on the main chain? (y/N)"
send "y\r"
expect "Enter P, the number of permissioned candidates seats, as a non-negative integer. (0)"
send "2\r"
expect "Enter R, the number of registered candidates seats, as a non-negative integer. (0)"
send "1\r"
expect "path to the payment signing key file (/keys/funded_address.skey)"
send "\r"
expect "Done. Main chain state is set."
expect eof
EOF
touch /shared/partner-chains-wizard-1.ready
echo "Partner Chain configuration is complete, and will be able to start after two mainchain epochs."
start_node