diff --git a/src/commands/network.ts b/src/commands/network.ts index aa12ce566..487db3ad3 100644 --- a/src/commands/network.ts +++ b/src/commands/network.ts @@ -169,6 +169,11 @@ export class NetworkCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile); } + const genesisNetworkDataFile = await this.profileManager.prepareValuesForGenesisNetwork(config.genesisNetworkData); + if (genesisNetworkDataFile) { + valuesArg += this.prepareValuesFiles(genesisNetworkDataFile); + } + // do not deploy mirror node until after we have the updated address book valuesArg += ` --set "telemetry.prometheus.svcMonitor.enabled=${config.enablePrometheusSvcMonitor}"`; diff --git a/src/core/profile_manager.ts b/src/core/profile_manager.ts index 4e133546c..8f0f56eeb 100644 --- a/src/core/profile_manager.ts +++ b/src/core/profile_manager.ts @@ -30,8 +30,9 @@ import * as helpers from './helpers.js'; import {getNodeAccountMap} from './helpers.js'; import type {SemVer} from 'semver'; import type {SoloLogger} from './logging.js'; -import type {AnyObject, NodeAlias, NodeAliases, Path} from '../types/aliases.js'; +import type {AnyObject, DirPath, NodeAlias, NodeAliases, Path} from '../types/aliases.js'; import type {GenesisNetworkDataConstructor} from './models/genesisNetworkDataConstructor.js'; +import type {Optional} from '../types/index.js'; const consensusSidecars = [ 'recordStreamUploader', @@ -44,12 +45,12 @@ const consensusSidecars = [ export class ProfileManager { private readonly logger: SoloLogger; private readonly configManager: ConfigManager; - private readonly cacheDir: string; + private readonly cacheDir: DirPath; private profiles: Map; - private profileFile: string | undefined; + private profileFile: Optional; - constructor(logger: SoloLogger, configManager: ConfigManager, cacheDir = constants.SOLO_VALUES_DIR) { + constructor(logger: SoloLogger, configManager: ConfigManager, cacheDir: DirPath = constants.SOLO_VALUES_DIR) { if (!logger) throw new MissingArgumentError('An instance of core/SoloLogger is required'); if (!configManager) throw new MissingArgumentError('An instance of core/ConfigManager is required'); @@ -176,7 +177,7 @@ export class ProfileManager { for (const key in dotItems) { let itemKey = key; - // if it is an array key like extraEnv[0].JAVA_OPTS, convert it into dot separated key as extraEnv.0.JAVA_OPTS + // if it is an array key like extraEnv[0].JAVA_OPTS, convert it into a dot separated key as extraEnv.0.JAVA_OPTS if (key.indexOf('[') !== -1) { itemKey = key.replace('[', '.').replace(']', ''); } @@ -370,10 +371,13 @@ export class ProfileManager { return this.writeToYaml(cachedValuesFile, yamlRoot); } - public setValueForGenesisNetwork(path: string) { + public prepareValuesForGenesisNetwork(genesisNetworkData: GenesisNetworkDataConstructor): Promise { const yamlRoot = {}; - this._setFileContentsAsValue('hedera.configMaps.genesisNetworkJson', path, yamlRoot); + this._setValue('hedera.configMaps.genesisNetworkJson', genesisNetworkData.toJSON(), yamlRoot); + + const cachedValuesFile = path.join(this.cacheDir, 'genesis-network.yaml'); + return this.writeToYaml(cachedValuesFile, yamlRoot); } /** @@ -484,12 +488,15 @@ export class ProfileManager { chainId = constants.HEDERA_CHAIN_ID, genesisNetworkData?: GenesisNetworkDataConstructor, ) { - if (!nodeAccountMap || nodeAccountMap.size === 0) + if (!nodeAccountMap || nodeAccountMap.size === 0) { throw new MissingArgumentError('nodeAccountMap the map of node IDs to account IDs is required'); + } + if (!releaseTag) throw new MissingArgumentError('release tag is required'); - if (!fs.existsSync(destPath)) + if (!fs.existsSync(destPath)) { throw new IllegalArgumentError(`config destPath does not exist: ${destPath}`, destPath); + } // init variables const internalPort = +constants.HEDERA_NODE_INTERNAL_GOSSIP_PORT; @@ -516,11 +523,11 @@ export class ProfileManager { nodeDataWrapper.weight = nodeStakeAmount; nodeDataWrapper.accountId = account; - // Add gossip endpoints + //? Add gossip endpoints nodeDataWrapper.addGossipEndpoint(externalIP, externalPort); nodeDataWrapper.addGossipEndpoint(internalIP, internalPort); - // Add service endpoints + //? Add service endpoints nodeDataWrapper.addServiceEndpoint(internalIP, internalPort); } diff --git a/src/types/aliases.ts b/src/types/aliases.ts index ef38efa3b..00aac962d 100644 --- a/src/types/aliases.ts +++ b/src/types/aliases.ts @@ -46,5 +46,7 @@ export type IP = string; export type JsonString = string; export type Path = string; +export type FilePath = string; +export type DirPath = string; export type AnyObject = Record;