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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -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
Expand All @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/script/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/script/solo_smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,19 @@ function start_sdk_test ()
return $result
}


# if first parameter equals to ACCOUNT_INIT,
# 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
fi

task solo:mirror-node
task solo:relay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible I would like to validate that the monitor/pinger functionality is active and running correctly


echo "Change to parent directory"

cd ../
create_test_account
clone_smart_contract_repo
Expand Down
8 changes: 6 additions & 2 deletions docs/content/User/StepByStepGuide.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

```
Expand All @@ -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 <a> Attach <ctr… ____ __.________
Cluster: kind-solo <ctrl-d> Delete <l> | |/ _/ __ \______
Expand All @@ -75,7 +77,6 @@ You may now view pods in your cluster using `k9s -A` as below:
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```


### Step by Step Instructions

* Initialize `solo` directories:
Expand Down Expand Up @@ -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

```
Expand Down
14 changes: 11 additions & 3 deletions examples/address-book/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 <solo-root>/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 <solo-root>/examples/address-book
task update:ledger:addressbook
```

To get the address book from the mirror node, run the following command:

```bash
cd <solo-root>/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 <solo-root>
npm run solo -- account create
Expand Down
17 changes: 16 additions & 1 deletion src/commands/mirror_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -263,9 +264,23 @@
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}`;
ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${constants.OPERATOR_KEY}`;

// get operatorKey from k8s secret since it could have been changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can use an SDK to change the key, and then the one in the secrets would be invalid.

if the user supplied the operator key, use that
else if the secret exist, use that
else use genesis

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}`;
} else {
const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey);
ctx.config.valuesArg += ` --set monitor.config.hedera.mirror.monitor.operator.privateKey=${operatorKeyFromK8}`;
}

Check warning on line 283 in src/commands/mirror_node.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/mirror_node.ts#L281-L283

Added lines #L281 - L283 were not covered by tests
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/commands/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -109,8 +110,13 @@
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}`]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user can use an SDK to change the key, and then the one in the secrets would be invalid.

if the user supplied the operator key, use that
else if the secret exist, use that
else use genesis

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}`;
} else {
const operatorKeyFromK8 = Base64.decode(secrets[0].data.privateKey);
valuesArg += ` --set config.OPERATOR_KEY_MAIN=${operatorKeyFromK8}`;

Check warning on line 119 in src/commands/relay.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/relay.ts#L118-L119

Added lines #L118 - L119 were not covered by tests
}

if (!nodeAliases) {
Expand Down
Loading