From f9a870c05203fa534ae23ab012bb9168baae4242 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 10 Jan 2025 13:53:30 -0600 Subject: [PATCH 01/22] add nohup Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 5 ----- Taskfile.helper.yml | 8 ++++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 199d714a4..557ef372a 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -83,11 +83,6 @@ function start_sdk_test () return $result } -echo "Restart port-forward" -task clean:port-forward -enable_port_forward - - echo "Change to parent directory" cd ../ create_test_account diff --git a/Taskfile.helper.yml b/Taskfile.helper.yml index b358f6f84..aea54846a 100644 --- a/Taskfile.helper.yml +++ b/Taskfile.helper.yml @@ -201,7 +201,7 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera Node" - kubectl port-forward -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 & + nohup kubectl port-forward -v=9 -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 > test1.log 2>&1 & sleep 4 fi @@ -221,7 +221,7 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera JSON RPC Relay" - kubectl port-forward -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 & + nohup kubectl port-forward -v=9 -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 > test2.log 2>&1 & sleep 4 fi @@ -391,8 +391,8 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera Explorer & Mirror Node Network" - kubectl port-forward -n "${SOLO_NAMESPACE}" svc/hedera-explorer 8080:80 & - kubectl port-forward svc/mirror-grpc -n "${SOLO_NAMESPACE}" 5600:5600 & + nohup kubectl port-forward -v=9 -n "${SOLO_NAMESPACE}" svc/hedera-explorer 8080:80 > test3.log 2>&1 & + nohup kubectl port-forward -v=9 svc/mirror-grpc -n "${SOLO_NAMESPACE}" 5600:5600 > test4.log 2>&1 & sleep 4 fi From e9a2326b7223c5d193c06f501c484f896cce9b85 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 10 Jan 2025 14:36:15 -0600 Subject: [PATCH 02/22] check port-foward Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 557ef372a..d81b06f4d 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -50,6 +50,17 @@ function setup_smart_contract_test () cd - } +function check_port_forward () +{ + # run background task for few minutes + for i in {1..20} + do + echo "Check port forward" + ps -ef |grep port-forward + sleep 5 + done & +} + function start_background_transactions () { echo "Start background transaction" @@ -89,6 +100,7 @@ create_test_account clone_smart_contract_repo setup_smart_contract_test start_background_transactions +check_port_forward start_contract_test start_sdk_test echo "Sleep a while to wait background transactions to finish" From 135a4f03115e247e2dbb918e3a5726a65596ad2d Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 10 Jan 2025 16:22:31 -0600 Subject: [PATCH 03/22] save Signed-off-by: Jeffrey Tang --- Taskfile.helper.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Taskfile.helper.yml b/Taskfile.helper.yml index aea54846a..3ac5aa100 100644 --- a/Taskfile.helper.yml +++ b/Taskfile.helper.yml @@ -192,6 +192,7 @@ tasks: internal: true deps: - task: "init" + async: true cmds: - | if [[ "${DEBUG_NODE_ALIAS}" != "" ]]; then @@ -216,6 +217,7 @@ tasks: solo:relay: deps: - task: "init" + async: true cmds: - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay deploy -n "${SOLO_NAMESPACE}" -i node1 -q - | @@ -232,7 +234,7 @@ tasks: deps: - task: "init" cmds: - - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 -q + - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 solo:cache:remove: silent: true @@ -386,6 +388,7 @@ tasks: desc: solo mirror-node deploy with port forward on explorer deps: - task: "init" + async: true cmds: - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node deploy --namespace "${SOLO_NAMESPACE}" -q - | @@ -404,7 +407,7 @@ tasks: deps: - task: "init" cmds: - - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force -q || true + - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force || true clean: desc: destroy, then remove cache directory, logs directory, config, and port forwards From f263913bad837f32dc0d04ece366e5a462927c56 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 11:55:27 -0600 Subject: [PATCH 04/22] save Signed-off-by: Jeffrey Tang --- Taskfile.helper.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Taskfile.helper.yml b/Taskfile.helper.yml index 3ac5aa100..25b2d9716 100644 --- a/Taskfile.helper.yml +++ b/Taskfile.helper.yml @@ -202,7 +202,7 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera Node" - nohup kubectl port-forward -v=9 -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 > test1.log 2>&1 & + /bin/bash -c "nohup kubectl port-forward -v=9 -n \"${SOLO_NAMESPACE}\" svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 &" sleep 4 fi @@ -223,7 +223,7 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera JSON RPC Relay" - nohup kubectl port-forward -v=9 -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 > test2.log 2>&1 & + /bin/bash -c "nohup kubectl port-forward -v=9 -n \"${SOLO_NAMESPACE}\" svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 &" sleep 4 fi @@ -394,8 +394,8 @@ tasks: - | if [[ "{{ .use_port_forwards }}" == "true" ]];then echo "Enable port forwarding for Hedera Explorer & Mirror Node Network" - nohup kubectl port-forward -v=9 -n "${SOLO_NAMESPACE}" svc/hedera-explorer 8080:80 > test3.log 2>&1 & - nohup kubectl port-forward -v=9 svc/mirror-grpc -n "${SOLO_NAMESPACE}" 5600:5600 > test4.log 2>&1 & + /bin/bash -c "nohup kubectl port-forward -v=9 -n \"${SOLO_NAMESPACE}\" svc/hedera-explorer 8080:80 > /dev/null 2>&1 &" + /bin/bash -c "nohup kubectl port-forward -v=9 -n \"${SOLO_NAMESPACE}\" svc/mirror-grpc 5600:5600 > /dev/null 2>&1 &" sleep 4 fi From 3c087e244cffc04f9ee74a2007a90a6c0d9f3caa Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 13:31:56 -0600 Subject: [PATCH 05/22] remove async Signed-off-by: Jeffrey Tang --- Taskfile.helper.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Taskfile.helper.yml b/Taskfile.helper.yml index 2bed12bdd..04d99450c 100644 --- a/Taskfile.helper.yml +++ b/Taskfile.helper.yml @@ -213,7 +213,6 @@ tasks: internal: true deps: - task: "init" - async: true cmds: - | if [[ "${DEBUG_NODE_ALIAS}" != "" ]]; then @@ -240,7 +239,6 @@ tasks: silent: true deps: - task: "init" - async: true cmds: - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay deploy -n "${SOLO_NAMESPACE}" -i node1 ${RELAY_NODE_DEPLOY_EXTRA_FLAGS} -q --dev - | @@ -258,7 +256,7 @@ tasks: deps: - task: "init" cmds: - - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 + - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 --dev solo:cache:remove: silent: true @@ -421,7 +419,6 @@ tasks: desc: solo mirror-node deploy with port forward on explorer deps: - task: "init" - async: true cmds: - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node deploy --namespace "${SOLO_NAMESPACE}" -s ${SOLO_CLUSTER_SETUP_NAMESPACE} ${SOLO_CHARTS_DIR_FLAG} ${ENABLE_EXPLORER_TLS_FLAG} ${TLS_CLUSTER_ISSUER_TYPE_FLAG} ${MIRROR_NODE_DEPLOY_EXTRA_FLAGS} --pinger -q --dev - | @@ -444,7 +441,7 @@ tasks: deps: - task: "init" cmds: - - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force || true + - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force --dev || true clean: desc: destroy, then remove cache directory, logs directory, config, and port forwards From 2b082944159820e3bd3183729d06d9c51f6b96f5 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 13:55:01 -0600 Subject: [PATCH 06/22] remove unused Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index d81b06f4d..401e39e60 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -11,14 +11,6 @@ set -eo pipefail source .github/workflows/script/helper.sh -function enable_port_forward () -{ - kubectl port-forward -n solo-e2e svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 & - kubectl port-forward -n solo-e2e svc/hedera-explorer 8080:80 > /dev/null 2>&1 & - kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 & - kubectl port-forward -n solo-e2e svc/mirror-grpc 5600:5600 > /dev/null 2>&1 & -} - function clone_smart_contract_repo () { echo "Clone hedera-smart-contracts" From bc4e3fc9631df43ed024bd910cde7402ae4970ef Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 19:44:38 -0600 Subject: [PATCH 07/22] add account init before deploy relay Signed-off-by: Jeffrey Tang --- .github/workflows/flow-task-test.yaml | 10 ++++++---- .github/workflows/script/helper.sh | 4 +++- .github/workflows/script/solo_smoke_test.sh | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/flow-task-test.yaml b/.github/workflows/flow-task-test.yaml index 32b0fc903..ea052f9ff 100644 --- a/.github/workflows/flow-task-test.yaml +++ b/.github/workflows/flow-task-test.yaml @@ -38,6 +38,9 @@ jobs: example-task-file-test: timeout-minutes: 20 runs-on: solo-linux-large + strategy: + matrix: + type: ["NO_ACCOUNT_INIT", "ACCOUNT_INIT"] steps: - name: Harden Runner uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 @@ -63,9 +66,8 @@ jobs: verbosity: 3 wait: 120s - - name: Run Example Task File Test + - name: Run Example Task File Test with type ${{ matrix.type }} run: | - task default-with-relay - sleep 10 - .github/workflows/script/solo_smoke_test.sh + task default + .github/workflows/script/solo_smoke_test.sh ${{ matrix.type }} task clean diff --git a/.github/workflows/script/helper.sh b/.github/workflows/script/helper.sh index ffed2745d..768d34c1a 100644 --- a/.github/workflows/script/helper.sh +++ b/.github/workflows/script/helper.sh @@ -14,7 +14,9 @@ function create_test_account () # get private key of the account npm run solo-test -- account get -n solo-e2e --account-id ${OPERATOR_ID} --private-key > test.log - export OPERATOR_KEY=$(grep "privateKey" test.log | awk '{print $2}' | sed 's/"//g'| sed 's/,//g') + + # retrieve the field privateKey but not privateKeyRaw + export OPERATOR_KEY=$(grep "privateKey" test.log | grep -v "privateKeyRaw" | awk '{print $2}' | sed 's/"//g'| sed 's/,//g') export CONTRACT_TEST_KEY_ONE=0x$(grep "privateKeyRaw" test.log | awk '{print $2}' | sed 's/"//g'| sed 's/,//g') echo "CONTRACT_TEST_KEY_ONE=${CONTRACT_TEST_KEY_ONE}" rm test.log diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 401e39e60..ff9732994 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -89,6 +89,25 @@ function start_sdk_test () echo "Change to parent directory" cd ../ create_test_account + +cd solo +# if first parameter equals to ACCOUNT_INIT, +# then call solo account init before deploy mirror and relay node +if [ -n "$1" ] && [ "$1" == "ACCOUNT_INIT" ]; then + echo "Call solo account init" + solo account init -n solo-e2e + + task solo:mirror-node + + solo relay deploy -n solo-e2e -i node1 --operator-key $OPERATOR_KEY --operator-id $OPERATOR_ID + kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 & + +else + task solo:mirror-node + task solo:relay +fi +cd - + clone_smart_contract_repo setup_smart_contract_test start_background_transactions From b4aaf2bcb26b3dfa4523f03c35640778675aa04a Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 19:56:41 -0600 Subject: [PATCH 08/22] save Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index ff9732994..10e2a8913 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -95,7 +95,7 @@ cd solo # then call solo account init before deploy mirror and relay node if [ -n "$1" ] && [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" - solo account init -n solo-e2e + npm run solo-test -- account init -n solo-e2e task solo:mirror-node From 28e1c75e6cac79950c51fae979a94b955be65e96 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 20:13:21 -0600 Subject: [PATCH 09/22] save Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 10e2a8913..855d2180a 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -93,7 +93,7 @@ create_test_account cd solo # if first parameter equals to ACCOUNT_INIT, # then call solo account init before deploy mirror and relay node -if [ -n "$1" ] && [ "$1" == "ACCOUNT_INIT" ]; then +if [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" npm run solo-test -- account init -n solo-e2e From 0e0c8d25ddaf32092b86a93508647754bb4a8129 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 22:51:42 -0600 Subject: [PATCH 10/22] save Signed-off-by: Jeffrey Tang --- .github/workflows/flow-task-test.yaml | 2 +- .github/workflows/script/solo_smoke_test.sh | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/flow-task-test.yaml b/.github/workflows/flow-task-test.yaml index ea052f9ff..f38c1eac0 100644 --- a/.github/workflows/flow-task-test.yaml +++ b/.github/workflows/flow-task-test.yaml @@ -68,6 +68,6 @@ jobs: - name: Run Example Task File Test with type ${{ matrix.type }} run: | - task default + task default-with-mirror .github/workflows/script/solo_smoke_test.sh ${{ matrix.type }} task clean diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 855d2180a..2a318aed0 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -97,13 +97,10 @@ if [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" npm run solo-test -- account init -n solo-e2e - task solo:mirror-node - solo relay deploy -n solo-e2e -i node1 --operator-key $OPERATOR_KEY --operator-id $OPERATOR_ID kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 & else - task solo:mirror-node task solo:relay fi cd - From 1ed59772e9359d45dd05c5bedf81539d11c554a4 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 23:04:35 -0600 Subject: [PATCH 11/22] fix Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 2a318aed0..17226ea92 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -97,7 +97,7 @@ if [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" npm run solo-test -- account init -n solo-e2e - solo relay deploy -n solo-e2e -i node1 --operator-key $OPERATOR_KEY --operator-id $OPERATOR_ID + npm run solo-test -- relay deploy -n solo-e2e -i node1 --operator-key $OPERATOR_KEY --operator-id $OPERATOR_ID kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 & else From 86b4f7668bcff69f88a337877bc1d8ed5c53de7c Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Mon, 13 Jan 2025 23:21:59 -0600 Subject: [PATCH 12/22] save Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 17226ea92..cc197becc 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -92,7 +92,7 @@ create_test_account cd solo # if first parameter equals to ACCOUNT_INIT, -# then call solo account init before deploy mirror and relay node +# then call solo account init before deploy relay node if [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" npm run solo-test -- account init -n solo-e2e From 2c1998702f19ef7bafca1acadfddf3d8d28dced2 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 14 Jan 2025 12:52:02 -0600 Subject: [PATCH 13/22] lookup operator key Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 16 ++++++---------- src/commands/mirror_node.ts | 8 +++++++- src/commands/relay.ts | 11 +++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index cc197becc..548646b90 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -86,25 +86,21 @@ function start_sdk_test () return $result } -echo "Change to parent directory" -cd ../ -create_test_account -cd solo # if first parameter equals to ACCOUNT_INIT, # then call solo account init before deploy relay node if [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" npm run solo-test -- account init -n solo-e2e +fi - npm run solo-test -- relay deploy -n solo-e2e -i node1 --operator-key $OPERATOR_KEY --operator-id $OPERATOR_ID - kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 & +task solo:mirror-node +task solo:relay -else - task solo:relay -fi -cd - +echo "Change to parent directory" +cd ../ +create_test_account clone_smart_contract_repo setup_smart_contract_test start_background_transactions diff --git a/src/commands/mirror_node.ts b/src/commands/mirror_node.ts index c27789c8a..a8cd5c978 100644 --- a/src/commands/mirror_node.ts +++ b/src/commands/mirror_node.ts @@ -265,7 +265,13 @@ export class MirrorNodeCommand extends BaseCommand { ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.nodes.0.host=${pod.status.podIP}`; ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.accountId=${constants.OPERATOR_ID}`; - ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${constants.OPERATOR_KEY}`; + try { + const keys = await this.accountManager.getAccountKeys(constants.OPERATOR_ID); + const newOperatorKey = keys[0].toString(); + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${newOperatorKey}`; + } catch (e: Error | any) { + throw new SoloError(`Failed to get operator key for mirror node monitor. ${e.message}`, e); + } } } diff --git a/src/commands/relay.ts b/src/commands/relay.ts index ede47a104..2786425ed 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -107,10 +107,21 @@ export class RelayCommand extends BaseCommand { if (operatorID) { valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; + } else { + this.logger.info(`Use default operator id ${constants.OPERATOR_ID}`); } if (operatorKey) { valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKey}`; + } else { + //lookup the operator key from GENESIS ACCOUNT since it could have been changed + try { + const keys = await this.accountManager.getAccountKeys(constants.OPERATOR_ID); + const newOperatorKey = keys[0].toString(); + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${newOperatorKey}`; + } catch (e: Error | any) { + throw new SoloError(`Error getting operator key or relay node: ${e.message}`, e); + } } if (!nodeAliases) { From e5aa20f1835d462a2ffabfcce5f405b3f636a99e Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 14 Jan 2025 17:05:47 -0600 Subject: [PATCH 14/22] save Signed-off-by: Jeffrey Tang --- .github/workflows/flow-task-test.yaml | 2 +- .github/workflows/script/solo_smoke_test.sh | 2 +- src/commands/mirror_node.ts | 13 +++++++--- src/commands/relay.ts | 27 +++++++++++---------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/flow-task-test.yaml b/.github/workflows/flow-task-test.yaml index f38c1eac0..ea052f9ff 100644 --- a/.github/workflows/flow-task-test.yaml +++ b/.github/workflows/flow-task-test.yaml @@ -68,6 +68,6 @@ jobs: - name: Run Example Task File Test with type ${{ matrix.type }} run: | - task default-with-mirror + task default .github/workflows/script/solo_smoke_test.sh ${{ matrix.type }} task clean diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 548646b90..c5ba6d376 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -88,7 +88,7 @@ function start_sdk_test () # if first parameter equals to ACCOUNT_INIT, -# then call solo account init before deploy relay node +# then call solo account init before deploy mirror and relay node if [ "$1" == "ACCOUNT_INIT" ]; then echo "Call solo account init" npm run solo-test -- account init -n solo-e2e diff --git a/src/commands/mirror_node.ts b/src/commands/mirror_node.ts index a8cd5c978..d6110bb40 100644 --- a/src/commands/mirror_node.ts +++ b/src/commands/mirror_node.ts @@ -33,6 +33,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import type {Optional, SoloListrTask} from '../types/index.js'; import type {Namespace} from '../core/config/remote/types.js'; +import * as Base64 from 'js-base64'; interface MirrorNodeDeployConfigClass { chartDirectory: string; @@ -263,12 +264,18 @@ export class MirrorNodeCommand extends BaseCommand { const pod = networkPods[0]; ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.nodes.0.accountId=${startAccId}`; ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.nodes.0.host=${pod.status.podIP}`; + ctx.config.valuesArg += ' --set monitor.config.hedera.mirror.monitor.nodes.0.nodeId=0'; ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.accountId=${constants.OPERATOR_ID}`; + const secrets = await self.k8.getSecretsByLabel([ + `solo.hedera.com/account-id=${constants.OPERATOR_ID}`, + ]); + if (secrets.length === 0) { + throw new SoloError(`No secret found for operator account id ${constants.OPERATOR_ID}`); + } try { - const keys = await this.accountManager.getAccountKeys(constants.OPERATOR_ID); - const newOperatorKey = keys[0].toString(); - ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${newOperatorKey}`; + const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${operatorKeyFromK8}`; } catch (e: Error | any) { throw new SoloError(`Failed to get operator key for mirror node monitor. ${e.message}`, e); } diff --git a/src/commands/relay.ts b/src/commands/relay.ts index 2786425ed..f4ef46038 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -29,6 +29,7 @@ import {type Opts} from '../types/command_types.js'; import {ListrLease} from '../core/lease/listr_lease.js'; import {RelayComponent} from '../core/config/remote/components/relay_component.js'; import {ComponentType} from '../core/config/remote/enumerations.js'; +import * as Base64 from 'js-base64'; export class RelayCommand extends BaseCommand { private readonly profileManager: ProfileManager; @@ -105,23 +106,23 @@ export class RelayCommand extends BaseCommand { valuesArg += ` --set replicaCount=${replicaCount}`; } - if (operatorID) { - valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; - } else { + if (operatorID === constants.OPERATOR_ID) { this.logger.info(`Use default operator id ${constants.OPERATOR_ID}`); + } else { + this.logger.info(`Use operator id from command line flag ${operatorID}`); } + valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; - if (operatorKey) { - valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKey}`; + const secrets = await this.k8.getSecretsByLabel([`solo.hedera.com/account-id=${constants.OPERATOR_ID}`]); + if (secrets.length === 0) { + throw new SoloError(`No secret found for operator account id ${constants.OPERATOR_ID}`); + } + const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKeyFromK8}`; + if (operatorKeyFromK8 === constants.OPERATOR_KEY) { + this.logger.info(`Use default operator key ${constants.OPERATOR_KEY}`); } else { - //lookup the operator key from GENESIS ACCOUNT since it could have been changed - try { - const keys = await this.accountManager.getAccountKeys(constants.OPERATOR_ID); - const newOperatorKey = keys[0].toString(); - valuesArg += ` --set config.OPERATOR_KEY_MAIN=${newOperatorKey}`; - } catch (e: Error | any) { - throw new SoloError(`Error getting operator key or relay node: ${e.message}`, e); - } + this.logger.info('Use operator key from k8s secret'); } if (!nodeAliases) { From 7432ce40cc51aeaa28ff16285d965e8fc694f590 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 14 Jan 2025 17:27:50 -0600 Subject: [PATCH 15/22] format Signed-off-by: Jeffrey Tang --- docs/content/User/StepByStepGuide.md | 8 ++++++-- examples/address-book/README.md | 14 +++++++++++--- src/commands/mirror_node.ts | 12 +++++++----- src/commands/relay.ts | 16 ++++------------ 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/docs/content/User/StepByStepGuide.md b/docs/content/User/StepByStepGuide.md index b84b9bbc9..43c791667 100644 --- a/docs/content/User/StepByStepGuide.md +++ b/docs/content/User/StepByStepGuide.md @@ -1,5 +1,7 @@ ## Advanced User Guide + For those who would like to have more control or need some customized setups, here are some step by step instructions of how to setup and deploy a solo network. + ### Setup Kubernetes cluster #### Remote cluster @@ -28,6 +30,7 @@ Then run the following command to set the kubectl context to the new cluster: ```bash kind create cluster -n "${SOLO_CLUSTER_NAME}" ``` + Example output ``` @@ -48,7 +51,6 @@ Thanks for using kind! 😊 You may now view pods in your cluster using `k9s -A` as below: - ``` Context: kind-solo <0> all Attach Delete | |/ _/ __ \______ @@ -75,7 +77,6 @@ You may now view pods in your cluster using `k9s -A` as below: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` - ### Step by Step Instructions * Initialize `solo` directories: @@ -136,13 +137,16 @@ Kubernetes Cluster : kind-solo ✔ Generate gRPC TLS Keys ✔ Finalize ``` + PEM key files are generated in `~/.solo/keys` directory. + ``` hedera-node1.crt hedera-node3.crt s-private-node1.pem s-public-node1.pem unused-gossip-pem hedera-node1.key hedera-node3.key s-private-node2.pem s-public-node2.pem unused-tls hedera-node2.crt hedera-node4.crt s-private-node3.pem s-public-node3.pem hedera-node2.key hedera-node4.key s-private-node4.pem s-public-node4.pem ``` + * Setup cluster with shared components ``` diff --git a/examples/address-book/README.md b/examples/address-book/README.md index 96b35b073..392b3517b 100644 --- a/examples/address-book/README.md +++ b/examples/address-book/README.md @@ -1,12 +1,13 @@ # Yahcli Address Book Example -This is an example of how to use Yahcli to pull the ledger and mirror node address book. And to update the ledger address book. It updates File 101 (the ledger address book file) and File 102 (the ledger node details file). +This is an example of how to use Yahcli to pull the ledger and mirror node address book. And to update the ledger address book. It updates File 101 (the ledger address book file) and File 102 (the ledger node details file). NOTE: Mirror Node refers to File 102 as its address book. ## Usage -To get the address book from the ledger, this requires a port forward to be setup on port 50211 to consensus node with node ID = 0. +To get the address book from the ledger, this requires a port forward to be setup on port 50211 to consensus node with node ID = 0. + ```bash # try and detect if the port forward is already setup netstat -na | grep 50211 @@ -17,28 +18,35 @@ kubectl port-forward -n "${SOLO_NAMESPACE}" pod/network-node1-0 50211:50211 ``` To get the address book from the ledger, run the following command: + ```bash cd /examples/address-book task get:ledger:addressbook ``` -It will output the address book in JSON format to: + +It will output the address book in JSON format to: + * `examples/address-book/localhost/sysfiles/addressBook.json` * `examples/address-book/localhost/sysfiles/nodeDetails.json` You can update the address book files with your favorite text editor. Once the files are ready, you can upload them to the ledger by running the following command: + ```bash cd /examples/address-book task update:ledger:addressbook ``` To get the address book from the mirror node, run the following command: + ```bash cd /examples/address-book task get:mirror:addressbook ``` + NOTE: Mirror Node may not pick up the changes automatically, it might require running some transactions through, example: + ```bash cd npm run solo -- account create diff --git a/src/commands/mirror_node.ts b/src/commands/mirror_node.ts index f19c2eacb..e8fa9f782 100644 --- a/src/commands/mirror_node.ts +++ b/src/commands/mirror_node.ts @@ -267,17 +267,19 @@ export class MirrorNodeCommand extends BaseCommand { ctx.config.valuesArg += ' --set monitor.config.hedera.mirror.monitor.nodes.0.nodeId=0'; ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.accountId=${constants.OPERATOR_ID}`; + + // get operatorKey from k8s secret since it could have been changed const secrets = await self.k8.getSecretsByLabel([ `solo.hedera.com/account-id=${constants.OPERATOR_ID}`, ]); if (secrets.length === 0) { - throw new SoloError(`No secret found for operator account id ${constants.OPERATOR_ID}`); - } - try { + this.logger.info( + `No secret found for operator account id ${constants.OPERATOR_ID} from k8s, use default one`, + ); + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${constants.OPERATOR_KEY}`; + } else { const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${operatorKeyFromK8}`; - } catch (e: Error | any) { - throw new SoloError(`Failed to get operator key for mirror node monitor. ${e.message}`, e); } } } diff --git a/src/commands/relay.ts b/src/commands/relay.ts index b44880d44..aa93be945 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -106,23 +106,15 @@ export class RelayCommand extends BaseCommand { valuesArg += ` --set replicaCount=${replicaCount}`; } - if (operatorID === constants.OPERATOR_ID) { - this.logger.info(`Use default operator id ${constants.OPERATOR_ID}`); - } else { - this.logger.info(`Use operator id from command line flag ${operatorID}`); - } valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; const secrets = await this.k8.getSecretsByLabel([`solo.hedera.com/account-id=${constants.OPERATOR_ID}`]); if (secrets.length === 0) { - throw new SoloError(`No secret found for operator account id ${constants.OPERATOR_ID}`); - } - const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); - valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKeyFromK8}`; - if (operatorKeyFromK8 === constants.OPERATOR_KEY) { - this.logger.info(`Use default operator key ${constants.OPERATOR_KEY}`); + this.logger.info(`No k8s secret found for operator account id ${constants.OPERATOR_ID}, use default one`); + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${constants.OPERATOR_KEY}`; } else { - this.logger.info('Use operator key from k8s secret'); + const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKeyFromK8}`; } if (!nodeAliases) { From e150d3832f2ab07905d4e1ceb13e99a3f9e41dac Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 14 Jan 2025 19:37:39 -0600 Subject: [PATCH 16/22] revert Signed-off-by: Jeffrey Tang --- Taskfile.helper.yml | 4 ++-- src/commands/relay.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Taskfile.helper.yml b/Taskfile.helper.yml index 04d99450c..8b7dcdccd 100644 --- a/Taskfile.helper.yml +++ b/Taskfile.helper.yml @@ -256,7 +256,7 @@ tasks: deps: - task: "init" cmds: - - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 --dev + - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 -q --dev solo:cache:remove: silent: true @@ -441,7 +441,7 @@ tasks: deps: - task: "init" cmds: - - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force --dev || true + - SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force -q --dev || true clean: desc: destroy, then remove cache directory, logs directory, config, and port forwards diff --git a/src/commands/relay.ts b/src/commands/relay.ts index aa93be945..686b4d186 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -106,7 +106,9 @@ export class RelayCommand extends BaseCommand { valuesArg += ` --set replicaCount=${replicaCount}`; } - valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; + if (operatorID) { + valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; + } const secrets = await this.k8.getSecretsByLabel([`solo.hedera.com/account-id=${constants.OPERATOR_ID}`]); if (secrets.length === 0) { From 9c446d0d2a5dfb70b47828af46bb3c08422b9ac8 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 15 Jan 2025 13:16:38 -0600 Subject: [PATCH 17/22] update how to extract operator key Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 9 +++++ src/commands/flags.ts | 4 +- src/commands/mirror_node.ts | 42 +++++++++++++-------- src/commands/relay.ts | 29 +++++++++----- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index c5ba6d376..735453861 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -109,3 +109,12 @@ start_contract_test start_sdk_test echo "Sleep a while to wait background transactions to finish" sleep 30 + +# get the logs of mirror-monitor +kubectl get pods -n solo-e2e | grep mirror-monitor | awk '{print $1}' | xargs kubectl logs -n solo-e2e > mirror-monitor.log + +if grep -q "ERROR" mirror-monitor.log; then + echo "mirror-monitor.log contains ERROR" + exit 1 +fi + diff --git a/src/commands/flags.ts b/src/commands/flags.ts index 21fd258aa..6915d415b 100644 --- a/src/commands/flags.ts +++ b/src/commands/flags.ts @@ -620,7 +620,7 @@ export class Flags { name: 'operator-id', definition: { describe: 'Operator ID', - defaultValue: constants.OPERATOR_ID, + defaultValue: undefined, type: 'string', }, prompt: async function promptOperatorId(task: ListrTaskWrapper, input: any) { @@ -641,7 +641,7 @@ export class Flags { name: 'operator-key', definition: { describe: 'Operator Key', - defaultValue: constants.OPERATOR_KEY, + defaultValue: undefined, type: 'string', }, prompt: async function promptOperatorKey(task: ListrTaskWrapper, input: any) { diff --git a/src/commands/mirror_node.ts b/src/commands/mirror_node.ts index e8fa9f782..3f6bafe1e 100644 --- a/src/commands/mirror_node.ts +++ b/src/commands/mirror_node.ts @@ -54,6 +54,8 @@ interface MirrorNodeDeployConfigClass { clusterSetupNamespace: string; soloChartVersion: string; pinger: boolean; + operatorId: string; + operatorKey: string; customMirrorNodeDatabaseValuePath: Optional; storageType: constants.StorageType; storageAccessKey: string; @@ -105,6 +107,8 @@ export class MirrorNodeCommand extends BaseCommand { flags.clusterSetupNamespace, flags.soloChartVersion, flags.customMirrorNodeDatabaseValuePath, + flags.operatorId, + flags.operatorKey, flags.storageType, flags.storageAccessKey, flags.storageSecrets, @@ -235,6 +239,8 @@ export class MirrorNodeCommand extends BaseCommand { flags.valuesFile, flags.mirrorNodeVersion, flags.pinger, + flags.operatorId, + flags.operatorKey, flags.soloChartVersion, ]); @@ -256,6 +262,8 @@ export class MirrorNodeCommand extends BaseCommand { // user defined values later to override predefined values ctx.config.valuesArg += await self.prepareValuesArg(ctx.config); + await self.accountManager.loadNodeClient(ctx.config.namespace); + if (ctx.config.pinger) { const startAccId = constants.HEDERA_NODE_ACCOUNT_ID_START; const networkPods = await this.k8.getPodsByLabel(['solo.hedera.com/type=network-node']); @@ -266,20 +274,26 @@ export class MirrorNodeCommand extends BaseCommand { ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.nodes.0.host=${pod.status.podIP}`; ctx.config.valuesArg += ' --set monitor.config.hedera.mirror.monitor.nodes.0.nodeId=0'; - ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.accountId=${constants.OPERATOR_ID}`; - - // get operatorKey from k8s secret since it could have been changed - const secrets = await self.k8.getSecretsByLabel([ - `solo.hedera.com/account-id=${constants.OPERATOR_ID}`, - ]); - if (secrets.length === 0) { - this.logger.info( - `No secret found for operator account id ${constants.OPERATOR_ID} from k8s, use default one`, - ); - ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${constants.OPERATOR_KEY}`; + const operatorId = ctx.config.operatorId || constants.OPERATOR_ID; + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.accountId=${operatorId}`; + + if (ctx.config.operatorKey) { + this.logger.info(`Using provided operator key: ${ctx.config.operatorKey}`); + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${ctx.config.operatorKey}`; } else { - const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); - ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${operatorKeyFromK8}`; + try { + const secrets = await this.k8.getSecretsByLabel([`solo.hedera.com/account-id=${operatorId}`]); + if (secrets.length === 0) { + this.logger.info(`No k8s secret found for operator account id ${operatorId}, use default one`); + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${constants.OPERATOR_KEY}`; + } else { + this.logger.info('Using operator key from k8s secret'); + const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); + ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${operatorKeyFromK8}`; + } + } catch (e: Error | any) { + throw new SoloError(`Error getting operator key: ${e.message}`, e); + } } } } @@ -288,8 +302,6 @@ export class MirrorNodeCommand extends BaseCommand { throw new SoloError(`namespace ${ctx.config.namespace} does not exist`); } - await self.accountManager.loadNodeClient(ctx.config.namespace); - return ListrLease.newAcquireLeaseTask(lease, task); }, }, diff --git a/src/commands/relay.ts b/src/commands/relay.ts index 686b4d186..ce4b92df6 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -106,17 +106,26 @@ export class RelayCommand extends BaseCommand { valuesArg += ` --set replicaCount=${replicaCount}`; } - if (operatorID) { - valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorID}`; - } + const operatorIdUsing = operatorID || constants.OPERATOR_ID; + valuesArg += ` --set config.OPERATOR_ID_MAIN=${operatorIdUsing}`; - const secrets = await this.k8.getSecretsByLabel([`solo.hedera.com/account-id=${constants.OPERATOR_ID}`]); - if (secrets.length === 0) { - this.logger.info(`No k8s secret found for operator account id ${constants.OPERATOR_ID}, use default one`); - valuesArg += ` --set config.OPERATOR_KEY_MAIN=${constants.OPERATOR_KEY}`; + if (operatorKey) { + // use user provided operatorKey if available + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKey}`; } else { - const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); - valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKeyFromK8}`; + try { + const secrets = await this.k8.getSecretsByLabel([`solo.hedera.com/account-id=${operatorIdUsing}`]); + if (secrets.length === 0) { + this.logger.info(`No k8s secret found for operator account id ${operatorIdUsing}, use default one`); + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${constants.OPERATOR_KEY}`; + } else { + this.logger.info('Using operator key from k8s secret'); + const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey); + valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKeyFromK8}`; + } + } catch (e: Error | any) { + throw new SoloError(`Error getting operator key: ${e.message}`, e); + } } if (!nodeAliases) { @@ -237,6 +246,7 @@ export class RelayCommand extends BaseCommand { constants.JSON_RPC_RELAY_CHART, constants.JSON_RPC_RELAY_CHART, ); + await self.accountManager.loadNodeClient(ctx.config.namespace); config.valuesArg = await self.prepareValuesArg( config.valuesFile, config.nodeAliases, @@ -304,6 +314,7 @@ export class RelayCommand extends BaseCommand { throw new SoloError('Error installing relays', e); } finally { await lease.release(); + await self.accountManager.close(); } return true; From 54442de08287d2e9c4c443b16e77c999088c329e Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 15 Jan 2025 13:45:27 -0600 Subject: [PATCH 18/22] add acceptance test Signed-off-by: Jeffrey Tang --- .github/workflows/script/solo_smoke_test.sh | 41 +++++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/script/solo_smoke_test.sh b/.github/workflows/script/solo_smoke_test.sh index 735453861..da89cde9b 100755 --- a/.github/workflows/script/solo_smoke_test.sh +++ b/.github/workflows/script/solo_smoke_test.sh @@ -86,6 +86,35 @@ function start_sdk_test () return $result } +function check_monitor_log() +{ + # get the logs of mirror-monitor + kubectl get pods -n solo-e2e | grep mirror-monitor | awk '{print $1}' | xargs kubectl logs -n solo-e2e > mirror-monitor.log + + if grep -q "ERROR" mirror-monitor.log; then + echo "mirror-monitor.log contains ERROR" + exit 1 + fi + + # any line contains "Scenario pinger published" should contain the string "Errors: {}" + if grep -q "Scenario pinger published" mirror-monitor.log; then + if grep -q "Errors: {}" mirror-monitor.log; then + echo "mirror-monitor.log contains Scenario pinger published and Errors: {}" + else + echo "mirror-monitor.log contains Scenario pinger published but not Errors: {}" + exit 1 + fi + fi +} + +function check_importer_log() +{ + kubectl get pods -n solo-e2e | grep mirror-importer | awk '{print $1}' | xargs kubectl logs -n solo-e2e > mirror-importer.log + if grep -q "ERROR" mirror-importer.log; then + echo "mirror-importer.log contains ERROR" + exit 1 + fi +} # if first parameter equals to ACCOUNT_INIT, # then call solo account init before deploy mirror and relay node @@ -110,11 +139,7 @@ start_sdk_test echo "Sleep a while to wait background transactions to finish" sleep 30 -# get the logs of mirror-monitor -kubectl get pods -n solo-e2e | grep mirror-monitor | awk '{print $1}' | xargs kubectl logs -n solo-e2e > mirror-monitor.log - -if grep -q "ERROR" mirror-monitor.log; then - echo "mirror-monitor.log contains ERROR" - exit 1 -fi - +echo "Run mirror node acceptance test" +helm test mirror -n solo-e2e --timeout 10m +check_monitor_log +check_importer_log From 6c40837943755d74c8c2244698b3f16bf4f701e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 15 Jan 2025 14:09:51 -0600 Subject: [PATCH 19/22] add helm install Signed-off-by: Jeffrey Tang --- .github/workflows/flow-task-test.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/flow-task-test.yaml b/.github/workflows/flow-task-test.yaml index ea052f9ff..5f3d17286 100644 --- a/.github/workflows/flow-task-test.yaml +++ b/.github/workflows/flow-task-test.yaml @@ -56,6 +56,11 @@ jobs: node-version: 20 cache: npm + - name: Setup Helm + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 + with: + version: "v3.12.3" # helm version + - name: Setup Kind uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0 with: From 050bb7a13094ffa12d8c621ee2c60785e7381d47 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 15 Jan 2025 19:31:08 -0600 Subject: [PATCH 20/22] save Signed-off-by: Jeffrey Tang --- src/commands/relay.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/commands/relay.ts b/src/commands/relay.ts index ce4b92df6..f63a1103a 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -217,6 +217,11 @@ export class RelayCommand extends BaseCommand { self.configManager.update(argv); + flags.disablePrompts([ + flags.operatorId, + flags.operatorKey, + ]); + await self.configManager.executePrompt(task, RelayCommand.DEPLOY_FLAGS_LIST); // prompt if inputs are empty and set it in the context From fbe41edf99f2acd686e6303735123b86c3ec8d64 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 15 Jan 2025 21:14:41 -0600 Subject: [PATCH 21/22] format Signed-off-by: Jeffrey Tang --- src/commands/relay.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/commands/relay.ts b/src/commands/relay.ts index f63a1103a..1be3c97c1 100644 --- a/src/commands/relay.ts +++ b/src/commands/relay.ts @@ -217,10 +217,7 @@ export class RelayCommand extends BaseCommand { self.configManager.update(argv); - flags.disablePrompts([ - flags.operatorId, - flags.operatorKey, - ]); + flags.disablePrompts([flags.operatorId, flags.operatorKey]); await self.configManager.executePrompt(task, RelayCommand.DEPLOY_FLAGS_LIST); From 9e7759b14b5691823cfd8f0392da13951e182700 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 16 Jan 2025 12:15:55 -0600 Subject: [PATCH 22/22] remove key from log Signed-off-by: Jeffrey Tang --- src/commands/mirror_node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/mirror_node.ts b/src/commands/mirror_node.ts index 3f6bafe1e..6e2f63f4f 100644 --- a/src/commands/mirror_node.ts +++ b/src/commands/mirror_node.ts @@ -278,7 +278,7 @@ export class MirrorNodeCommand extends BaseCommand { ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.accountId=${operatorId}`; if (ctx.config.operatorKey) { - this.logger.info(`Using provided operator key: ${ctx.config.operatorKey}`); + this.logger.info('Using provided operator key'); ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${ctx.config.operatorKey}`; } else { try {