Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: account init before relay deployment #1154

Merged
merged 27 commits into from
Jan 17, 2025
Merged
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f9a870c
add nohup
JeffreyDallas Jan 10, 2025
e9a2326
check port-foward
JeffreyDallas Jan 10, 2025
135a4f0
save
JeffreyDallas Jan 10, 2025
f263913
save
JeffreyDallas Jan 13, 2025
52e56fc
Merge commit '4ebae5d6ed897dfca91176fe0092c0cffced68d2' into 01115-D-…
JeffreyDallas Jan 13, 2025
3c087e2
remove async
JeffreyDallas Jan 13, 2025
2b08294
remove unused
JeffreyDallas Jan 13, 2025
9dd76c4
Merge branch 'main' into 01115-D-portforward-quit-task
JeffreyDallas Jan 13, 2025
bc4e3fc
add account init before deploy relay
JeffreyDallas Jan 14, 2025
b4aaf2b
save
JeffreyDallas Jan 14, 2025
28e1c75
save
JeffreyDallas Jan 14, 2025
0e0c8d2
save
JeffreyDallas Jan 14, 2025
1ed5977
fix
JeffreyDallas Jan 14, 2025
86b4f76
save
JeffreyDallas Jan 14, 2025
2c19987
lookup operator key
JeffreyDallas Jan 14, 2025
e5aa20f
save
JeffreyDallas Jan 14, 2025
e6b93e1
Merge commit '97537711e285a81ddeb6e8887ce01185347bee31' into 01149-D-…
JeffreyDallas Jan 14, 2025
925f2f8
Merge branch 'main' into 01149-D-account-init-before-relay
JeffreyDallas Jan 14, 2025
7432ce4
format
JeffreyDallas Jan 14, 2025
e150d38
revert
JeffreyDallas Jan 15, 2025
9c446d0
update how to extract operator key
JeffreyDallas Jan 15, 2025
54442de
add acceptance test
JeffreyDallas Jan 15, 2025
f201c02
Merge branch 'main' into 01149-D-account-init-before-relay
JeffreyDallas Jan 15, 2025
6c40837
add helm install
JeffreyDallas Jan 15, 2025
050bb7a
save
JeffreyDallas Jan 16, 2025
fbe41ed
format
JeffreyDallas Jan 16, 2025
9e7759b
remove key from log
JeffreyDallas Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/flow-task-test.yaml
Original file line number Diff line number Diff line change
@@ -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-with-mirror
.github/workflows/script/solo_smoke_test.sh ${{ matrix.type }}
task clean
4 changes: 3 additions & 1 deletion .github/workflows/script/helper.sh
Original file line number Diff line number Diff line change
@@ -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
41 changes: 28 additions & 13 deletions .github/workflows/script/solo_smoke_test.sh
Original file line number Diff line number Diff line change
@@ -11,14 +11,6 @@

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"
@@ -50,6 +42,17 @@
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"
@@ -83,17 +86,29 @@
return $result
}

echo "Restart port-forward"
task clean:port-forward
enable_port_forward


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

npm run solo-test -- relay deploy -n solo-e2e -i node1 --operator-key $OPERATOR_KEY --operator-id $OPERATOR_ID

Check warning on line 100 in .github/workflows/script/solo_smoke_test.sh

Codacy Production / Codacy Static Code Analysis

.github/workflows/script/solo_smoke_test.sh#L100

Double quote to prevent globbing and word splitting.
kubectl port-forward -n solo-e2e svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 &

else
task solo:relay
fi
cd -

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"
15 changes: 7 additions & 8 deletions Taskfile.helper.yml
Original file line number Diff line number Diff line change
@@ -221,9 +221,8 @@ tasks:
SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- node start --namespace "${SOLO_NAMESPACE}" --node-aliases-unparsed {{.node_identifiers}} ${DEBUG_NODE_FLAG} -q {{ .CLI_ARGS }} --dev
- |
if [[ "{{ .use_port_forwards }}" == "true" ]];then
echo "Enable port forwarding for Hedera Network Node"
echo "Port forwarding for Hedera Network Node: grpc:50211"
nohup kubectl port-forward -n "${SOLO_NAMESPACE}" pod/network-node1-0 50211:50211 < /dev/null > {{.temp_prefix}}-50211-nohup.out 2>&1 &
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 &"
sleep 4
fi

@@ -245,7 +244,7 @@ tasks:
- |
if [[ "{{ .use_port_forwards }}" == "true" ]];then
echo "Enable port forwarding for Hedera JSON RPC Relay"
nohup kubectl port-forward -n "${SOLO_NAMESPACE}" svc/relay-node1-hedera-json-rpc-relay 7546:7546 &
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/relay-node1-hedera-json-rpc-relay 7546:7546 > /dev/null 2>&1 &"
sleep 4
fi

@@ -257,7 +256,7 @@ tasks:
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 -q --dev
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- relay destroy -n "${SOLO_NAMESPACE}" -i node1 --dev

solo:cache:remove:
silent: true
@@ -426,10 +425,10 @@ tasks:
if [[ "{{ .use_port_forwards }}" == "true" ]];then
echo "Enable port forwarding for Hedera Explorer & Mirror Node Network"
echo "Port forwarding for Hedera Explorer: http://localhost:6789"
nohup kubectl port-forward -n "${SOLO_NAMESPACE}" svc/hedera-explorer 6789:80 < /dev/null > {{.temp_prefix}}-6789-nohup.out 2>&1 &
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/hedera-explorer 8080:80 > /dev/null 2>&1 &"
echo "Port forwarding for Mirror Node Network: grpc:5600, rest:5551"
nohup kubectl port-forward svc/mirror-grpc -n "${SOLO_NAMESPACE}" 5600:5600 < /dev/null > {{.temp_prefix}}-5600-nohup.out 2>&1 &
nohup kubectl port-forward svc/mirror-rest -n "${SOLO_NAMESPACE}" 5551:80 < /dev/null > {{.temp_prefix}}-5551-nohup.out 2>&1 &
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/mirror-grpc 5600:5600 > /dev/null 2>&1 &"
/bin/bash -c "nohup kubectl port-forward -n \"${SOLO_NAMESPACE}\" svc/mirror-rest 5551:80 > /dev/null 2>&1 &"
sleep 4
fi

@@ -442,7 +441,7 @@ tasks:
deps:
- task: "init"
cmds:
- SOLO_HOME_DIR=${SOLO_HOME_DIR} npm run solo -- mirror-node destroy --namespace "${SOLO_NAMESPACE}" --force -q --dev || 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

Unchanged files with check annotations Beta

super(opts);
if (!opts || !opts.accountManager)
throw new IllegalArgumentError('An instance of core/AccountManager is required', opts.accountManager as any);

Check warning on line 47 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
this.accountManager = opts.accountManager;
this.accountInfo = null;
try {
const privateKey = PrivateKey.fromStringDer(newAccountInfo.privateKey);
newAccountInfo.privateKeyRaw = privateKey.toStringRaw();
} catch (e: Error | any) {

Check warning on line 82 in src/commands/account.ts

GitHub Actions / Code Style / Standard

'e' is defined but never used

Check warning on line 82 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
this.logger.error(`failed to retrieve EVM address for accountId ${newAccountInfo.accountId}`);
}
}
return this.accountManager.accountInfoQuery(ctx.config.accountId);
}
async updateAccountInfo(ctx: any) {

Check warning on line 123 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
let amount = ctx.config.amount;
if (ctx.config.ed25519PrivateKey) {
if (
return await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, toAccountId, amount);
}
async init(argv: any) {

Check warning on line 159 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
const self = this;
interface Context {
{
title: 'Update special account key sets',
task: ctx => {
const subTasks: any[] = [];

Check warning on line 225 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
const realm = constants.HEDERA_NODE_ACCOUNT_ID_START.realm;
const shard = constants.HEDERA_NODE_ACCOUNT_ID_START.shard;
for (const currentSet of ctx.accountsBatchedSet) {
try {
await tasks.run();
} catch (e: Error | any) {

Check warning on line 299 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
throw new SoloError(`Error in creating account: ${e.message}`, e);
} finally {
await this.closeConnections();
return true;
}
async create(argv: any) {

Check warning on line 311 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
const self = this;
const lease = await self.leaseManager.create();
try {
await tasks.run();
} catch (e: Error | any) {

Check warning on line 387 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
throw new SoloError(`Error in creating account: ${e.message}`, e);
} finally {
await lease.release();
return true;
}
async update(argv: any) {

Check warning on line 397 in src/commands/account.ts

GitHub Actions / Code Style / Standard

Unexpected any. Specify a different type
const self = this;
interface Context {