Skip to content

Commit

Permalink
fix: update the address book and perform helm upgrade to fix mirror n…
Browse files Browse the repository at this point in the history
…ode importer (#52)

Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon authored Feb 23, 2024
1 parent b7e60c1 commit 26e2e8f
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 36 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ jobs:
if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }}
run: npm run test-e2e

- name: Upload E2E Logs to GitHub
if: ${{ inputs.enable-e2e-tests && !cancelled() }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: solo.log
path: ~/.solo/logs/solo.log
overwrite: true
if-no-files-found: error

- name: Publish E2E Test Report
uses: EnricoMi/publish-unit-test-result-action@8885e273a4343cd7b48eaa72428dea0c3067ea98 # v2.14.0
if: ${{ inputs.enable-e2e-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
Expand Down
9 changes: 6 additions & 3 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"author": "Swirlds Labs",
"license": "Apache2.0",
"dependencies": {
"@hashgraph/proto": "^2.14.0-beta.3",
"@hashgraph/sdk": "^2.41.0",
"@kubernetes/client-node": "^0.20.0",
"@listr2/prompt-adapter-enquirer": "^2.0.2",
Expand All @@ -37,6 +38,7 @@
"figlet": "^1.7.0",
"got": "^14.2.0",
"inquirer": "^9.2.15",
"js-base64": "^3.7.6",
"listr2": "^8.0.2",
"tar": "^6.2.0",
"uuid": "^9.0.1",
Expand All @@ -46,6 +48,7 @@
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@jest/test-sequencer": "^29.7.0",
"eslint": "^8.56.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-headers": "^1.1.2",
Expand Down
22 changes: 4 additions & 18 deletions src/commands/account.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,10 @@ export class AccountCommand extends BaseCommand {
const serviceMap = await this.accountManager.getNodeServiceMap(ctx.config.namespace)

ctx.nodeClient = await this.accountManager.getNodeClient(ctx.config.namespace,
serviceMap, ctx.treasuryAccountId, ctx.treasuryPrivateKey)
serviceMap, ctx.treasuryAccountInfo.accountId, ctx.treasuryAccountInfo.privateKey)
this.nodeClient = ctx.nodeClient // store in class so that we can make sure connections are closed
}

async loadTreasuryAccount (ctx) {
ctx.treasuryAccountId = constants.TREASURY_ACCOUNT_ID
// check to see if the treasure account is in the secrets
const accountInfo = await this.accountManager.getAccountKeysFromSecret(ctx.treasuryAccountId, ctx.config.namespace)

// if it isn't in the secrets we can load genesis key
if (accountInfo) {
ctx.treasuryPrivateKey = accountInfo.privateKey
} else {
ctx.treasuryPrivateKey = constants.GENESIS_KEY
}
}

async getAccountInfo (ctx) {
return this.accountManager.accountInfoQuery(ctx.config.accountId, ctx.nodeClient)
}
Expand All @@ -101,7 +88,6 @@ export class AccountCommand extends BaseCommand {
this.logger.error(`failed to update account keys for accountId ${ctx.accountInfo.accountId}`)
return false
}
this.logger.debug(`sent account key update for account ${ctx.accountInfo.accountId}`)
} else {
amount = amount || flags.amount.definition.defaultValue
}
Expand Down Expand Up @@ -156,7 +142,7 @@ export class AccountCommand extends BaseCommand {

self.logger.debug('Initialized config', { config })

await self.loadTreasuryAccount(ctx)
ctx.treasuryAccountInfo = await self.accountManager.getTreasuryAccountKeys(ctx.config.namespace)
await self.loadNodeClient(ctx)
}
},
Expand Down Expand Up @@ -219,7 +205,7 @@ export class AccountCommand extends BaseCommand {
{
title: 'get the account info',
task: async (ctx, task) => {
await self.loadTreasuryAccount(ctx)
ctx.treasuryAccountInfo = await self.accountManager.getTreasuryAccountKeys(ctx.config.namespace)
await self.loadNodeClient(ctx)
ctx.accountInfo = await self.buildAccountInfo(await self.getAccountInfo(ctx), ctx.config.namespace, ctx.config.privateKey)
}
Expand Down Expand Up @@ -286,7 +272,7 @@ export class AccountCommand extends BaseCommand {
{
title: 'get the account info',
task: async (ctx, task) => {
await self.loadTreasuryAccount(ctx)
ctx.treasuryAccountInfo = await self.accountManager.getTreasuryAccountKeys(ctx.config.namespace)
await self.loadNodeClient(ctx)
self.accountInfo = await self.buildAccountInfo(await self.getAccountInfo(ctx), ctx.config.namespace, false)
this.logger.showJSON('account info', self.accountInfo)
Expand Down
4 changes: 3 additions & 1 deletion src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export class NetworkCommand extends BaseCommand {

valuesArg += this.prepareValuesFiles(config.valuesFile)

valuesArg += ` --set hedera-mirror-node.enabled=${config.deployMirrorNode} --set hedera-explorer.enabled=${config.deployHederaExplorer}`
// do not deploy mirror node until after we have the updated address book
valuesArg += ' --set hedera-mirror-node.enabled=false --set hedera-explorer.enabled=false'

valuesArg += ` --set telemetry.prometheus.svcMonitor.enabled=${config.enablePrometheusSvcMonitor}`

if (config.enableHederaExplorerTls) {
Expand Down
82 changes: 80 additions & 2 deletions src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -419,16 +419,29 @@ export class NodeCommand extends BaseCommand {
self.configManager.update(argv)
await prompts.execute(task, self.configManager, [
flags.namespace,
flags.chartDirectory,
flags.fstChartVersion,
flags.nodeIDs,
flags.deployHederaExplorer,
flags.deployMirrorNode,
flags.updateAccountKeys
])

ctx.config = {
namespace: self.configManager.getFlag(flags.namespace),
chartDir: this.configManager.getFlag(flags.chartDirectory),
fstChartVersion: this.configManager.getFlag(flags.fstChartVersion),
nodeIds: helpers.parseNodeIDs(self.configManager.getFlag(flags.nodeIDs)),
deployMirrorNode: this.configManager.getFlag(flags.deployMirrorNode),
deployHederaExplorer: this.configManager.getFlag(flags.deployHederaExplorer),
updateAccountKeys: self.configManager.getFlag(flags.updateAccountKeys)
}

ctx.config.chartPath = await this.prepareChartPath(ctx.config.chartDir,
constants.FULLSTACK_TESTING_CHART, constants.FULLSTACK_DEPLOYMENT_CHART)

ctx.config.valuesArg = ` --set hedera-mirror-node.enabled=${ctx.config.deployMirrorNode} --set hedera-explorer.enabled=${ctx.config.deployHederaExplorer}`

if (!await this.k8.hasNamespace(ctx.config.namespace)) {
throw new FullstackTestingError(`namespace ${ctx.config.namespace} does not exist`)
}
Expand Down Expand Up @@ -483,6 +496,36 @@ export class NodeCommand extends BaseCommand {
})
}
},
{
title: 'Enable mirror node',
task: async (ctx, parentTask) => {
const subTasks = [
{
title: 'Get the mirror node importer address book',
task: async (ctx, _) => {
ctx.addressBook = await self.getAddressBook(ctx.config.namespace)
ctx.config.valuesArg += ` --set "hedera-mirror-node.importer.addressBook=${ctx.addressBook}"`
}
},
{
title: `Upgrade chart '${constants.FULLSTACK_DEPLOYMENT_CHART}'`,
task: async (ctx, _) => {
await this.chartManager.upgrade(
ctx.config.namespace,
constants.FULLSTACK_DEPLOYMENT_CHART,
ctx.config.chartPath,
ctx.config.valuesArg
)
}
}
]

return parentTask.newListr(subTasks, {
concurrent: false,
rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION
})
}
},
{
title: 'Update special account keys',
task: async (ctx, task) => {
Expand All @@ -493,8 +536,17 @@ export class NodeCommand extends BaseCommand {
'skipping special account keys update, special accounts will retain genesis private keys'))
}
}
}
], {
},
{
title: 'Waiting for explorer pod to be ready',
task: async (ctx, _) => {
if (ctx.config.deployHederaExplorer) {
await this.k8.waitForPod(constants.POD_STATUS_RUNNING, [
'app.kubernetes.io/component=hedera-explorer', 'app.kubernetes.io/name=hedera-explorer'
], 1)
}
}
}], {
concurrent: false,
rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION
})
Expand All @@ -508,6 +560,32 @@ export class NodeCommand extends BaseCommand {
return true
}

/**
* Will get the address book from the network (base64 encoded)
* @param namespace
* @returns {Promise<string>} the base64 encoded address book for the network
*/
async getAddressBook (namespace) {
const treasuryAccountInfo = await this.accountManager.getTreasuryAccountKeys(namespace)
const serviceMap = await this.accountManager.getNodeServiceMap(namespace)

const nodeClient = await this.accountManager.getNodeClient(namespace,
serviceMap, treasuryAccountInfo.accountId, treasuryAccountInfo.privateKey)

try {
// Retrieve the AddressBook as base64
return await this.accountManager.prepareAddressBookBase64(nodeClient)
} catch (e) {
throw new FullstackTestingError('an error was encountered while trying to prepare the address book')
} finally {
await this.accountManager.stopPortForwards()
if (nodeClient) {
nodeClient.close()
}
await sleep(5) // sleep a few ticks to allow network connections to close
}
}

async stop (argv) {
const self = this

Expand Down
Loading

0 comments on commit 26e2e8f

Please sign in to comment.