Skip to content

Commit 6c707c9

Browse files
committed
Squashed commit of the following:
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]>
1 parent 3c3673a commit 6c707c9

17 files changed

+389
-127
lines changed

.madgerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"detectiveOptions": {
3+
"ts": {
4+
"skipTypeImports": true
5+
}
6+
}
7+
}

examples/performance-tuning/README.md

Whitespace-only changes.

src/commands/flags.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ export class Flags {
16451645
Flags.envoyIps,
16461646
Flags.generateEcdsaKey,
16471647
Flags.generateGossipKeys,
1648+
Flags.generateEcdsaKey,
16481649
Flags.generateTlsKeys,
16491650
Flags.gossipEndpoints,
16501651
Flags.gossipPrivateKey,
@@ -1665,6 +1666,7 @@ export class Flags {
16651666
Flags.namespace,
16661667
Flags.newAccountNumber,
16671668
Flags.newAdminKey,
1669+
Flags.createAmount,
16681670
Flags.nodeAlias,
16691671
Flags.nodeAliasesUnparsed,
16701672
Flags.operatorId,

src/commands/network.ts

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {ConsensusNodeComponent} from '../core/config/remote/components/consensus
3838
import {ConsensusNodeStates} from '../core/config/remote/enumerations.js';
3939
import {EnvoyProxyComponent} from '../core/config/remote/components/envoy_proxy_component.js';
4040
import {HaProxyComponent} from '../core/config/remote/components/ha_proxy_component.js';
41+
import {GenesisNetworkDataConstructor} from '../core/genesis_network_models/genesis_network_data_constructor.js';
4142

4243
export interface NetworkDeployConfigClass {
4344
applicationEnv: string;
@@ -61,6 +62,7 @@ export interface NetworkDeployConfigClass {
6162
grpcWebTlsCertificatePath: string;
6263
grpcTlsKeyPath: string;
6364
grpcWebTlsKeyPath: string;
65+
genesisNetworkData: GenesisNetworkDataConstructor;
6466
getUnusedConfigs: () => string[];
6567
haproxyIps: string;
6668
envoyIps: string;
@@ -130,20 +132,19 @@ export class NetworkCommand extends BaseCommand {
130132
];
131133
}
132134

133-
async prepareValuesArg(
134-
config: {
135-
chartDirectory?: string;
136-
app?: string;
137-
nodeAliases?: string[];
138-
debugNodeAlias?: NodeAlias;
139-
enablePrometheusSvcMonitor?: boolean;
140-
releaseTag?: string;
141-
persistentVolumeClaims?: string;
142-
valuesFile?: string;
143-
haproxyIpsParsed?: Record<NodeAlias, IP>;
144-
envoyIpsParsed?: Record<NodeAlias, IP>;
145-
} = {},
146-
) {
135+
async prepareValuesArg(config: {
136+
chartDirectory?: string;
137+
app?: string;
138+
nodeAliases: string[];
139+
debugNodeAlias?: NodeAlias;
140+
enablePrometheusSvcMonitor?: boolean;
141+
releaseTag?: string;
142+
persistentVolumeClaims?: string;
143+
valuesFile?: string;
144+
haproxyIpsParsed?: Record<NodeAlias, IP>;
145+
envoyIpsParsed?: Record<NodeAlias, IP>;
146+
genesisNetworkData: GenesisNetworkDataConstructor;
147+
}) {
147148
let valuesArg = config.chartDirectory
148149
? `-f ${path.join(config.chartDirectory, 'solo-deployment', 'values.yaml')}`
149150
: '';
@@ -160,7 +161,10 @@ export class NetworkCommand extends BaseCommand {
160161
}
161162

162163
const profileName = this.configManager.getFlag<string>(flags.profileName) as string;
163-
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(profileName);
164+
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(
165+
profileName,
166+
config.genesisNetworkData,
167+
);
164168
if (this.profileValuesFile) {
165169
valuesArg += this.prepareValuesFiles(this.profileValuesFile);
166170
}
@@ -172,7 +176,7 @@ export class NetworkCommand extends BaseCommand {
172176

173177
// Iterate over each node and set static IPs for HAProxy
174178
if (config.haproxyIpsParsed) {
175-
config.nodeAliases?.forEach((nodeAlias, index) => {
179+
config.nodeAliases.forEach((nodeAlias, index) => {
176180
const ip = config.haproxyIpsParsed?.[nodeAlias];
177181

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

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

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

256-
config.valuesArg = await this.prepareValuesArg(config);
257-
258260
// compute other config parameters
259261
config.keysDir = path.join(validatePath(config.cacheDir), 'keys');
260262
config.stagingDir = Templates.renderStagingDir(config.cacheDir, config.releaseTag);
261263
config.stagingKeysDir = path.join(validatePath(config.stagingDir), 'keys');
262264

265+
config.genesisNetworkData = await GenesisNetworkDataConstructor.initialize(
266+
config.nodeAliases,
267+
this.keyManager,
268+
config.keysDir,
269+
);
270+
271+
config.valuesArg = await this.prepareValuesArg(config);
272+
263273
if (!(await this.k8.hasNamespace(config.namespace))) {
264274
await this.k8.createNamespace(config.namespace);
265275
}
@@ -341,7 +351,7 @@ export class NetworkCommand extends BaseCommand {
341351
},
342352
{
343353
title: 'Check if cluster setup chart is installed',
344-
task: async (ctx, task) => {
354+
task: async () => {
345355
const isChartInstalled = await this.chartManager.isChartInstalled('', constants.SOLO_CLUSTER_SETUP_CHART);
346356
if (!isChartInstalled) {
347357
throw new SoloError(
@@ -386,7 +396,7 @@ export class NetworkCommand extends BaseCommand {
386396
task: (ctx, parentTask) => {
387397
const config = ctx.config;
388398

389-
// set up the sub-tasks
399+
// set up the subtasks
390400
return parentTask.newListr(self.platformInstaller.copyNodeKeys(config.stagingDir, config.nodeAliases), {
391401
concurrent: true,
392402
rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION,
@@ -502,7 +512,7 @@ export class NetworkCommand extends BaseCommand {
502512
),
503513
});
504514

505-
// set up the sub-tasks
515+
// set up the subtasks
506516
return task.newListr(subTasks, {
507517
concurrent: false, // no need to run concurrently since if one node is up, the rest should be up by then
508518
rendererOptions: {
@@ -754,6 +764,7 @@ export class NetworkCommand extends BaseCommand {
754764
},
755765
};
756766
}
767+
757768
/** Adds the consensus node, envoy and haproxy components to remote config. */
758769
public addNodesAndProxies(): ListrTask<any, any, any> {
759770
return {

src/commands/node/configs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import path from 'path';
2424
import fs from 'fs';
2525
import {validatePath} from '../../core/helpers.js';
2626
import {Flags as flags} from '../flags.js';
27-
import {type NodeAlias, type NodeAliases, type PodName} from '../../types/aliases.js';
28-
import {type NetworkNodeServices} from '../../core/network_node_services.js';
27+
import type {NodeAlias, NodeAliases, PodName} from '../../types/aliases.js';
28+
import type {NetworkNodeServices} from '../../core/network_node_services.js';
2929

3030
export const PREPARE_UPGRADE_CONFIGS_NAME = 'prepareUpgradeConfig';
3131
export const DOWNLOAD_GENERATED_FILES_CONFIGS_NAME = 'downloadGeneratedFilesConfig';

src/commands/node/tasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ export class NodeCommandTasks {
455455
*/
456456
_generateGossipKeys(generateMultiple: boolean) {
457457
const self = this;
458+
458459
return new Task(
459460
'Generate gossip keys',
460461
(ctx: any, task: ListrTaskWrapper<any, any, any>) => {
@@ -701,7 +702,7 @@ export class NodeCommandTasks {
701702
config.stagingDir,
702703
);
703704

704-
// if directory data/upgrade/current/data/keys does not exist then use data/upgrade/current
705+
// if directory data/upgrade/current/data/keys does not exist, then use data/upgrade/current
705706
let keyDir = `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/data/keys`;
706707
if (!(await self.k8.hasDir(nodeFullyQualifiedPodName, constants.ROOT_CONTAINER, keyDir))) {
707708
keyDir = `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`;

src/core/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export const RELAY_PODS_RUNNING_MAX_ATTEMPTS = +process.env.RELAY_PODS_RUNNING_M
196196
export const RELAY_PODS_RUNNING_DELAY = +process.env.RELAY_PODS_RUNNING_DELAY || 1_000;
197197
export const RELAY_PODS_READY_MAX_ATTEMPTS = +process.env.RELAY_PODS_READY_MAX_ATTEMPTS || 100;
198198
export const RELAY_PODS_READY_DELAY = +process.env.RELAY_PODS_READY_DELAY || 1_000;
199+
export const GRPC_PORT = +process.env.GRPC_PORT || 50_211;
199200

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Copyright (C) 2024 Hedera Hashgraph, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the ""License"");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an ""AS IS"" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
import crypto from 'node:crypto';
18+
import {PrivateKey} from '@hashgraph/sdk';
19+
import {Templates} from '../templates.js';
20+
import {GenesisNetworkNodeDataWrapper} from './genesis_network_node_data_wrapper.js';
21+
import * as x509 from '@peculiar/x509';
22+
import * as constants from '../constants.js';
23+
24+
import type {KeyManager} from '../key_manager.js';
25+
import type {ToJSON} from '../../types/index.js';
26+
import type {JsonString, NodeAlias, NodeAliases} from '../../types/aliases.js';
27+
28+
/**
29+
* Used to construct the nodes data and convert them to JSON
30+
*/
31+
export class GenesisNetworkDataConstructor implements ToJSON {
32+
public readonly nodes: Record<NodeAlias, GenesisNetworkNodeDataWrapper> = {};
33+
34+
private constructor(
35+
private readonly nodeAliases: NodeAliases,
36+
private readonly keyManager: KeyManager,
37+
private readonly keysDir: string,
38+
) {
39+
nodeAliases.forEach((nodeAlias, nodeId) => {
40+
// TODO: get nodeId from label in pod.
41+
const adminPrivateKey = PrivateKey.fromStringED25519(constants.GENESIS_KEY);
42+
const adminPubKey = adminPrivateKey.publicKey;
43+
44+
this.nodes[nodeAlias] = new GenesisNetworkNodeDataWrapper(nodeId, adminPubKey, nodeAlias);
45+
});
46+
}
47+
48+
public static async initialize(
49+
nodeAliases: NodeAliases,
50+
keyManager: KeyManager,
51+
keysDir: string,
52+
): Promise<GenesisNetworkDataConstructor> {
53+
const instance = new GenesisNetworkDataConstructor(nodeAliases, keyManager, keysDir);
54+
55+
await instance.load();
56+
57+
return instance;
58+
}
59+
60+
/**
61+
* Loads the gossipCaCertificate and grpcCertificateHash
62+
*/
63+
private async load() {
64+
await Promise.all(
65+
this.nodeAliases.map(async nodeAlias => {
66+
const nodeKeys = await this.keyManager.loadSigningKey(nodeAlias, this.keysDir);
67+
68+
//* Convert the certificate to PEM format
69+
const certPem = nodeKeys.certificate.toString();
70+
71+
//* Assign the PEM certificate
72+
this.nodes[nodeAlias].gossipCaCertificate = nodeKeys.certificate.toString('base64');
73+
74+
//* Decode the PEM to DER format
75+
const tlsCertDer = new Uint8Array(x509.PemConverter.decode(certPem)[0]);
76+
77+
//* Generate the SHA-384 hash
78+
this.nodes[nodeAlias].grpcCertificateHash = crypto.createHash('sha384').update(tlsCertDer).digest('base64');
79+
}),
80+
);
81+
}
82+
83+
public toJSON(): JsonString {
84+
return JSON.stringify({nodeMetadata: Object.values(this.nodes).map(node => node.toObject())});
85+
}
86+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright (C) 2024 Hedera Hashgraph, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the ""License"");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an ""AS IS"" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
import type {AccountId, PublicKey} from '@hashgraph/sdk';
18+
import type {GenesisNetworkNodeStructure, ServiceEndpoint, ToObject} from '../../types/index.js';
19+
20+
export class GenesisNetworkNodeDataWrapper
21+
implements GenesisNetworkNodeStructure, ToObject<{node: GenesisNetworkNodeStructure}>
22+
{
23+
public accountId: AccountId;
24+
public gossipEndpoint: ServiceEndpoint[] = [];
25+
public serviceEndpoint: ServiceEndpoint[] = [];
26+
public gossipCaCertificate: string;
27+
public grpcCertificateHash: string;
28+
public weight: number;
29+
public readonly deleted = false;
30+
31+
constructor(
32+
public readonly nodeId: number,
33+
public readonly adminKey: PublicKey,
34+
public readonly description: string,
35+
) {}
36+
37+
/**
38+
* @param domainName - a fully qualified domain name
39+
* @param port
40+
*/
41+
public addServiceEndpoint(domainName: string, port: number): void {
42+
this.serviceEndpoint.push({domainName, port, ipAddressV4: ''});
43+
}
44+
45+
/**
46+
* @param domainName - a fully qualified domain name
47+
* @param port
48+
*/
49+
public addGossipEndpoint(domainName: string, port: number): void {
50+
this.gossipEndpoint.push({domainName, port, ipAddressV4: ''});
51+
}
52+
53+
public toObject() {
54+
return {
55+
node: {
56+
nodeId: this.nodeId,
57+
accountId: this.accountId,
58+
description: this.description,
59+
gossipEndpoint: this.gossipEndpoint,
60+
serviceEndpoint: this.serviceEndpoint,
61+
gossipCaCertificate: this.gossipCaCertificate,
62+
grpcCertificateHash: this.grpcCertificateHash,
63+
weight: this.weight,
64+
deleted: this.deleted,
65+
adminKey: this.adminKey,
66+
},
67+
};
68+
}
69+
}

src/core/helpers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {type NodeAlias, type NodeAliases} from '../types/aliases.js';
2727
import {type CommandFlag} from '../types/flag_types.js';
2828
import {type SoloLogger} from './logging.js';
2929
import {type Duration} from './time/duration.js';
30+
import {type NodeAddConfigClass} from '../commands/node/configs.js';
3031

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

244-
const config = /** @type {NodeAddConfigClass} **/ ctx.config;
245+
const config = ctx.config as NodeAddConfigClass;
245246
const exportedFields = ['tlsCertHash', 'upgradeZipHash', 'newNode'];
246247

247248
exportedCtx.signingCertDer = ctx.signingCertDer.toString();
248249
exportedCtx.gossipEndpoints = ctx.gossipEndpoints.map((ep: any) => `${ep.getDomainName}:${ep.getPort}`);
249250
exportedCtx.grpcServiceEndpoints = ctx.grpcServiceEndpoints.map((ep: any) => `${ep.getDomainName}:${ep.getPort}`);
250251
exportedCtx.adminKey = ctx.adminKey.toString();
252+
// @ts-ignore
251253
exportedCtx.existingNodeAliases = config.existingNodeAliases;
252254

253255
for (const prop of exportedFields) {
@@ -308,16 +310,14 @@ export function prepareEndpoints(endpointType: string, endpoints: string[], defa
308310
if (endpointType.toUpperCase() === constants.ENDPOINT_TYPE_IP) {
309311
ret.push(
310312
new ServiceEndpoint({
311-
// @ts-ignore
312-
port,
313+
port: +port,
313314
ipAddressV4: parseIpAddressToUint8Array(url),
314315
}),
315316
);
316317
} else {
317318
ret.push(
318319
new ServiceEndpoint({
319-
// @ts-ignore
320-
port,
320+
port: +port,
321321
domainName: url,
322322
}),
323323
);

0 commit comments

Comments
 (0)