Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 6b8ada1
Author: instamenta <[email protected]>
Date:   Fri Dec 20 16:55:18 2024 +0200

    fixing the nodeSequence, switched to haproxy fQDN for the service endpoint and new version of the solo-charts

    Signed-off-by: instamenta <[email protected]>

commit bcdef8b
Merge: 847cd45 861c579
Author: instamenta <[email protected]>
Date:   Fri Dec 20 12:15:25 2024 +0200

    Merge remote-tracking branch 'origin/main' into 00949-production-readiness-dynamically-construct-the-genesis-networkjson-and-add-it-to-the-values-file-to-be-used-during-network-deploy

commit 847cd45
Author: instamenta <[email protected]>
Date:   Fri Dec 20 09:33:54 2024 +0200

    renamed the GenesisNetowrkNodeDataWrapper filename to follow convention

    Signed-off-by: instamenta <[email protected]>

commit 861c579
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Dec 19 11:06:35 2024 -0600

    chore(deps-dev): bump globals from 15.13.0 to 15.14.0 (#1007)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit e80bda8
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Dec 19 11:06:22 2024 -0600

    chore(deps): bump chalk from 5.3.0 to 5.4.0 (#1008)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit f4b49aa
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Dec 19 10:47:50 2024 -0600

    chore(deps): bump @hashgraph/sdk from 2.55.1 to 2.56.0 (#1009)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit c9711c5
Author: Ivo Yankov <[email protected]>
Date:   Thu Dec 19 18:47:03 2024 +0200

    feat: update `solo context connect` to connect to single remote cluster (#993)

    Signed-off-by: Ivo Yankov <[email protected]>

commit c91b8ab
Author: instamenta <[email protected]>
Date:   Thu Dec 19 17:04:11 2024 +0200

    add mock to fix failing unit test

    Signed-off-by: instamenta <[email protected]>

commit 7c63989
Author: instamenta <[email protected]>
Date:   Thu Dec 19 16:43:31 2024 +0200

    updated package-lock.jsonn

    Signed-off-by: instamenta <[email protected]>

commit c06e32a
Merge: 7a3ef9d 043efcf
Author: instamenta <[email protected]>
Date:   Thu Dec 19 16:42:31 2024 +0200

    Merge remote-tracking branch 'origin/main' into 00949-production-readiness-dynamically-construct-the-genesis-networkjson-and-add-it-to-the-values-file-to-be-used-during-network-deploy

commit 7a3ef9d
Author: instamenta <[email protected]>
Date:   Thu Dec 19 16:35:01 2024 +0200

    bump up the solo-charts version

    Signed-off-by: instamenta <[email protected]>

commit 043efcf
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Dec 18 16:56:19 2024 -0600

    chore(deps): bump actions/upload-artifact from 4.4.3 to 4.5.0 (#1002)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 8115945
Author: Pranali Deshmukh <[email protected]>
Date:   Thu Dec 19 00:55:58 2024 +0200

    docs(README): Updated the "Install Solo" section. (#1004)

    Signed-off-by: Pranali Deshmukh <[email protected]>

commit 01ed969
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Dec 18 11:19:09 2024 -0600

    chore(deps): bump actions/setup-java from 4.5.0 to 4.6.0 (#1003)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 23238fc
Merge: 1e30538 a4ef700
Author: instamenta <[email protected]>
Date:   Wed Dec 18 09:50:20 2024 +0200

    Merge remote-tracking branch 'origin/main' into 00949-production-readiness-dynamically-construct-the-genesis-networkjson-and-add-it-to-the-values-file-to-be-used-during-network-deploy

commit 1e30538
Author: instamenta <[email protected]>
Date:   Wed Dec 18 09:50:13 2024 +0200

    fix type of the grpc cert hash to be digested to base64 and conditional logic to not break tests

    Signed-off-by: instamenta <[email protected]>

commit a4ef700
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 17 07:35:39 2024 -0600

    chore(deps-dev): bump typescript-eslint from 8.18.0 to 8.18.1 (#996)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 4dfbf2f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 17 07:35:19 2024 -0600

    chore(deps-dev): bump @typescript-eslint/utils from 8.18.0 to 8.18.1 (#997)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit b82610a
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 17 07:11:27 2024 -0600

    chore(deps): bump jfrog/setup-jfrog-cli from 4.5.1 to 4.5.2 (#995)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 0b2326b
Author: instamenta <[email protected]>
Date:   Mon Dec 16 19:16:58 2024 +0200

    changes to the genesis-network.json constructor that resolve the error's while parsing the json inside the node root containerpull

    Signed-off-by: instamenta <[email protected]>

commit 7ec2527
Merge: 2887510 a5fab1e
Author: instamenta <[email protected]>
Date:   Mon Dec 16 19:16:41 2024 +0200

    Merge remote-tracking branch 'origin/main' into 00949-production-readiness-dynamically-construct-the-genesis-networkjson-and-add-it-to-the-values-file-to-be-used-during-network-deploy

commit a5fab1e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Dec 16 07:22:14 2024 -0600

    chore(deps): bump helm/kind-action from 1.10.0 to 1.11.0 (#992)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 72a6433
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Dec 16 07:14:47 2024 -0600

    chore(deps-dev): bump @eslint/js from 9.16.0 to 9.17.0 (#989)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 41d079f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Dec 16 07:13:53 2024 -0600

    chore(deps-dev): bump eslint from 9.16.0 to 9.17.0 (#990)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit c3a693c
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Dec 16 07:13:26 2024 -0600

    chore(deps-dev): bump typedoc from 0.27.4 to 0.27.5 (#991)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 2887510
Author: instamenta <[email protected]>
Date:   Mon Dec 16 12:49:29 2024 +0200

    dont use string but AccountId for the genesis-network.json constructor

    Signed-off-by: instamenta <[email protected]>

commit f4c3cc7
Merge: d1020c4 8e4fe04
Author: instamenta <[email protected]>
Date:   Mon Dec 16 09:20:45 2024 +0200

    merge with main

    Signed-off-by: instamenta <[email protected]>

commit 8e4fe04
Author: JeffreyDallas <[email protected]>
Date:   Sat Dec 14 02:48:33 2024 -0600

    fix: document typo (#988)

    Signed-off-by: Jeffrey Tang <[email protected]>

commit 06e6026
Author: Jeromy Cannon <[email protected]>
Date:   Fri Dec 13 15:25:37 2024 +0000

    refactor: added http status code enums/library (#987)

    Signed-off-by: Jeromy Cannon <[email protected]>

commit d1020c4
Author: instamenta <[email protected]>
Date:   Fri Dec 13 17:12:53 2024 +0200

    fixes

    Signed-off-by: instamenta <[email protected]>

commit 79410f0
Author: JeffreyDallas <[email protected]>
Date:   Fri Dec 13 07:36:52 2024 -0600

    feat: add solo smoke test to test flow (#905)

    Signed-off-by: Jeffrey Tang <[email protected]>
    Signed-off-by: Jeromy Cannon <[email protected]>
    Co-authored-by: Jeromy Cannon <[email protected]>

commit a13e9db
Author: instamenta <[email protected]>
Date:   Fri Dec 13 15:32:31 2024 +0200

    bump the charts version

    Signed-off-by: instamenta <[email protected]>

commit 4f0b286
Author: instamenta <[email protected]>
Date:   Fri Dec 13 14:36:57 2024 +0200

    remove unused params

    Signed-off-by: instamenta <[email protected]>

commit 3361081
Author: instamenta <[email protected]>
Date:   Fri Dec 13 14:14:53 2024 +0200

    renamed models to follow snake_case convention

    Signed-off-by: instamenta <[email protected]>

commit d6ae342
Merge: 4bfd998 b378937
Author: instamenta <[email protected]>
Date:   Fri Dec 13 12:42:15 2024 +0200

    merge with main

    Signed-off-by: instamenta <[email protected]>

commit 4bfd998
Author: instamenta <[email protected]>
Date:   Thu Dec 12 22:44:04 2024 +0200

    added logic for setting the value file

    Signed-off-by: instamenta <[email protected]>

commit 59b156c
Author: instamenta <[email protected]>
Date:   Thu Dec 12 21:35:49 2024 +0200

    polishing and cleaning up the profile_manager, adding comments, aliases and keeping it D.R.Y.

    Signed-off-by: instamenta <[email protected]>

commit b378937
Author: JeffreyDallas <[email protected]>
Date:   Thu Dec 12 12:58:46 2024 -0600

    feat: Update document (#956)

    Signed-off-by: Jeffrey Tang <[email protected]>

commit 58e96e1
Author: JeffreyDallas <[email protected]>
Date:   Thu Dec 12 12:56:41 2024 -0600

    fix: local chart directory not being taken correctly (#983)

    Signed-off-by: Jeffrey Tang <[email protected]>

commit 437bbc6
Author: Jeromy Cannon <[email protected]>
Date:   Thu Dec 12 18:26:55 2024 +0000

    fix: performance improvements for node stop (#986)

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 83fb584
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Dec 12 08:53:01 2024 -0600

    chore(deps): bump @hashgraph/sdk from 2.55.0 to 2.55.1 (#984)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 9cae011
Author: Jeromy Cannon <[email protected]>
Date:   Thu Dec 12 14:52:36 2024 +0000

    fix: bump chart and hedera version,  re-enable node add (#985)

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 45c69a0
Author: instamenta <[email protected]>
Date:   Thu Dec 12 16:40:40 2024 +0200

    changed version

    Signed-off-by: instamenta <[email protected]>

commit 75964fc
Author: instamenta <[email protected]>
Date:   Thu Dec 12 15:56:46 2024 +0200

    finishing up, and fixes

    Signed-off-by: instamenta <[email protected]>

commit dac6d6d
Author: instamenta <[email protected]>
Date:   Thu Dec 12 14:05:36 2024 +0200

    lint-fix, added .madgerc and configured it to dont count typed imports as circular dependencies

    Signed-off-by: instamenta <[email protected]>

commit 1a29c82
Author: instamenta <[email protected]>
Date:   Thu Dec 12 11:59:16 2024 +0200

    polishing new classes added new interfaces and aliases to make clarify what they do

    Signed-off-by: instamenta <[email protected]>

commit 74285bf
Author: Ivo Yankov <[email protected]>
Date:   Thu Dec 12 11:08:39 2024 +0200

    fix: node update with single node (#981)

    Signed-off-by: Ivo Yankov <[email protected]>

commit d6b823a
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Dec 11 12:07:16 2024 -0600

    chore(deps-dev): bump @types/node from 22.10.1 to 22.10.2 (#980)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 3e3cdd9
Author: instamenta <[email protected]>
Date:   Wed Dec 11 18:50:55 2024 +0200

    updating data wrapper properties

    Signed-off-by: instamenta <[email protected]>

commit f2760fd
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Dec 11 09:04:35 2024 -0600

    chore(deps-dev): bump c8 from 10.1.2 to 10.1.3 (#979)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 1948c26
Author: instamenta <[email protected]>
Date:   Wed Dec 11 16:27:19 2024 +0200

    wiring

    Signed-off-by: instamenta <[email protected]>

commit 7b11550
Author: instamenta <[email protected]>
Date:   Wed Dec 11 16:09:08 2024 +0200

    remove obsolete comments

    Signed-off-by: instamenta <[email protected]>

commit d965c12
Author: instamenta <[email protected]>
Date:   Wed Dec 11 16:04:28 2024 +0200

    lemove obsolete comments

    Signed-off-by: instamenta <[email protected]>

commit 26f9341
Author: instamenta <[email protected]>
Date:   Wed Dec 11 16:01:14 2024 +0200

    cleanup

    Signed-off-by: instamenta <[email protected]>

commit 5a62289
Author: instamenta <[email protected]>
Date:   Wed Dec 11 15:42:13 2024 +0200

    changes from other branch

    Signed-off-by: instamenta <[email protected]>

Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Dec 23, 2024
1 parent a4e5cd8 commit b598e9e
Show file tree
Hide file tree
Showing 17 changed files with 389 additions and 127 deletions.
7 changes: 7 additions & 0 deletions .madgerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
Empty file.
2 changes: 2 additions & 0 deletions src/commands/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ export class Flags {
Flags.envoyIps,
Flags.generateEcdsaKey,
Flags.generateGossipKeys,
Flags.generateEcdsaKey,
Flags.generateTlsKeys,
Flags.gossipEndpoints,
Flags.gossipPrivateKey,
Expand All @@ -1665,6 +1666,7 @@ export class Flags {
Flags.namespace,
Flags.newAccountNumber,
Flags.newAdminKey,
Flags.createAmount,
Flags.nodeAlias,
Flags.nodeAliasesUnparsed,
Flags.operatorId,
Expand Down
55 changes: 33 additions & 22 deletions src/commands/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {ConsensusNodeComponent} from '../core/config/remote/components/consensus
import {ConsensusNodeStates} from '../core/config/remote/enumerations.js';
import {EnvoyProxyComponent} from '../core/config/remote/components/envoy_proxy_component.js';
import {HaProxyComponent} from '../core/config/remote/components/ha_proxy_component.js';
import {GenesisNetworkDataConstructor} from '../core/genesis_network_models/genesis_network_data_constructor.js';

export interface NetworkDeployConfigClass {
applicationEnv: string;
Expand All @@ -61,6 +62,7 @@ export interface NetworkDeployConfigClass {
grpcWebTlsCertificatePath: string;
grpcTlsKeyPath: string;
grpcWebTlsKeyPath: string;
genesisNetworkData: GenesisNetworkDataConstructor;
getUnusedConfigs: () => string[];
haproxyIps: string;
envoyIps: string;
Expand Down Expand Up @@ -130,20 +132,19 @@ export class NetworkCommand extends BaseCommand {
];
}

async prepareValuesArg(
config: {
chartDirectory?: string;
app?: string;
nodeAliases?: string[];
debugNodeAlias?: NodeAlias;
enablePrometheusSvcMonitor?: boolean;
releaseTag?: string;
persistentVolumeClaims?: string;
valuesFile?: string;
haproxyIpsParsed?: Record<NodeAlias, IP>;
envoyIpsParsed?: Record<NodeAlias, IP>;
} = {},
) {
async prepareValuesArg(config: {
chartDirectory?: string;
app?: string;
nodeAliases: string[];
debugNodeAlias?: NodeAlias;
enablePrometheusSvcMonitor?: boolean;
releaseTag?: string;
persistentVolumeClaims?: string;
valuesFile?: string;
haproxyIpsParsed?: Record<NodeAlias, IP>;
envoyIpsParsed?: Record<NodeAlias, IP>;
genesisNetworkData: GenesisNetworkDataConstructor;
}) {
let valuesArg = config.chartDirectory
? `-f ${path.join(config.chartDirectory, 'solo-deployment', 'values.yaml')}`
: '';
Expand All @@ -160,7 +161,10 @@ export class NetworkCommand extends BaseCommand {
}

const profileName = this.configManager.getFlag<string>(flags.profileName) as string;
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(profileName);
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(
profileName,
config.genesisNetworkData,
);
if (this.profileValuesFile) {
valuesArg += this.prepareValuesFiles(this.profileValuesFile);
}
Expand All @@ -172,7 +176,7 @@ export class NetworkCommand extends BaseCommand {

// Iterate over each node and set static IPs for HAProxy
if (config.haproxyIpsParsed) {
config.nodeAliases?.forEach((nodeAlias, index) => {
config.nodeAliases.forEach((nodeAlias, index) => {
const ip = config.haproxyIpsParsed?.[nodeAlias];

if (ip) valuesArg += ` --set "hedera.nodes[${index}].haproxyStaticIP=${ip}"`;
Expand All @@ -181,7 +185,7 @@ export class NetworkCommand extends BaseCommand {

// Iterate over each node and set static IPs for Envoy Proxy
if (config.envoyIpsParsed) {
config.nodeAliases?.forEach((nodeAlias, index) => {
config.nodeAliases.forEach((nodeAlias, index) => {
const ip = config.envoyIpsParsed?.[nodeAlias];

if (ip) valuesArg += ` --set "hedera.nodes[${index}].envoyProxyStaticIP=${ip}"`;
Expand Down Expand Up @@ -253,13 +257,19 @@ export class NetworkCommand extends BaseCommand {
constants.SOLO_DEPLOYMENT_CHART,
);

config.valuesArg = await this.prepareValuesArg(config);

// compute other config parameters
config.keysDir = path.join(validatePath(config.cacheDir), 'keys');
config.stagingDir = Templates.renderStagingDir(config.cacheDir, config.releaseTag);
config.stagingKeysDir = path.join(validatePath(config.stagingDir), 'keys');

config.genesisNetworkData = await GenesisNetworkDataConstructor.initialize(
config.nodeAliases,
this.keyManager,
config.keysDir,
);

config.valuesArg = await this.prepareValuesArg(config);

if (!(await this.k8.hasNamespace(config.namespace))) {
await this.k8.createNamespace(config.namespace);
}
Expand Down Expand Up @@ -341,7 +351,7 @@ export class NetworkCommand extends BaseCommand {
},
{
title: 'Check if cluster setup chart is installed',
task: async (ctx, task) => {
task: async () => {
const isChartInstalled = await this.chartManager.isChartInstalled('', constants.SOLO_CLUSTER_SETUP_CHART);
if (!isChartInstalled) {
throw new SoloError(
Expand Down Expand Up @@ -386,7 +396,7 @@ export class NetworkCommand extends BaseCommand {
task: (ctx, parentTask) => {
const config = ctx.config;

// set up the sub-tasks
// set up the subtasks
return parentTask.newListr(self.platformInstaller.copyNodeKeys(config.stagingDir, config.nodeAliases), {
concurrent: true,
rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION,
Expand Down Expand Up @@ -502,7 +512,7 @@ export class NetworkCommand extends BaseCommand {
),
});

// set up the sub-tasks
// set up the subtasks
return task.newListr(subTasks, {
concurrent: false, // no need to run concurrently since if one node is up, the rest should be up by then
rendererOptions: {
Expand Down Expand Up @@ -754,6 +764,7 @@ export class NetworkCommand extends BaseCommand {
},
};
}

/** Adds the consensus node, envoy and haproxy components to remote config. */
public addNodesAndProxies(): ListrTask<any, any, any> {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/node/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import path from 'path';
import fs from 'fs';
import {validatePath} from '../../core/helpers.js';
import {Flags as flags} from '../flags.js';
import {type NodeAlias, type NodeAliases, type PodName} from '../../types/aliases.js';
import {type NetworkNodeServices} from '../../core/network_node_services.js';
import type {NodeAlias, NodeAliases, PodName} from '../../types/aliases.js';
import type {NetworkNodeServices} from '../../core/network_node_services.js';

export const PREPARE_UPGRADE_CONFIGS_NAME = 'prepareUpgradeConfig';
export const DOWNLOAD_GENERATED_FILES_CONFIGS_NAME = 'downloadGeneratedFilesConfig';
Expand Down
3 changes: 2 additions & 1 deletion src/commands/node/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ export class NodeCommandTasks {
*/
_generateGossipKeys(generateMultiple: boolean) {
const self = this;

return new Task(
'Generate gossip keys',
(ctx: any, task: ListrTaskWrapper<any, any, any>) => {
Expand Down Expand Up @@ -701,7 +702,7 @@ export class NodeCommandTasks {
config.stagingDir,
);

// if directory data/upgrade/current/data/keys does not exist then use data/upgrade/current
// if directory data/upgrade/current/data/keys does not exist, then use data/upgrade/current
let keyDir = `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/data/keys`;
if (!(await self.k8.hasDir(nodeFullyQualifiedPodName, constants.ROOT_CONTAINER, keyDir))) {
keyDir = `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`;
Expand Down
1 change: 1 addition & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export const RELAY_PODS_RUNNING_MAX_ATTEMPTS = +process.env.RELAY_PODS_RUNNING_M
export const RELAY_PODS_RUNNING_DELAY = +process.env.RELAY_PODS_RUNNING_DELAY || 1_000;
export const RELAY_PODS_READY_MAX_ATTEMPTS = +process.env.RELAY_PODS_READY_MAX_ATTEMPTS || 100;
export const RELAY_PODS_READY_DELAY = +process.env.RELAY_PODS_READY_DELAY || 1_000;
export const GRPC_PORT = +process.env.GRPC_PORT || 50_211;

export const NETWORK_DESTROY_WAIT_TIMEOUT = +process.env.NETWORK_DESTROY_WAIT_TIMEOUT || 120;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the ""License"");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an ""AS IS"" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import crypto from 'node:crypto';
import {PrivateKey} from '@hashgraph/sdk';
import {Templates} from '../templates.js';
import {GenesisNetworkNodeDataWrapper} from './genesis_network_node_data_wrapper.js';
import * as x509 from '@peculiar/x509';
import * as constants from '../constants.js';

import type {KeyManager} from '../key_manager.js';
import type {ToJSON} from '../../types/index.js';
import type {JsonString, NodeAlias, NodeAliases} from '../../types/aliases.js';

/**
* Used to construct the nodes data and convert them to JSON
*/
export class GenesisNetworkDataConstructor implements ToJSON {
public readonly nodes: Record<NodeAlias, GenesisNetworkNodeDataWrapper> = {};

private constructor(
private readonly nodeAliases: NodeAliases,
private readonly keyManager: KeyManager,
private readonly keysDir: string,
) {
nodeAliases.forEach((nodeAlias, nodeId) => {
// TODO: get nodeId from label in pod.
const adminPrivateKey = PrivateKey.fromStringED25519(constants.GENESIS_KEY);
const adminPubKey = adminPrivateKey.publicKey;

this.nodes[nodeAlias] = new GenesisNetworkNodeDataWrapper(nodeId, adminPubKey, nodeAlias);
});
}

public static async initialize(
nodeAliases: NodeAliases,
keyManager: KeyManager,
keysDir: string,
): Promise<GenesisNetworkDataConstructor> {
const instance = new GenesisNetworkDataConstructor(nodeAliases, keyManager, keysDir);

await instance.load();

return instance;
}

/**
* Loads the gossipCaCertificate and grpcCertificateHash
*/
private async load() {
await Promise.all(
this.nodeAliases.map(async nodeAlias => {
const nodeKeys = await this.keyManager.loadSigningKey(nodeAlias, this.keysDir);

//* Convert the certificate to PEM format
const certPem = nodeKeys.certificate.toString();

//* Assign the PEM certificate
this.nodes[nodeAlias].gossipCaCertificate = nodeKeys.certificate.toString('base64');

//* Decode the PEM to DER format
const tlsCertDer = new Uint8Array(x509.PemConverter.decode(certPem)[0]);

//* Generate the SHA-384 hash
this.nodes[nodeAlias].grpcCertificateHash = crypto.createHash('sha384').update(tlsCertDer).digest('base64');
}),
);
}

public toJSON(): JsonString {
return JSON.stringify({nodeMetadata: Object.values(this.nodes).map(node => node.toObject())});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the ""License"");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an ""AS IS"" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import type {AccountId, PublicKey} from '@hashgraph/sdk';
import type {GenesisNetworkNodeStructure, ServiceEndpoint, ToObject} from '../../types/index.js';

export class GenesisNetworkNodeDataWrapper
implements GenesisNetworkNodeStructure, ToObject<{node: GenesisNetworkNodeStructure}>
{
public accountId: AccountId;
public gossipEndpoint: ServiceEndpoint[] = [];
public serviceEndpoint: ServiceEndpoint[] = [];
public gossipCaCertificate: string;
public grpcCertificateHash: string;
public weight: number;
public readonly deleted = false;

constructor(
public readonly nodeId: number,
public readonly adminKey: PublicKey,
public readonly description: string,
) {}

/**
* @param domainName - a fully qualified domain name
* @param port
*/
public addServiceEndpoint(domainName: string, port: number): void {
this.serviceEndpoint.push({domainName, port, ipAddressV4: ''});
}

/**
* @param domainName - a fully qualified domain name
* @param port
*/
public addGossipEndpoint(domainName: string, port: number): void {
this.gossipEndpoint.push({domainName, port, ipAddressV4: ''});
}

public toObject() {
return {
node: {
nodeId: this.nodeId,
accountId: this.accountId,
description: this.description,
gossipEndpoint: this.gossipEndpoint,
serviceEndpoint: this.serviceEndpoint,
gossipCaCertificate: this.gossipCaCertificate,
grpcCertificateHash: this.grpcCertificateHash,
weight: this.weight,
deleted: this.deleted,
adminKey: this.adminKey,
},
};
}
}
10 changes: 5 additions & 5 deletions src/core/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {type NodeAlias, type NodeAliases} from '../types/aliases.js';
import {type CommandFlag} from '../types/flag_types.js';
import {type SoloLogger} from './logging.js';
import {type Duration} from './time/duration.js';
import {type NodeAddConfigClass} from '../commands/node/configs.js';

export function sleep(duration: Duration) {
return new Promise<void>(resolve => {
Expand Down Expand Up @@ -241,13 +242,14 @@ export function addDebugOptions(valuesArg: string, debugNodeAlias: NodeAlias, in
export function addSaveContextParser(ctx: any) {
const exportedCtx = {} as Record<string, string>;

const config = /** @type {NodeAddConfigClass} **/ ctx.config;
const config = ctx.config as NodeAddConfigClass;
const exportedFields = ['tlsCertHash', 'upgradeZipHash', 'newNode'];

exportedCtx.signingCertDer = ctx.signingCertDer.toString();
exportedCtx.gossipEndpoints = ctx.gossipEndpoints.map((ep: any) => `${ep.getDomainName}:${ep.getPort}`);
exportedCtx.grpcServiceEndpoints = ctx.grpcServiceEndpoints.map((ep: any) => `${ep.getDomainName}:${ep.getPort}`);
exportedCtx.adminKey = ctx.adminKey.toString();
// @ts-ignore
exportedCtx.existingNodeAliases = config.existingNodeAliases;

for (const prop of exportedFields) {
Expand Down Expand Up @@ -308,16 +310,14 @@ export function prepareEndpoints(endpointType: string, endpoints: string[], defa
if (endpointType.toUpperCase() === constants.ENDPOINT_TYPE_IP) {
ret.push(
new ServiceEndpoint({
// @ts-ignore
port,
port: +port,
ipAddressV4: parseIpAddressToUint8Array(url),
}),
);
} else {
ret.push(
new ServiceEndpoint({
// @ts-ignore
port,
port: +port,
domainName: url,
}),
);
Expand Down
Loading

0 comments on commit b598e9e

Please sign in to comment.