From 246ede3e0ffcb65d21359360d982d8c03d52cd1b Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 21 Dec 2019 13:34:09 -0800 Subject: [PATCH 1/4] [node] option to specify the pub port Signed-off-by: Leo Chen --- scripts/node.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/node.sh b/scripts/node.sh index 3be23be3e..1777886bd 100755 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version="v1 20191105.1" +version="v1 20191221.0" unset -v progname progname="${0##*/}" @@ -94,7 +94,9 @@ function setup_env print_usage() { cat <<- ENDEND -usage: ${progname} [-1ch] [-k KEYFILE] +usage: ${progname} [options] + +options: -c back up database/logs and start clean (use only when directed by Harmony) -1 do not loop; run once and exit @@ -107,6 +109,7 @@ usage: ${progname} [-1ch] [-k KEYFILE] -D do not download Harmony binaries (default: download when start) -m collect and upload node metrics to harmony prometheus + grafana -N network join the given network (mainnet, testnet, devnet; default: mainnet) + -n port specify the public base port of the node (default: 9000) -t equivalent to -N testnet (deprecated) -T nodetype specify the node type (validator, explorer; default: validator) -i shardid specify the shard id (valid only with explorer node; default: 1) @@ -137,6 +140,9 @@ examples: # upgrade harmony binaries from specified repo ${progname} -1 -U upgrade +# start the node in a different port 9010 + ${progname} -n 9010 + ENDEND } @@ -151,7 +157,7 @@ BUCKET=pub.harmony.one OS=$(uname -s) unset start_clean loop run_as_root blspass do_not_download download_only metrics network node_type shard_id download_harmony_db db_file_to_dl -unset upgrade_rel public_rpc staking_mode +unset upgrade_rel public_rpc staking_mode pub_port start_clean=false loop=true run_as_root=true @@ -168,7 +174,7 @@ ${BLSKEYFILE=} unset OPTIND OPTARG opt OPTIND=1 -while getopts :1chk:sSp:dDmN:tT:i:ba:U:PvVyz opt +while getopts :1chk:sSp:dDmN:tT:i:ba:U:PvVyzn: opt do case "${opt}" in '?') usage "unrecognized option -${OPTARG}";; @@ -185,6 +191,7 @@ do D) do_not_download=true;; m) metrics=true;; N) network="${OPTARG}";; + n) pub_port="${OPTARG}";; t) network=devnet;; T) node_type="${OPTARG}";; i) shard_id="${OPTARG}";; @@ -483,7 +490,7 @@ else download_binaries . || err 69 "initial node software update failed" fi -NODE_PORT=9000 +NODE_PORT=${pub_port:-9000} PUB_IP= METRICS= PUSHGATEWAY_IP= From fcb04eededaeeb9979ed62e3302753bb1c1651c2 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 21 Dec 2019 13:49:30 -0800 Subject: [PATCH 2/4] [node] add -M support multi-key mode Signed-off-by: Leo Chen --- scripts/node.sh | 68 ++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/scripts/node.sh b/scripts/node.sh index 1777886bd..ba0331b3d 100755 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -121,6 +121,7 @@ options: -V print out the version of the Harmony binary -z run in staking mode -y run in legacy, foundational-node mode (default) + -M support multi-key mode (default: off) examples: @@ -157,7 +158,7 @@ BUCKET=pub.harmony.one OS=$(uname -s) unset start_clean loop run_as_root blspass do_not_download download_only metrics network node_type shard_id download_harmony_db db_file_to_dl -unset upgrade_rel public_rpc staking_mode pub_port +unset upgrade_rel public_rpc staking_mode pub_port multi_key start_clean=false loop=true run_as_root=true @@ -170,11 +171,12 @@ shard_id=1 download_harmony_db=false public_rpc=false staking_mode=false +multi_key=false ${BLSKEYFILE=} unset OPTIND OPTARG opt OPTIND=1 -while getopts :1chk:sSp:dDmN:tT:i:ba:U:PvVyzn: opt +while getopts :1chk:sSp:dDmN:tT:i:ba:U:PvVyzn:M opt do case "${opt}" in '?') usage "unrecognized option -${OPTARG}";; @@ -189,6 +191,7 @@ do p) blspass="${OPTARG}";; d) download_only=true;; D) do_not_download=true;; + M) multi_key=true;; m) metrics=true;; N) network="${OPTARG}";; n) pub_port="${OPTARG}";; @@ -438,35 +441,38 @@ if ${run_as_root}; then check_root fi -case "${BLSKEYFILE}" in -"") - unset -v f - for f in \ - ~/*--????-??-??T??-??-??.*Z--bls_???????????????????????????????????????????????????????????????????????????????????????????????? \ - ~/????????????????????????????????????????????????????????????????????????????????????????????????.key \ - *--????-??-??T??-??-??.*Z--bls_???????????????????????????????????????????????????????????????????????????????????????????????? \ - ????????????????????????????????????????????????????????????????????????????????????????????????.key - do - [ -f "${f}" ] || continue +# multi_key mode will use specified keys in .hmy/multikeys directory +if ! ${multi_key}; then + case "${BLSKEYFILE}" in + "") + unset -v f + for f in \ + ~/*--????-??-??T??-??-??.*Z--bls_???????????????????????????????????????????????????????????????????????????????????????????????? \ + ~/????????????????????????????????????????????????????????????????????????????????????????????????.key \ + *--????-??-??T??-??-??.*Z--bls_???????????????????????????????????????????????????????????????????????????????????????????????? \ + ????????????????????????????????????????????????????????????????????????????????????????????????.key + do + [ -f "${f}" ] || continue + case "${BLSKEYFILE}" in + "") + BLSKEYFILE="${f}" + ;; + *) + [ "${f}" -ef "${BLSKEYFILE}" ] || \ + err 69 "multiple key files found (${f}, ${BLSKEYFILE}); please use -k to specify" + ;; + esac + done case "${BLSKEYFILE}" in - "") - BLSKEYFILE="${f}" - ;; - *) - [ "${f}" -ef "${BLSKEYFILE}" ] || \ - err 69 "multiple key files found (${f}, ${BLSKEYFILE}); please use -k to specify" - ;; + "") err 69 "could not autodetect BLS key file; please use -k to specify";; esac - done - case "${BLSKEYFILE}" in - "") err 69 "could not autodetect BLS key file; please use -k to specify";; + msg "autodetected BLS key file: ${BLSKEYFILE}" + ;; + *) + msg "using manually specified BLS key file: ${BLSKEYFILE}" + ;; esac - msg "autodetected BLS key file: ${BLSKEYFILE}" - ;; -*) - msg "using manually specified BLS key file: ${BLSKEYFILE}" - ;; -esac +fi any_new_binaries() { local outdir @@ -649,10 +655,14 @@ do -ip "${PUB_IP}" -port "${NODE_PORT}" -is_genesis - -blskey_file "${BLSKEYFILE}" -network_type="${network_type}" -dns_zone="${dns_zone}" ) + if ! ${multi_key}; then + args+=( + -blskey_file "${BLSKEYFILE}" + ) + fi if ${public_rpc}; then args+=( -public_rpc From a872f29fa30f3852573358590a0962002a8f7865 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 21 Dec 2019 13:55:42 -0800 Subject: [PATCH 3/4] [node] fix the default network type Signed-off-by: Leo Chen --- scripts/node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/node.sh b/scripts/node.sh index ba0331b3d..03369ee1c 100755 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -165,7 +165,7 @@ run_as_root=true do_not_download=false download_only=false metrics=false -network=main +network=mainnet node_type=validator shard_id=1 download_harmony_db=false From 64e48cfd2d26fce52d1852ea978325fd2e79d629 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 21 Dec 2019 14:44:28 -0800 Subject: [PATCH 4/4] [node] set shard_id to -1 by default to avoid override Signed-off-by: Leo Chen --- scripts/node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/node.sh b/scripts/node.sh index 03369ee1c..dff7ac16f 100755 --- a/scripts/node.sh +++ b/scripts/node.sh @@ -167,7 +167,7 @@ download_only=false metrics=false network=mainnet node_type=validator -shard_id=1 +shard_id=-1 download_harmony_db=false public_rpc=false staking_mode=false