@constellation-network/node-pilot 0.13.1-testnet → 0.14.0-intnet

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @constellation-network/node-pilot
21
21
  $ cpilot COMMAND
22
22
  running command...
23
23
  $ cpilot (--version|-v)
24
- @constellation-network/node-pilot/0.13.1-testnet darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.14.0-intnet darwin-arm64 node-v22.15.0
25
25
  $ cpilot --help [COMMAND]
26
26
  USAGE
27
27
  $ cpilot COMMAND
@@ -72,7 +72,7 @@ EXAMPLES
72
72
  $ cpilot clean
73
73
  ```
74
74
 
75
- _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/clean.ts)_
75
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/clean.ts)_
76
76
 
77
77
  ## `cpilot config`
78
78
 
@@ -89,7 +89,7 @@ EXAMPLES
89
89
  $ cpilot config
90
90
  ```
91
91
 
92
- _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/config.ts)_
92
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/config.ts)_
93
93
 
94
94
  ## `cpilot config get [NAME]`
95
95
 
@@ -113,7 +113,7 @@ EXAMPLES
113
113
  $ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
114
114
  ```
115
115
 
116
- _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/config/get.ts)_
116
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/config/get.ts)_
117
117
 
118
118
  ## `cpilot config set NAME VALUE`
119
119
 
@@ -136,7 +136,7 @@ EXAMPLES
136
136
  $ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
137
137
  ```
138
138
 
139
- _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/config/set.ts)_
139
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/config/set.ts)_
140
140
 
141
141
  ## `cpilot help [COMMAND]`
142
142
 
@@ -173,7 +173,7 @@ EXAMPLES
173
173
  $ cpilot info
174
174
  ```
175
175
 
176
- _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/info.ts)_
176
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/info.ts)_
177
177
 
178
178
  ## `cpilot logs LAYER`
179
179
 
@@ -199,7 +199,7 @@ EXAMPLES
199
199
  $ cpilot logs
200
200
  ```
201
201
 
202
- _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/logs.ts)_
202
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/logs.ts)_
203
203
 
204
204
  ## `cpilot restart [LAYER]`
205
205
 
@@ -227,7 +227,7 @@ EXAMPLES
227
227
  $ cpilot restart
228
228
  ```
229
229
 
230
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/restart.ts)_
230
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/restart.ts)_
231
231
 
232
232
  ## `cpilot shutdown`
233
233
 
@@ -244,7 +244,7 @@ EXAMPLES
244
244
  $ cpilot shutdown
245
245
  ```
246
246
 
247
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/shutdown.ts)_
247
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/shutdown.ts)_
248
248
 
249
249
  ## `cpilot status`
250
250
 
@@ -258,7 +258,7 @@ DESCRIPTION
258
258
  Display node status and configuration settings
259
259
  ```
260
260
 
261
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/status.ts)_
261
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/status.ts)_
262
262
 
263
263
  ## `cpilot uninstall`
264
264
 
@@ -275,5 +275,5 @@ EXAMPLES
275
275
  $ cpilot uninstall
276
276
  ```
277
277
 
278
- _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.1-testnet/src/commands/uninstall.ts)_
278
+ _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.14.0-intnet/src/commands/uninstall.ts)_
279
279
  <!-- commandsstop -->
@@ -24,17 +24,19 @@ export const checkDependencies = async () => {
24
24
  const pilotDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../..`);
25
25
  const hasInstallScript = fs.existsSync(path.join(pilotDir, 'install-dependencies.sh'));
26
26
  if (isDockerInstalled) {
27
- const user = os.userInfo().username;
28
- clm.preStep(`Checking if user ${user} has been added to the docker group...`);
29
- const groups = await shellService.runCommandWithOutput('groups');
30
- if (groups.includes('docker')) {
31
- clm.postStep('✅ User has already been added');
32
- }
33
- else {
34
- await shellService.runCommand(`sudo usermod -aG docker ${user}`);
35
- clm.postStep(`\n✅ Added user "${user}" to the docker group`);
36
- clm.warn('\nPlease logout and login again in order for the group changes take effect.\n');
37
- process.exit(0);
27
+ if (os.platform() === 'linux') {
28
+ const user = os.userInfo().username;
29
+ clm.preStep(`Checking if user ${user} has been added to the docker group...`);
30
+ const groups = await shellService.runCommandWithOutput('groups');
31
+ if (groups.includes('docker')) {
32
+ clm.postStep('✅ User has already been added');
33
+ }
34
+ else {
35
+ await shellService.runCommand(`sudo usermod -aG docker ${user}`);
36
+ clm.postStep(`\n✅ Added user "${user}" to the docker group`);
37
+ clm.warn('\nPlease logout and login again in order for the group changes take effect.\n');
38
+ process.exit(0);
39
+ }
38
40
  }
39
41
  }
40
42
  else if (hasInstallScript) {
@@ -154,9 +154,6 @@ export const checkNetwork = {
154
154
  configStore.setClusterStats({ total: nodes.length });
155
155
  return true;
156
156
  })
157
- .catch(() => {
158
- clm.error(`${type} is not in service. Please try again later.`);
159
- return false;
160
- });
157
+ .catch(() => false);
161
158
  }
162
159
  };
@@ -0,0 +1,5 @@
1
+ export declare const checkNodeCtl: {
2
+ check4Migration(): Promise<void>;
3
+ importKeyInfo(cnPath: string): Promise<void>;
4
+ promptForKeyFile(pilotKeyPath: string): Promise<void>;
5
+ };
@@ -0,0 +1,90 @@
1
+ import { input, password } from "@inquirer/prompts";
2
+ import chalk from "chalk";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import yaml from "yaml";
6
+ import { clm } from "../clm.js";
7
+ import { configStore } from "../config-store.js";
8
+ import { keyFileHelper } from "../helpers/key-file-helper.js";
9
+ import { promptHelper } from "../helpers/prompt-helper.js";
10
+ import { dockerService } from "../services/docker-service.js";
11
+ import { nodeService } from "../services/node-service.js";
12
+ import { shellService } from "../services/shell-service.js";
13
+ export const checkNodeCtl = {
14
+ async check4Migration() {
15
+ if (configStore.hasProjectFlag('nodeCtlChecked')) {
16
+ return;
17
+ }
18
+ const { name } = configStore.getProjectInfo();
19
+ if (name.toLowerCase() !== 'hypergraph') {
20
+ configStore.setProjectFlag('nodeCtlChecked', true);
21
+ return;
22
+ }
23
+ const hasNodeAdminUser = fs.existsSync('/home/nodeadmin');
24
+ if (hasNodeAdminUser) {
25
+ const isDockerRunning = await dockerService.isRunning();
26
+ const isPortOpen = await nodeService.isPortInUse(9000);
27
+ if (!isDockerRunning && isPortOpen) {
28
+ clm.error('Detected port 9000 already in use. Please shutdown any Nodes before proceeding.');
29
+ }
30
+ const cnPath = path.resolve('/var/tessellation/nodectl/cn-config.yaml');
31
+ if (fs.existsSync(cnPath)) {
32
+ clm.step(chalk.bold('NODECTL has been detected.'));
33
+ const answer = await input({
34
+ default: 'y',
35
+ message: 'Would you like to import key file from nodectl? (y/n): '
36
+ });
37
+ if (answer.toLowerCase() === 'y') {
38
+ await this.importKeyInfo(cnPath);
39
+ }
40
+ clm.warn(`You will need to uninstall nodectl before proceeding. \nPlease run the following command to uninstall it: ${chalk.cyanBright("sudo nodectl uninstall")}`);
41
+ process.exit(0);
42
+ }
43
+ }
44
+ configStore.setProjectFlag('nodeCtlChecked', true);
45
+ },
46
+ async importKeyInfo(cnPath) {
47
+ clm.step('Importing key file from nodectl...');
48
+ try {
49
+ clm.preStep('Making a sudo call to read the nodectl config file...');
50
+ await shellService.runCommand(`sudo chmod +r ${cnPath}`);
51
+ const doc = yaml.parse(fs.readFileSync(cnPath, 'utf8'));
52
+ // console.log(JSON.stringify(doc,null,2));
53
+ // eslint-disable-next-line camelcase
54
+ const { key_location, key_name } = doc.nodectl.global_p12;
55
+ const nodeCtlKeyPath = path.resolve(key_location, key_name);
56
+ clm.debug(`Found key file path in nodectl config file: ${nodeCtlKeyPath}`);
57
+ clm.step('Key file found at ' + chalk.cyan(nodeCtlKeyPath));
58
+ clm.preStep('Importing key file...');
59
+ const { projectDir } = configStore.getProjectInfo();
60
+ const pilotKeyPath = path.join(projectDir, 'key.p12');
61
+ // copy file to home directory, change owner to current user, and make it readable by all
62
+ clm.preStep('Making a sudo call to copy the key file...');
63
+ await shellService.runCommand(`sudo cp ${nodeCtlKeyPath} ${pilotKeyPath}; sudo chown $(whoami) ${pilotKeyPath}; chmod +r ${pilotKeyPath}`);
64
+ await this.promptForKeyFile(pilotKeyPath);
65
+ }
66
+ catch (error) {
67
+ console.error(error);
68
+ clm.warn('Failed to import key information from nodectl. You will need to import it manually.');
69
+ await promptHelper.doYouWishToContinue();
70
+ }
71
+ },
72
+ async promptForKeyFile(pilotKeyPath) {
73
+ // prompt for password
74
+ const keyPassword = await password({ message: 'Enter the key file password:' });
75
+ const keyAlias = await input({ message: 'Enter the key file alias:' });
76
+ configStore.setEnvInfo({ CL_KEYALIAS: keyAlias, CL_KEYSTORE: pilotKeyPath, CL_PASSWORD: keyPassword });
77
+ try {
78
+ const dagAddress = await keyFileHelper.getAddress();
79
+ const nodeId = await keyFileHelper.getId();
80
+ configStore.setProjectInfo({ dagAddress, nodeId });
81
+ }
82
+ catch {
83
+ clm.warn('Failed to unlock the key file. Please check your key file information and try again.');
84
+ fs.rmSync(pilotKeyPath);
85
+ await this.promptForKeyFile(pilotKeyPath);
86
+ return;
87
+ }
88
+ clm.postStep('Key file imported successfully.\n');
89
+ }
90
+ };
@@ -14,7 +14,7 @@ function getJavaMemoryOptions(network, mem) {
14
14
  if (network === 'testnet') {
15
15
  const linuxOpt = (os.platform() === 'linux') ? ' -XX:+UseZGC -XX:+ZGenerational -XX:ZAllocationSpikeTolerance=5 -XX:ZCollectionInterval=10' : '';
16
16
  // return `-Xms${mem}g -Xmx${mem}g -XX:+UnlockExperimentalVMOptions${linuxOpt} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heap_dumps/ -XX:+ExitOnOutOfMemoryError`;
17
- return `-Xms${mem}g -Xmx${mem}g${linuxOpt} -XX:+UseStringDeduplication --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED`;
17
+ return `-Xms${mem}g -Xmx${mem}g${linuxOpt} -XX:+UseStringDeduplication`;
18
18
  }
19
19
  return `-Xms1024M -Xmx${mem}g -Xss256K`;
20
20
  }
@@ -50,8 +50,8 @@ export const checkProject = {
50
50
  let mainLayerMem = 0;
51
51
  if (currentNetwork === 'testnet') {
52
52
  // Divide equally between layers with max of 10GB each
53
- subLayerMem = layersToRun.length > 1 ? Math.floor(answer / layersToRun.length) : 0;
54
- subLayerMem = Math.min(subLayerMem, 10);
53
+ subLayerMem = layersToRun.length > 1 ? Math.floor(answer / 3) : 0;
54
+ subLayerMem = Math.min(subLayerMem, 5);
55
55
  mainLayerMem = Math.min(10, answer - subLayerMem);
56
56
  }
57
57
  else {
@@ -127,9 +127,9 @@ export const checkProject = {
127
127
  else if (rInfo.version !== nInfo.version) {
128
128
  configStore.setNetworkInfo({ type: rInfo.network, version: rInfo.version });
129
129
  }
130
- const clusterVersion = await clusterService.getReleaseVersion();
131
130
  if (!requiresInstall) {
132
131
  const nInfo = configStore.getNetworkInfo();
132
+ const clusterVersion = await clusterService.getReleaseVersion();
133
133
  if (nInfo.version !== clusterVersion) {
134
134
  const answer = await input({
135
135
  default: 'y',
@@ -5,7 +5,10 @@ import { checkNetwork } from "../checks/check-network.js";
5
5
  import { checkNodePilot } from "../checks/check-pilot.js";
6
6
  import { checkProject } from "../checks/check-project.js";
7
7
  import { checkWallet } from "../checks/check-wallet.js";
8
+ import { clm } from "../clm.js";
9
+ import { configStore } from "../config-store.js";
8
10
  import { keyFileHelper } from "../helpers/key-file-helper.js";
11
+ import { dockerService } from "../services/docker-service.js";
9
12
  import { migrationService } from "../services/migration-service.js";
10
13
  export default class Status extends Command {
11
14
  static description = 'Display node status and configuration settings';
@@ -21,7 +24,14 @@ export async function checkInstallationAndConfigurationStatus() {
21
24
  migrationService.runMigrations();
22
25
  await checkProject.checkJavaMemory();
23
26
  await checkNetwork.checkExternalIpAddress();
24
- await checkNetwork.isNetworkConnectable();
27
+ if (!await checkNetwork.isNetworkConnectable()) {
28
+ if (await dockerService.isRunning()) {
29
+ await checkLayers.layersStatus();
30
+ return;
31
+ }
32
+ const { type } = configStore.getNetworkInfo();
33
+ clm.error(`${type} is currently offline. Please try again later.`);
34
+ }
25
35
  await checkNodePilot.checkDiscordRegistration();
26
36
  await checkProject.releaseVersion();
27
37
  await keyFileHelper.promptIfNoKeyFile();
@@ -3,5 +3,4 @@ export default class Test extends Command {
3
3
  static description: string;
4
4
  static hidden: boolean;
5
5
  run(): Promise<void>;
6
- testRandomNode(): Promise<void>;
7
6
  }
@@ -1,46 +1,13 @@
1
1
  import { Command } from "@oclif/core";
2
- import dotenv from "dotenv";
3
2
  import fs from "node:fs";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { getRandomNode } from "../services/get-random-node.js";
7
- import { StatusTable } from "../helpers/status-table.js";
8
3
  export default class Test extends Command {
9
4
  static description = 'node pilot test command';
10
5
  static hidden = true;
11
6
  async run() {
12
- // await checkNodeCtl.importKeyInfo(path.resolve('/Users/ffox/Projects/Constellation/node-pilot/cn-config.yaml'));
13
- // await this.testRandomNode();
14
- // const info = await archiverService.getArchiveSnapshotInfo();
15
- // console.log(info);
16
- // const ordinal = archiverService.getDownloadedSnapshotRange();
17
- // console.log(ordinal)
18
- //
19
- // await archiverService.syncToLatestSnapshot();
20
- // await archiverService.checkLogsForMissingSnapshots();
21
- await StatusTable.run();
22
- // console.log(semver.parse("0.11.0-testnet")?.compare('0.11.0'));
23
- // await checkNodePilot.checkVersion();
24
- }
25
- async testRandomNode() {
26
- const filePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../projects/hypergraph/networks/mainnet/source-nodes.env`);
27
- const conetent = fs.readFileSync(filePath);
28
- const parsed = dotenv.parse(conetent);
29
- const nodes = ['1', '2', '3'].map(i => {
30
- return { host: parsed[`SOURCE_NODE_${i}_HOST`], id: parsed[`SOURCE_NODE_${i}_ID`], publicPort: parsed[`SOURCE_NODE_${i}_PORT`] };
31
- });
32
- const n = await getRandomNode(nodes);
33
- console.log('Random node:', n);
7
+ // await promptHelper.configureJavaMemoryArguments();
8
+ const r = fs.statfsSync('/');
9
+ const totalSpace = (r.bsize * r.blocks / (1024 * 1024 * 1024)).toFixed(2);
10
+ const totalFreeSpace = (r.bsize * r.bfree / (1024 * 1024 * 1024)).toFixed(2);
11
+ console.log(totalSpace, totalFreeSpace);
34
12
  }
35
13
  }
36
- // type NetworkEnvType = {
37
- // SOURCE_NODE_1_HOST:string,
38
- // SOURCE_NODE_1_ID:string,
39
- // SOURCE_NODE_1_PORT:string,
40
- // SOURCE_NODE_2_HOST:string,
41
- // SOURCE_NODE_2_ID:string,
42
- // SOURCE_NODE_2_PORT:string,
43
- // SOURCE_NODE_3_HOST:string,
44
- // SOURCE_NODE_3_ID:string,
45
- // SOURCE_NODE_3_PORT:string,
46
- // }
@@ -1,10 +1,12 @@
1
1
  import semver from "semver";
2
2
  import { clm } from "../clm.js";
3
3
  import { configStore } from "../config-store.js";
4
+ import { projectHelper } from "../helpers/project-helper.js";
4
5
  export const migrationService = {
5
6
  runMigrations() {
6
7
  const migrations = {
7
8
  '0.12.5': m0125,
9
+ '0.13.9': m0139,
8
10
  // add more migrations as needed
9
11
  };
10
12
  const { version = '0.0.0' } = configStore.getProjectInfo();
@@ -29,6 +31,11 @@ export const migrationService = {
29
31
  configStore.setProjectInfo({ version: currentVersion.toString() });
30
32
  }
31
33
  };
34
+ function m0139() {
35
+ clm.step('Running migration 0.13.9...');
36
+ configStore.setProjectFlag('javaMemoryChecked', false);
37
+ projectHelper.upgradeHypergraph();
38
+ }
32
39
  function m0125() {
33
40
  clm.step('Running migration 0.12.5...');
34
41
  configStore.setProjectFlag('javaMemoryChecked', false);
@@ -363,5 +363,5 @@
363
363
  ]
364
364
  }
365
365
  },
366
- "version": "0.13.1-testnet"
366
+ "version": "0.14.0-intnet"
367
367
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@constellation-network/node-pilot",
3
3
  "description": "An easy deployment and monitoring tool for Constellation nodes.",
4
- "version": "0.13.1-testnet",
4
+ "version": "0.14.0-intnet",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -21,7 +21,7 @@
21
21
  "version": "oclif readme && git add README.md",
22
22
  "start": "./bin/dev.js",
23
23
  "debug": "DEBUG=true ./bin/dev.js",
24
- "pub": "npm publish --access public --tag testnet"
24
+ "pub": "npm publish --access public --tag intnet"
25
25
  },
26
26
  "types": "dist/index.d.ts",
27
27
  "engines": {
@@ -39,7 +39,7 @@ COPY dist/gl0.jar /app/jars/gl0.jar
39
39
  #COPY ./health-check /health-check
40
40
  #RUN chmod +x /health-check/bin/run.sh
41
41
  #RUN chmod +x /health-check/bin/hydrate.sh
42
- RUN npm install -g "@constellation-network/node-pilot-health-check@0.0.27"
42
+ RUN npm install -g "@constellation-network/node-pilot-health-check@0.0.28"
43
43
 
44
44
  # Add entrypoint
45
45
  COPY ./entrypoint.sh /app/entrypoint.sh
@@ -1,9 +0,0 @@
1
- {
2
- "name": "custom",
3
- "projects": [
4
- { "name": "hg-intnet-1", "network": "intnet", "key": "key1.p12", "layers": "gl0" },
5
- { "name": "hg-intnet-2", "network": "intnet", "key": "key2.p12", "layers": "gl0" },
6
- { "name": "hg-intnet-3", "network": "intnet", "key": "key3.p12", "layers": "gl0" }
7
- ]
8
- }
9
-