Skip to content

Commit

Permalink
feat(cli): implement node setup command (#491)
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <[email protected]>
  • Loading branch information
leninmehedy authored Nov 9, 2023
1 parent 5948113 commit 7920cb6
Show file tree
Hide file tree
Showing 42 changed files with 1,895 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
run: |
npm i
npm test
npm run test-e2e
# npm run test-e2e # tracked by #https://github.com/hashgraph/full-stack-testing/issues/501

# This step tests the Helm chart direct mode of operation which uses the ubi8-init-java17 image.
- name: Helm Chart Test (Direct Install)
Expand Down
4 changes: 2 additions & 2 deletions dev/gateway-api/fst-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ spec:
listeners:
- name: http-debug
protocol: HTTP
port: 80
port: 3100
- name: tcp-debug
protocol: TCP
port: 9000
port: 3101
allowedRoutes:
kinds:
- kind: TCPRoute
Expand Down
38 changes: 14 additions & 24 deletions fullstack-network-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,6 @@ fullstack-network-manager is a CLI tool to manage and deploy a Hedera Network us
- Run `fsnetman` from a terminal as shown below
```
❯ fsnetman
Usage: fsnetman <command> [options]
Commands:
fsnetman init Initialize local environment
fsnetman cluster Manager FST cluster
Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Select a command
```
## Develop
- In order to support ES6 modules with `jest`, set an env variable `export NODE_OPTIONS=--experimental-vm-modules >> ~/.zshrc`
- If you are using Intellij and would like to use debugger tools, you will need to enable `--experimental-vm-modules` for `Jest`.
- `Run->Edit Configurations->Edit Configuration Templates->Jest` and then set `--experimental-vm-modules` in `Node Options`.
- Run `npm i` to install the required packages
- Run `npm link` to install `fsnetman` as the CLI (you need to do it once)
- Run `npm test` or `npm run test` to run the unit tests
- Run `npm run test-e2e` to run the long-running integration tests
- Run `npm run fsnetman` to access the CLI as shown below:
```
❯ npm run fsnetman
Usage:
fsnetman <command> [options]
Expand All @@ -49,6 +26,19 @@ Options:
-v, --version Show version number [boolean]
Select a command
```

## Develop
- In order to support ES6 modules with `jest`, set an env variable `export NODE_OPTIONS=--experimental-vm-modules >> ~/.zshrc`
- If you are using Intellij and would like to use debugger tools, you will need to enable `--experimental-vm-modules` for `Jest`.
- `Run->Edit Configurations->Edit Configuration Templates->Jest` and then set `--experimental-vm-modules` in `Node Options`.
- Run `npm i` to install the required packages
- Run `npm link` to install `fsnetman` as the CLI
- Note: you need to do it once. If `fsnetman` already exists in your path, you will need to remove it first.
- Alternative way would be to run `npm run fsnetman -- <COMMAND> <ARGS>`
- Run `npm test` or `npm run test` to run the unit tests
- Run `npm run test-e2e` to run the long-running integration tests
- Run `fsnetman` to access the CLI as shown above.
- Note that debug logs are stored at `~/.fsnetman/logs/fst.log`. So you may use `tail -f ~/.fsnetman/logs/fst.log | jq
` in a separate terminal to keep an eye on the logs.

9 changes: 9 additions & 0 deletions fullstack-network-manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fullstack-network-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"author": "Lenin Mehedy",
"license": "Apache2.0",
"dependencies": {
"adm-zip": "^0.5.10",
"chalk": "^5.3.0",
"esm": "^3.2.25",
"figlet": "^1.6.0",
Expand Down
62 changes: 62 additions & 0 deletions fullstack-network-manager/resources/templates/config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# ======================================================================================================================
# Address book Format Description
# ======================================================================================================================
# Address book format varies across versions since it evolved over time. As of July 27, 2023 the below formats were
# relevant for recent versions. Latest version is available in the file: hedera-services/hedera-node/config.txt
#
# - v.0.39.* (or before) format:
# Fields: address, <NODE_ID>, <NODE_NAME>, <NODE_STAKE_AMOUNT>, <INTERNAL_IP>, <INTERNAL_GOSSIP_PORT>, <EXTERNAL_IP>, <EXTERNAL_GOSSIP_PORT>, <ACCOUNT_ID>
# Example: address, 0, node0, 1, 10.128.0.27, 50111, 35.223.93.31, 30124, 0.0.3
#
# - v.0.4* format:
# Fields: address, <NODE_ID>, <NODE_NICK_NAME>, <NODE_NAME>, <NODE_STAKE_AMOUNT>, <INTERNAL_IP>, <INTERNAL_GOSSIP_PORT>, <EXTERNAL_IP>, <EXTERNAL_GOSSIP_PORT>, <ACCOUNT_ID>
# Example: address, 0, n0, node0, 1, 10.128.0.27, 50111, 35.223.93.31, 30124, 0.0.3
#
# - v.0.41* (onward) we need to append the below formatted line with next node ID after the list of "address" lines
# <address book lines>
# nextNodeId, <NEXT_NODE_ID>
#
# Field descriptions:
# ===========================
# NODE_ID: This increments for each node and starts from 0.
# NEXT_NODE_ID: The id for the next node (i.e. last node ID + 1)
# NODE_NICK_NAME: This is a string (alphanumeric). e.g. node0
# NODE_NAME: This is a string (alphanumeric). e.g. node0 or n0
# NODE_STAKE_AMOUNT: A long value. e.g. 1 or a larger number
# INTERNAL_IP: This is the pod IP
# INTERNAL_GOSSIP_PORT: Default gossip port is 50111. So use the exposed port that is mapped to 50111 in container.
# EXTERNAL_IP: This is the service IP
# EXTERNAL_GOSSIP_PORT: Default gossip port is 50111. This is usually same as INTERNAL_GOSSIP_PORT unless mapped differently.
# ACCOUNT_ID: Must start from 0.0.3
#

# Account restrictions:
# ===========================
# All ACCOUNT_ID should start from 0.0.3 because of restricted accounts as below:
# - 0.0.0 restricted and not usable
# - 0.0.1 minting account and not usable
# - 0.0.2 treasury account
#
# Default Ports
# ===========================
# We only need to specify the gossip port (INTERNAL_GOSSIP_PORT, EXTERNAL_GOSSIP_PORT). Below are some details on other
# ports that a node may expose:
# - 50111: gossip port
# - 50211: grpc non-tls (for platform services)
# - 50212: grpc tls (for platform services)
#
# IP Address
# ===========================
# When deploying in a kubernetes cluster, we need to use the following IP mapping:
# - INTERNAL_IP: This should be the Pod IP exposing gossip port (i.e. 50111)
# - EXTERNAL_IP: This should be the cluster IP of the service exposing gossip port (i.e. 50111)
#
#
# Example config.txt (for v0.4* onward)
# ===========================
# swirld, 123
# app, HederaNode.jar
# address, 0, node0, node0, 1, 10.244.0.197, 56789, 10.96.61.84, 50111, 0.0.0
# address, 1, node1, node1, 1, 10.244.0.198, 56789, 10.96.163.93, 50111, 0.0.1
# nextNodeId, 2
# ======================================================================================================================
52 changes: 52 additions & 0 deletions fullstack-network-manager/resources/templates/hedera.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDd8OHe3OmcPVTI
OlSDgBac2yRnD9br2O+jhCDVPKRwC8/8PFko816qXLti/Y4Csuu8OBQC6KFxU8mK
G05RYJpuCsW78h8mSUSb7P1HMmS8O4+7VSSLM4i9xJaGizH82oOOQpjdbGJwZdeN
thSChkR//A4BpyFr1jipZB5vc8Vk6GFV2+NrbBK4ooOxmrVFIZiI690uC9exKmTb
QnDeFE1z3pcCww+JbFFMBGF77ppz67HFaBnLJBGTygRyg8kmkAkN23d9COTTzZCH
y79a8O/beiRbCb83XIbB31JVT8d38KW8EojxzRRSYDLUR94BHdCBUL+XwtmfMf7a
wjS/4xYSvtknUQfLdbkuzmEyHafEQlScEsx81Yt6izd/d7b9AYqn7JPkdbUt6J6P
YMw5Lh9AOTKCyj3dMNGybE+qYEmHqkOJggX/HREA54qQuaBtL2yzDzQrjm5y8WaN
mNGLotWIY1+zpvRinhHUgokhtnonRqwWOsyWpzOfLLfIsdzGFJHmTu+EOA2WyuWe
+vdGXQz7CZQh41QccPIq+O6Ny5/RwSsykpcYH1gSOt5aAK+WRlDWnWTZbF48bWgw
FH9veArQF3RQx+7Swmt3hTpzgHerKc9ovUtbSIF6XuXYzIHl5N/QVhyOZtE3gyAj
0XhiBfS4L4Vyx2sr5CPlpjsJVsUBaQIDAQABAoICABkN+Uupy/AEvvJTHmkRb8wR
k56UW854aRYgI347CDOza611iRmtvq80B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