Skip to content

Commit

Permalink
feat(cli): generate Gossip keys and gRPC TLS keys in PEM format (#629)
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <[email protected]>
  • Loading branch information
leninmehedy authored Feb 1, 2024
1 parent 74c6ca6 commit d970796
Show file tree
Hide file tree
Showing 46 changed files with 2,285 additions and 547 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/zxc-solo-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ on:
type: string
required: false
default: "18"
java-distribution:
description: "Java JDK Distribution:"
type: string
required: false
default: "temurin"
java-version:
description: "Java JDK Version:"
type: string
required: false
default: "21.0.1"

defaults:
run:
Expand Down Expand Up @@ -80,6 +90,13 @@ jobs:
# the fetch depth defaults to only the commit that triggered the workflow unless the spotless check was enabled
fetch-depth: ${{ inputs.enable-spotless-check && '0' || '' }}

- name: Setup Java
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
if: ${{ !inputs.enable-nodejs-tests && !cancelled() && !failure() }}
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}

- name: Setup Node
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
if: ${{ steps.check-changed-files.outputs.run-tests && !cancelled() && !failure() }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -516,3 +516,6 @@ charts/deleteme.yaml
node_modules
solo/coverage
dev/resources/nmt/version.properties
solo/test/scripts/backup
fullstack-network-manager/test/data/tmp
*.pfx
1 change: 1 addition & 0 deletions docker/ubi8-init-java21/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ENV JAVA_HOME /usr/local/java
ENV PATH ${JAVA_HOME}/bin:${PATH}

# Define Application Environment Variables
ENV APP_HOME="/opt/hgcapp/services-hedera/HapiApp2.0"
ENV JAVA_HEAP_MIN=""
ENV JAVA_HEAP_MAX=""
ENV JAVA_OPTS=""
Expand Down
12 changes: 8 additions & 4 deletions docker/ubi8-init-java21/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

set -eo pipefail

SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "${SCRIPT_PATH}" || exit 64
if [[ -z "${APP_HOME}" ]]; then
echo "ERROR: APP_HOME is not defined, but is required!"
exit 63
fi

cd "${APP_HOME}" || exit 64

if [[ -z "${JAVA_OPTS}" ]]; then
JAVA_OPTS=""
Expand Down Expand Up @@ -55,8 +59,8 @@ fi
LOG_DIR_NAME="${LOG_DIR_NAME:-output}"

# Ensure the log directory exists
if [[ ! -d "${SCRIPT_PATH}/${LOG_DIR_NAME}" ]]; then
mkdir -p "${SCRIPT_PATH}/${LOG_DIR_NAME}"
if [[ ! -d "${APP_HOME}/${LOG_DIR_NAME}" ]]; then
mkdir -p "${APP_HOME}/${LOG_DIR_NAME}"
fi

cat <<EOF
Expand Down
56 changes: 49 additions & 7 deletions solo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

An opinionated CLI tool to deploy and manage private Hedera Networks.

## Requirements

* Node(^18.19.0)
* Helm(^3.14.0)
* Kubectl(^1.28.2)
* Helpful tools (Optional):
* [`k9s`](https://k9scli.io/)
* [`kubectx`](https://github.com/ahmetb/kubectx)

## Install

* Run `npm install -g @hashgraph/solo`

* Ensure you have a valid kubernetes context, cluster and namespace. You may use `kind` and `kubectl` CLIs to create
cluster and namespace as below (See [`test/e2e/setup-e2e.sh`](test/e2e/setup_e2e.sh)):
cluster and namespace as below:

```
export SOLO_CLUSTER_NAME=solo-local
export SOLO_NAMESPACE=solo-local
kind create cluster -n "${SOLO_CLUSTER_NAME}"
kubectl create ns "${SOLO_NAMESPACE}"
solo init -d ../charts --namespace "${SOLO_NAMESPACE}" # cache args for subsequent commands
export SOLO_NAMESPACE=solo # use a namespace that suits you
kind create cluster
kubectl create ns "${SOLO_NAMESPACE}"
```

* Run `solo` from a terminal, It may show usage options as shown below:
Expand Down Expand Up @@ -46,6 +53,16 @@ Options:
Select a command
```

* Deploy private Hedera network in your existing cluster and namespace

```
solo init -n "${SOLO_NAMESPACE}" # cache args for subsequent commands
solo cluster setup
solo network deploy
solo node setup
solo node start
```

## Develop

* In order to support ES6 modules with `jest`, set an env
Expand All @@ -60,7 +77,7 @@ Select a command
* Alternative way would be to run `npm run solo -- <COMMAND> <ARGS>`
* Run `npm test` or `npm run test` to run the unit tests
* Run `solo` to access the CLI as shown above.
* Note that debug logs are stored at `~/.solo/logs/solo.log`. So you may use `tail -f ~/.solo/logs/solo.log | jq
* Note that debug logs are stored at `$HOME/.solo/logs/solo.log`. So you may use `tail -f $HOME/.solo/logs/solo.log | jq
` in a separate terminal to keep an eye on the logs.
* Before making a commit run `npm run format`

Expand All @@ -69,3 +86,28 @@ Select a command
* In order to run E2E test, we need to set up cluster and install the chart.
* Run `./test/e2e/setup-e2e.sh`
* Run `npm run test-e2e`

## Node Keys

### Standard keys (.pem file)

`solo` is able to generate standard `PEM` formatted keys for nodes. You may
run `solo node keys --gossip-keys --tls-keys`
command to generate the required keys.

### Legacy keys (.pfx file)

`solo` is not able to generate legacy `PFX` formatted gossip keys. However, you may use the
script [test/scripts/gen-legacy-keys](test/scripts/gen-legacy-keys.sh).
For example, if `curl`, `keytool` and `openssl` are installed on the machine, you may run the following command to
generate the pfx formatted gossip keys in the default
cache directory (`$HOME/.solo/cache/keys`):

```
# Option - 1: Generate keys for default node IDs: node0,node1,node2,node3
/bin/bash -c "${curl -fsSL https://raw.githubusercontent.com/hashgraph/solo/main/test/scripts/gen-legacy-keys.sh)"
# Option - 2: Generate keys for custom node IDs
curl -o gen-legacy-keys.sh https://raw.githubusercontent.com/hashgraph/solo/main/test/scripts/gen-legacy-keys.sh
./legacy-key-generation.sh alice,bob,carol
```
165 changes: 165 additions & 0 deletions solo/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 solo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@hashgraph/sdk": "^2.40.0",
"@kubernetes/client-node": "^0.20.0",
"@listr2/prompt-adapter-enquirer": "^1.0.2",
"@peculiar/x509": "^1.9.5",
"adm-zip": "^0.5.10",
"chalk": "^5.3.0",
"dotenv": "^16.3.1",
Expand Down
Loading

0 comments on commit d970796

Please sign in to comment.