Skip to content

Commit a9acea3

Browse files
authored
Merge pull request #250 from andkononykhin/issue-238-ceremony-verification
[issue 238] deployment script fixes
2 parents 9d12ffb + 3ff7022 commit a9acea3

File tree

7 files changed

+89
-55
lines changed

7 files changed

+89
-55
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ LICENSED_FILES = $(shell find . -type f -not -path '*/.*' -not -name '*.md' -not
9090

9191
MK_TEST = "Makefile.test"
9292
LOCALNET_TARGETS = image localnet_init localnet_start localnet_stop localnet_clean localnet_export localnet_reset localnet_rebuild
93-
TEST_DEPLOY_TARGETS = test_deploy_image test_deploy_env_build test_deploy_env_clean
93+
TEST_DEPLOY_TARGETS = test_deploy_image test_deploy_env_build make test_deploy_genesis_env_build test_deploy_env_clean
9494
TEST_TARGETS= ${LOCALNET_TARGETS} ${TEST_DEPLOY_TARGETS}
9595

9696
all: install

Makefile.test

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ clean_network = $(call remove_containers,$(call localnet_containers))
2020

2121
# test deploy vars
2222
TEST_DEPLOY_IMAGE_NAME = "dcledger_deploy"
23-
TEST_DEPLOY_NODE = "test_deploy_node"
23+
TEST_DEPLOY_GVN = "test_deploy_gvn"
24+
TEST_DEPLOY_VN = "test_deploy_vn"
25+
TEST_DEPLOY_ON = "test_deploy_on"
2426

2527
image:
2628
docker build -t ${IMAGE_NAME} --build-arg TEST_UID=${UID} \
@@ -69,11 +71,18 @@ test_deploy_image: integration_tests/deploy/Dockerfile
6971
cat $< | docker build -t ${TEST_DEPLOY_IMAGE_NAME} -
7072

7173
test_deploy_env_build: image test_deploy_image
72-
docker run -d --name ${TEST_DEPLOY_NODE} --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \
74+
docker run -d --name ${TEST_DEPLOY_VN} --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \
7375
-v /sys/fs/cgroup:/sys/fs/cgroup:ro --network ${LOCALNET_DOCKER_NETWORK} ${TEST_DEPLOY_IMAGE_NAME}
7476

77+
test_deploy_genesis_env_build: image test_deploy_image
78+
docker run -d --name ${TEST_DEPLOY_GVN} --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \
79+
-v /sys/fs/cgroup:/sys/fs/cgroup:ro ${TEST_DEPLOY_IMAGE_NAME}
80+
docker run -d --name ${TEST_DEPLOY_VN} --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \
81+
-v /sys/fs/cgroup:/sys/fs/cgroup:ro ${TEST_DEPLOY_IMAGE_NAME}
82+
83+
7584
test_deploy_env_clean:
76-
docker rm -f ${TEST_DEPLOY_NODE}
85+
docker rm -f ${TEST_DEPLOY_GVN} ${TEST_DEPLOY_VN} ${TEST_DEPLOY_ON}
7786

7887
.PHONY: localnet_init localnet_start localnet_stop localnet_clean localnet_export \
7988
localnet_reset localnet_rebuild \

deployment/persistent_chains/testnet-2.0/testnet-2.0-launch.md

+30-28
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following steps are expected to be done **before** the ceremony.
4747
$ sudo cp -f ./dcld -t /usr/bin
4848
$ sudo chown "<dcl-user>" /usr/bin/dcld
4949
$ sudo chmod u+x /usr/bin/dcld
50+
5051
# verification
5152
$ dcld version
5253
```
@@ -77,7 +78,8 @@ The following steps are expected to be done **before** the ceremony.
7778

7879
3.1. Share VN's IP address
7980
80-
3.2. Share VN's `id` (`id` field in `dcld status` command output)
81+
3.2. Share VN's `id` (`node_id` field in `dcld init` command output
82+
or `id` field in `dcld status` command output in case node is running)
8183

8284
4. **Generate NodeAdmin keys**
8385

@@ -93,9 +95,9 @@ The following steps are expected to be done **before** the ceremony.
9395

9496
4.3. Share generated `address` and `pubkey` (in Slack or in a special doc).
9597

96-
`address` and `pubkey` can be found in the `dcld keys show "<key-name>"` output.
98+
`address` and `pubkey` can be found in the `dcld keys show --output text "<key-name>"` output.
9799

98-
5. **\[Optional] Generate Trustee keys**
100+
5. **[Optional] Generate Trustee keys**
99101

100102
5.1. Choose a machine where Trustee keys will be hold (it can be either VN Node, or a separate machine with `dcld` binary)
101103

@@ -109,13 +111,13 @@ The following steps are expected to be done **before** the ceremony.
109111

110112
5.3. Share generated `address` and `pubkey` (in Slack or in a special doc).
111113

112-
`address` and `pubkey` can be found in the `dcld keys show "<key-name>"` output.
114+
`address` and `pubkey` can be found in the `dcld keys show --output text "<key-name>"` output.
113115

114-
6. **\[Optional] Configure ON Nodes**
116+
6. **[Optional] Configure ON Nodes**
115117

116118
Do steps 1.1 - 1.7 for all ON Nodes.
117119

118-
7. \[CSA Only] Create `persistent_peers.txt` file containing `<node1-ID>@<node1-IP>:26656,...` for all VNs. Share in Slack/doc.
120+
7. [CSA Only] Create `persistent_peers.txt` file containing `<node1-ID>@<node1-IP>:26656,...` for all VNs. Share in Slack/doc.
119121

120122
## II. Ceremony: Genesis Node (CSA Only)
121123

@@ -132,14 +134,14 @@ The following steps are expected to be done **during** the ceremony.
132134
# fetch the helper script
133135
curl -L -O https://raw.githubusercontent.com/zigbee-alliance/distributed-compliance-ledger/master/deployment/scripts/test_peers_conn
134136
135-
# run, by default it expectes persistent_peers.txt in the current directory
137+
# run, by default it expects persistent_peers.txt in the current directory
136138
./test_peers_conn
137139
```
138140

139141
8.3. Run genesis VN
140142

141143
```bash
142-
./run_dcl_node -t genesis -c testnet-2.0 --gen-key-name "<node-admin-key>" [--gen-key-name-trustee "<trustee-key>"] node0
144+
./run_dcl_node -t genesis -c testnet-2.0 --gen-key-name "<node-admin-key>" [--gen-key-name-trustee "<trustee-key>"] "<node-name>"
143145
```
144146

145147
8.4. Put genesis file to GitHub (`zigbee-alliance/distributed-compliance-ledger/master/deployment/persistent_chains/testnet-2.0/genesis.json`)
@@ -153,16 +155,30 @@ The following steps are expected to be done **during** the ceremony.
153155
9.1. A Trustee proposes a NodeAdmin account
154156

155157
```bash
156-
dcld tx auth propose-add-account --address="<bench32 encoded string>" --pubkey="<protobuf JSON encoded>" --roles=NodeAdmin --from="<account-name>"
158+
dcld tx auth propose-add-account --address='<bench32 encoded string>' --pubkey='<protobuf JSON encoded>' --roles=NodeAdmin --from='<account-name>'
157159
```
158160

159161
9.2. Trustees approve the NodeAdmin account
160162

161163
```bash
162-
dcld tx auth approve-add-account --address="<bench32 encoded string>" --from="<account-name>"
164+
dcld tx auth approve-add-account --address='<bench32 encoded string>' --from='<account-name>'
165+
```
166+
167+
10. **[Optional] Add Trustee account**
168+
169+
12.1. A Trustee proposes Trustee account
170+
171+
```bash
172+
dcld tx auth propose-add-account --address='<bench32 encoded string>' --pubkey='<protobuf JSON encoded>' --roles=Trustee --from='<account-name>'
173+
```
174+
175+
12.2. Trustees approve Trustee account
176+
177+
```bash
178+
dcld tx auth approve-add-account --address='<bench32 encoded string>' --from='<account-name>'
163179
```
164180

165-
10. **Run VN node**
181+
11. **Run VN node**
166182

167183
10.1. Download genesis
168184

@@ -179,7 +195,7 @@ The following steps are expected to be done **during** the ceremony.
179195
# fetch the helper script
180196
curl -L -O https://raw.githubusercontent.com/zigbee-alliance/distributed-compliance-ledger/master/deployment/scripts/test_peers_conn
181197
182-
# run, by default it expectes persistent_peers.txt in the current directory
198+
# run, by default it expects persistent_peers.txt in the current directory
183199
./test_peers_conn
184200
```
185201

@@ -199,7 +215,7 @@ The following steps are expected to be done **during** the ceremony.
199215

200216
(once transaction is successfully written you should see `"code": 0` in the JSON output.)
201217

202-
11. **VN Deployment Verification**
218+
12. **VN Deployment Verification**
203219

204220
11.1. Check the account presence on the ledger: `dcld query auth account --address="<address>"`.
205221

@@ -209,20 +225,6 @@ The following steps are expected to be done **during** the ceremony.
209225

210226
11.4. Make sure the VN participates in consensus: `dcld query tendermint-validator-set` must contain the VN's address.
211227
212-
12. **\[Optional] Add Trustee account**
213-
214-
12.1. A Trustee proposes Trustee account
215-
216-
```bash
217-
dcld tx auth propose-add-account --address="<bench32 encoded string>" --pubkey="<protobuf JSON encoded>" --roles=Trustee --from="<account-name>"
218-
```
219-
220-
12.2. Trustees approve Trustee account
221-
222-
```bash
223-
dcld tx auth approve-add-account --address="<bench32 encoded string>" --from="<account-name>"
224-
```
225-
226228
## IV. Post-Ceremony: For every Observer Node
227229
228230
The following steps can be done **after** the ceremony.
@@ -278,7 +280,7 @@ The following steps can be done **after** the ceremony.
278280
```
279281
* Useful commands
280282
* keys:
281-
* `dcld keys show "<name>"`: to get address and pubkey for a keyname
283+
* `dcld keys show --output text "<name>"`: to get address and pubkey for a keyname
282284
* node status:
283285
* `systemctl status dcld`: to get the node service status.
284286
* `journalctl -u dcld.service -f`: to see node logs.

deployment/scripts/run_dcl_node

+21-18
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ PEER=
6161

6262
NODE_TYPE="$DEF_NODE_TYPE"
6363
CHAIN_ID="$DEF_CHAIN_ID"
64-
NODE_USER="${USER:-$DEF_NODE_USER}"
64+
65+
CURR_USER="${USER:-$(whoami 2>/dev/null)}"
66+
67+
NODE_USER="${CURR_USER:-$DEF_NODE_USER}"
6568

6669

6770
function usage {
@@ -252,7 +255,7 @@ function node_init {
252255
rm -rf "$DCL_HOME/config/gentx"
253256
rm -f "$GENESIS_FILE"
254257

255-
# dcld init "$_name" --chain-id "$_chain_id"
258+
dcld init "$_name" --chain-id "$_chain_id"
256259
}
257260

258261

@@ -266,11 +269,11 @@ function build_genesis {
266269
local _acc_address_tr="${4:-}"
267270
local _acc_pubkey_tr="${5:-}"
268271

269-
dcld add-genesis-account --address="$_acc_address" --pubkey="$_acc_pubkey" --roles="NodeAdmin"
272+
dcld add-genesis-account --address "$_acc_address" --pubkey "$_acc_pubkey" --roles "NodeAdmin"
270273
if [[ -n "$_acc_address_tr" && -n "$_acc_pubkey_tr" ]]; then
271-
dcld add-genesis-account --address="$_acc_address_tr" --pubkey="$_acc_pubkey_tr" --roles="Trustee"
274+
dcld add-genesis-account --address "$_acc_address_tr" --pubkey "$_acc_pubkey_tr" --roles "Trustee"
272275
fi
273-
dcld gentx --from "$_key_name_admin"
276+
dcld gentx --chain-id "$CHAIN_ID" "$_key_name_admin"
274277
dcld collect-gentxs
275278
dcld validate-genesis
276279
}
@@ -402,8 +405,8 @@ function add_account {
402405
local _acc_roles="$3"
403406
local _from="$4"
404407

405-
dcld tx auth propose-add-account --address="$_acc_address" --pubkey="$_acc_pubkey" \
406-
--roles="$_acc_roles" --from="$_from"
408+
dcld tx auth propose-add-account --address "$_acc_address" --pubkey "$_acc_pubkey" \
409+
--roles "$_acc_roles" --from "$_from"
407410

408411
echo "Account added"
409412
echo "To approve run: dcld tx auth approve-add-account --address=<string> --from=<account>"
@@ -417,7 +420,7 @@ function approve_account {
417420
local _acc_address="$1"
418421
local _from="$2"
419422

420-
dcld tx auth approve-add-account --address="$_acc_address" --from="$_from"
423+
dcld tx auth approve-add-account --address "$_acc_address" --from "$_from"
421424

422425
echo "Account approved by $_from"
423426
}
@@ -451,19 +454,19 @@ config_cli "$CHAIN_ID"
451454
ACC_ADDR="<acc-addr>"
452455
ACC_PUBKEY="<acc-pubkey>"
453456
if [[ -n "$KEY_NAME" ]]; then
454-
KEY_INFO="$(dcld keys show "${KEY_NAME}")"
455-
ACC_ADDR="$(_jq "$KEY_INFO" | grep address | awk -F'"' '{print $4}')"
456-
ACC_PUBKEY="$(_jq "$KEY_INFO" | grep pubkey | awk -F'"' '{print $4}')"
457+
KEY_INFO="$(dcld keys show --output text "${KEY_NAME}")"
458+
ACC_ADDR="$(grep address <<<"$KEY_INFO" | awk '{print $NF}')"
459+
ACC_PUBKEY="$(grep pubkey <<<"$KEY_INFO" | awk '{print $NF}' | sed -e "s/^'//" -e "s/'$//")"
457460
fi
458461

459462
if [[ -n "$KEY_NAME_GEN_TRUSTEE" ]]; then
460-
KEY_INFO="$(dcld keys show "${KEY_NAME_GEN_TRUSTEE}")"
461-
ACC_ADDR_TR="$(_jq "$KEY_INFO" | grep address | awk -F'"' '{print $4}')"
462-
ACC_PUBKEY_TR="$(_jq "$KEY_INFO" | grep pubkey | awk -F'"' '{print $4}')"
463+
KEY_INFO="$(dcld keys show --output text "${KEY_NAME_GEN_TRUSTEE}")"
464+
ACC_ADDR_TR="$(grep address <<<"$KEY_INFO" | awk '{print $NF}')"
465+
ACC_PUBKEY_TR="$(grep pubkey <<<"$KEY_INFO" | awk '{print $NF}' | sed -e "s/^'//" -e "s/'$//")"
463466
fi
464467

465-
echo "Initializing the node"
466-
node_init "$NODE_NAME" "$CHAIN_ID"
468+
#echo "Initializing the node"
469+
#node_init "$NODE_NAME" "$CHAIN_ID"
467470

468471

469472
if [[ "$NODE_TYPE" == "$NT_GENESIS" ]]; then
@@ -486,7 +489,7 @@ VAL_ID="unknown"
486489
wait_node_up
487490

488491
STATUS="$(dcld status)"
489-
VAL_ID="$(_jq "$STATUS"| grep '"id"' | awk -F'"' '{print $4}')"
492+
VAL_ID="$(_jq "$STATUS"| grep '"id"' | awk '{print $NF}' | sed -e 's/^"//' -e 's/[",]\+$//')"
490493
VAL_ADDR="$(dcld tendermint show-address)"
491494
VAL_PUBKEY="$(dcld tendermint show-validator)"
492495

@@ -511,7 +514,7 @@ elif [[ "$NODE_TYPE" == "$NT_VALIDATOR" ]]; then
511514

512515
echo -e "\nNext steps:"
513516
echo -e "\n\t1. If you have an approved NodeAdmin account please run the following command to make the node a validator:"
514-
echo -e "\t\t'dcld tx validator add-node --pubkey='$VAL_PUBKEY' --moniker=$NODE_NAME --from=$KEY_NAME'"
517+
echo -e "\t\tdcld tx validator add-node --pubkey '$VAL_PUBKEY' --moniker '$NODE_NAME' --from '$KEY_NAME'"
515518
echo -e "\n\t2. Explore the node external IP and provide it along with validator ID '$VAL_ID'"
516519
echo -e "\t\t to DCLedger '$CHAIN_ID' network validator administrators"
517520

deployment/scripts/test_peers_conn

+20-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ set -o pipefail
1919
TIMEOUT_DEF=3
2020
PERSISTENT_PEERS_FILE="${1:-./persistent_peers.txt}"
2121

22-
TIMEOUT="${TIMEOUT:-TIMEOUT_DEF}"
22+
TIMEOUT="${TIMEOUT:-$TIMEOUT_DEF}"
2323

2424
PASSED_RES=PASSED
25+
SKIPPED_RES=SKIPPED
2526
FAILED_RES=FAILED
26-
final_res=true
2727
NETCAT=""
28+
IP_TOOL=ip
29+
SELF_IPS=""
2830
CHECK_TOOL=""
2931

32+
final_res=true
33+
3034
function usage {
3135
echo "\
3236
Usage: $0 [persistent-peers-file]
@@ -63,6 +67,13 @@ function test_env {
6367
exit 1
6468
fi
6569
fi
70+
71+
if [[ -n "$(which "$IP_TOOL")" ]]; then
72+
# TODO may fail for specific cases
73+
SELF_IPS="$(ip -br -f inet a | grep -v 127.0.0.1 | awk '{print $NF}' | paste -s)"
74+
else
75+
echo "WARNING: 'ip' tool is not found, skipping self IP filtering"
76+
fi
6677
}
6778

6879
function telnet_check {
@@ -115,7 +126,13 @@ IFS=',' read -a peers <<< "$(cat "$PERSISTENT_PEERS_FILE")"
115126
for peer in "${peers[@]}"
116127
do
117128
IFS=':' read -a _arr <<< "$(echo "$peer" | cut -d @ -f 2)"
118-
res="$(check "${_arr[0]}" "${_arr[1]}")"
129+
130+
if [[ "$SELF_IPS" == *"${_arr[0]}/"* ]]; then
131+
res="$SKIPPED_RES"
132+
else
133+
res="$(check "${_arr[0]}" "${_arr[1]}")"
134+
fi
135+
119136
echo "Connection to peer '${_arr[0]}:${_arr[1]}' $res"
120137

121138
if [[ "$res" == "$FAILED_RES" ]]; then

integration_tests/deploy/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ FROM jrei/systemd-ubuntu:20.04
1616

1717
RUN apt-get update && apt-get install -y \
1818
sudo \
19+
curl \
20+
netcat \
21+
iproute2 \
1922
&& rm -rf /var/lib/apt/lists/*
2023

2124
# test user

integration_tests/deploy/test_deploy.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ source integration_tests/cli/common.sh
2222
DCL_USER="dcl"
2323
DCL_USER_HOME="/var/lib/dcl"
2424
DCL_DIR="$DCL_USER_HOME/.dcl"
25-
TEST_NODE="test_deploy_node"
25+
TEST_NODE="test_deploy_vn"
2626

2727
random_string account
2828

@@ -56,7 +56,7 @@ docker exec -u "$DCL_USER" "$TEST_NODE" /bin/sh -c "
5656

5757
echo "Configure and start new node"
5858
docker exec -u "$DCL_USER" "$TEST_NODE" dcld init $TEST_NODE --chain-id $chain_id
59-
docker exec -u "$DCL_USER" "$TEST_NODE" ./run_dcl_node -u $DCL_USER -c $chain_id $TEST_NODE
59+
docker exec -u "$DCL_USER" "$TEST_NODE" ./run_dcl_node -c $chain_id $TEST_NODE
6060
docker exec "$TEST_NODE" systemctl status dcld
6161
vaddress=$(docker exec -u "$DCL_USER" "$TEST_NODE" dcld tendermint show-address)
6262
vpubkey=$(docker exec -u "$DCL_USER" "$TEST_NODE" dcld tendermint show-validator)

0 commit comments

Comments
 (0)