@constellation-network/node-pilot 0.23.0-testnet → 0.24.0-devnet.1

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.23.0-testnet darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.24.0-devnet.1 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.23.0-testnet/src/commands/clean.ts)_
75
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/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.23.0-testnet/src/commands/config.ts)_
92
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/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.23.0-testnet/src/commands/config/get.ts)_
116
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/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.23.0-testnet/src/commands/config/set.ts)_
139
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/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.23.0-testnet/src/commands/info.ts)_
176
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/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.23.0-testnet/src/commands/logs.ts)_
202
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/logs.ts)_
203
203
 
204
204
  ## `cpilot restart [LAYER]`
205
205
 
@@ -223,7 +223,7 @@ EXAMPLES
223
223
  $ cpilot restart
224
224
  ```
225
225
 
226
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.23.0-testnet/src/commands/restart.ts)_
226
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/restart.ts)_
227
227
 
228
228
  ## `cpilot shutdown`
229
229
 
@@ -240,7 +240,7 @@ EXAMPLES
240
240
  $ cpilot shutdown
241
241
  ```
242
242
 
243
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.23.0-testnet/src/commands/shutdown.ts)_
243
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/shutdown.ts)_
244
244
 
245
245
  ## `cpilot status`
246
246
 
@@ -254,7 +254,7 @@ DESCRIPTION
254
254
  Display node status and configuration settings
255
255
  ```
256
256
 
257
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.23.0-testnet/src/commands/status.ts)_
257
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/status.ts)_
258
258
 
259
259
  ## `cpilot uninstall`
260
260
 
@@ -271,5 +271,5 @@ EXAMPLES
271
271
  $ cpilot uninstall
272
272
  ```
273
273
 
274
- _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.23.0-testnet/src/commands/uninstall.ts)_
274
+ _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.24.0-devnet.1/src/commands/uninstall.ts)_
275
275
  <!-- commandsstop -->
@@ -48,7 +48,8 @@ export const checkHardware = {
48
48
  await promptHelper.doYouWishToContinue('n');
49
49
  }
50
50
  else {
51
- clm.error("System requirements not met.\n");
51
+ clm.warn("System recommendations not met. The validator node may not function properly.\n");
52
+ await promptHelper.doYouWishToContinue('n');
52
53
  }
53
54
  pilotManager.setSystemInfo({ cores: numOfCores, disk: totalSpaceGB, memory: totalMemoryGB, platform: os.platform(), user: os.userInfo().username });
54
55
  }
@@ -105,6 +105,9 @@ export const checkNodePilot = {
105
105
  else if (pilotVersion.includes('intnet')) {
106
106
  distTag = 'intnet';
107
107
  }
108
+ else if (pilotVersion.includes('devnet')) {
109
+ distTag = 'devnet';
110
+ }
108
111
  const latestVer = semver.parse(result['dist-tags'][distTag]);
109
112
  const currentVer = semver.parse(pilotVersion);
110
113
  if (latestVer !== null && currentVer !== null) {
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Mgkeys extends Command {
3
+ static args: {
4
+ prefix: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ alias: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ complexity: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ password: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ static hidden: boolean;
14
+ private NAMES;
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,64 @@
1
+ /* eslint-disable perfectionist/sort-objects */
2
+ import { Args, Command, Flags } from '@oclif/core';
3
+ import { keyFileHelper } from "../helpers/key-file-helper.js";
4
+ export default class Mgkeys extends Command {
5
+ static args = {
6
+ prefix: Args.string({ description: 'A short name to be used for the key file prefix', required: true }),
7
+ };
8
+ static description = 'generate new keys for a metagraph';
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %>',
11
+ ];
12
+ static flags = {
13
+ alias: Flags.string({ char: 'a', default: 'alias', description: 'alias to use for each key' }),
14
+ complexity: Flags.integer({ char: 'l', description: 'generate new password with specified length', max: 128, min: 4 }),
15
+ password: Flags.string({ char: 'p', default: 'password', description: 'if no complexity is specified, apply this value for each key' }),
16
+ };
17
+ static hidden = true;
18
+ NAMES = ['node-1', 'node-2', 'node-3', 'owner', 'staking'];
19
+ async run() {
20
+ const { args, flags } = await this.parse(Mgkeys);
21
+ const { alias, complexity, password } = flags;
22
+ const passwords = Array.from({ length: 5 }, () => complexity
23
+ ? Array.from({ length: complexity }).fill(0).map(() => Math.random().toString(36).charAt(2)).join('')
24
+ : password);
25
+ const keyInfos = [];
26
+ const printKeyInfo = [];
27
+ const currentDir = process.cwd();
28
+ for (let i = 0; i < this.NAMES.length; i++) {
29
+ const name = this.NAMES[i];
30
+ const password = passwords[i];
31
+ const file = `${currentDir}/${args.prefix}-${name}.p12`;
32
+ // console.log(`Generating key: ${file} with alias: ${alias} and password: ${password}`);
33
+ // eslint-disable-next-line no-await-in-loop
34
+ keyInfos[i] = await keyFileHelper.getKeyInfoFromParams({ CL_KEYALIAS: alias, CL_KEYSTORE: file, CL_PASSWORD: password });
35
+ // await this.spawnCommand('cpilot', ['keygen', '--alias', `${alias}-${name}`, '--password', password, '--output', keyName]);
36
+ printKeyInfo[i] = {
37
+ "name": `${args.prefix}-${name}`,
38
+ "key_file": {
39
+ "name": `${args.prefix}-${name}.p12`,
40
+ alias,
41
+ password
42
+ }
43
+ };
44
+ console.log('generated:', file);
45
+ }
46
+ const fees = {
47
+ "snapshot_fees": {
48
+ "owner": {
49
+ "key_file": printKeyInfo[3].key_file
50
+ },
51
+ "staking": {
52
+ "key_file": printKeyInfo[4].key_file,
53
+ }
54
+ }
55
+ };
56
+ // Show euclid.json "nodes" JSON array
57
+ console.log(JSON.stringify({ "nodes": printKeyInfo.slice(0, 3) }, null, 2));
58
+ // Show euclid.json snapshot_fees and staking object
59
+ console.log(JSON.stringify(fees, null, 2));
60
+ // Show each name and Node ID
61
+ for (const [i, kInfo] of keyInfos.entries())
62
+ console.log(`\n${args.prefix}-${this.NAMES[i]}\n${kInfo.address}\n${kInfo.id}`);
63
+ }
64
+ }
@@ -21,7 +21,7 @@ export async function checkInstallationAndConfigurationStatus() {
21
21
  await checkNodePilot.checkMultipleUsers();
22
22
  await checkProject.projectInstallation();
23
23
  await checkNodePilot.checkVersion();
24
- migrationService.runMigrations();
24
+ await migrationService.runMigrations();
25
25
  await checkProject.checkJavaMemory();
26
26
  await checkNetwork.checkExternalIpAddress();
27
27
  if (!await checkNetwork.isNetworkConnectable()) {
@@ -1,5 +1,4 @@
1
- import { EnvCombinedInfo, EnvInfo } from "../config-store.js";
1
+ import { EnvCombinedInfo } from "../config-store.js";
2
2
  import { TessellationLayer } from "../types.js";
3
3
  export declare function getLayerEnvFileContent(layer: TessellationLayer, env: EnvCombinedInfo): string;
4
- export declare function getKeyFileContent(env: EnvInfo): string;
5
4
  export declare function getObjectToEnvContent(obj: object): string;
@@ -29,13 +29,6 @@ CL_P2P_HTTP_PORT=${env.CL_P2P_HTTP_PORT}
29
29
  CL_CLI_HTTP_PORT=${env.CL_CLI_HTTP_PORT}
30
30
  `;
31
31
  }
32
- export function getKeyFileContent(env) {
33
- return `
34
- export CL_KEYSTORE='${env.CL_KEYSTORE}'
35
- export CL_KEYALIAS='${env.CL_KEYALIAS}'
36
- export CL_PASSWORD='${env.CL_PASSWORD}'
37
- `;
38
- }
39
32
  export function getObjectToEnvContent(obj) {
40
33
  return Object.entries(obj).map(([k, v]) => `${k}='${v}'`).join('\n') + '\n';
41
34
  }
@@ -3,6 +3,14 @@ export declare const keyFileHelper: {
3
3
  generate(): Promise<void>;
4
4
  getAddress(): Promise<string>;
5
5
  getId(): Promise<string>;
6
+ getKeyInfoFromParams(params: {
7
+ CL_KEYALIAS: string;
8
+ CL_KEYSTORE: string;
9
+ CL_PASSWORD: string;
10
+ }): Promise<{
11
+ address: string;
12
+ id: string;
13
+ }>;
6
14
  importKeyFile(): Promise<void>;
7
15
  promptForKeyFile(): Promise<void>;
8
16
  promptIfNoKeyFile(): Promise<void>;
@@ -59,6 +59,17 @@ export const keyFileHelper = {
59
59
  const env = configStore.getEnvInfo();
60
60
  return shellService.runCommandWithOutput(`java -jar ${projectDir}/dist/wallet.jar show-id`, env);
61
61
  },
62
+ async getKeyInfoFromParams(params) {
63
+ if (fs.existsSync(params.CL_KEYSTORE)) {
64
+ throw new Error(`A key file already exists. Please delete it first. ${params.CL_KEYSTORE}`);
65
+ }
66
+ const { projectDir } = configStore.getProjectInfo();
67
+ await shellService.runCommand(`java -jar ${projectDir}/dist/keytool.jar generate`, params);
68
+ const id = await shellService.runCommandWithOutput(`java -jar ${projectDir}/dist/wallet.jar show-id`, params);
69
+ const address = await shellService.runCommandWithOutput(`java -jar ${projectDir}/dist/wallet.jar show-address`, params);
70
+ ;
71
+ return { address, id };
72
+ },
62
73
  async importKeyFile() {
63
74
  const p12Files = fs.readdirSync(os.homedir())
64
75
  .filter(file => file.endsWith('.p12'))
@@ -16,7 +16,9 @@ export const dockerService = {
16
16
  else {
17
17
  clm.preStep('Building the node container...');
18
18
  }
19
- await shellService.runProjectCommand('bash scripts/docker-build.sh', undefined, silent);
19
+ const { type: network } = configStore.getNetworkInfo();
20
+ const JAVA_VERSION = network === 'mainnet' ? '11' : '21';
21
+ await shellService.runProjectCommand('bash scripts/docker-build.sh', { JAVA_VERSION }, silent);
20
22
  if (silent) {
21
23
  spinner.stop();
22
24
  }
@@ -1,3 +1,3 @@
1
1
  export declare const migrationService: {
2
- runMigrations(): void;
2
+ runMigrations(): Promise<void>;
3
3
  };
@@ -2,16 +2,25 @@ import semver from "semver";
2
2
  import { clm } from "../clm.js";
3
3
  import { configStore } from "../config-store.js";
4
4
  import { projectHelper } from "../helpers/project-helper.js";
5
+ import { dockerService } from "./docker-service.js";
6
+ import { nodeService } from "./node-service.js";
7
+ import { shellService } from "./shell-service.js";
8
+ const migrations = {
9
+ '0.24.0-0': {
10
+ description: 'host Java 21; container Java is network-aware (11 for mainnet, 21 elsewhere)',
11
+ requiresNodeRestart: true,
12
+ async run() {
13
+ configStore.setProjectFlag('javaMemoryChecked', false);
14
+ projectHelper.upgradeHypergraph();
15
+ const { type: network } = configStore.getNetworkInfo();
16
+ const JAVA_VERSION = network === 'mainnet' ? '11' : '21';
17
+ await shellService.runProjectCommand('bash scripts/install-dependencies.sh', { JAVA_VERSION });
18
+ await refreshJavaHome();
19
+ }
20
+ }
21
+ };
5
22
  export const migrationService = {
6
- runMigrations() {
7
- const migrations = {
8
- '0.12.5': m0125,
9
- '0.13.9': m0139,
10
- '0.14.0-intnet.1': m0140intnet1,
11
- '0.18.7-intnet': m01807,
12
- '0.19.2-intnet': m0192intnet
13
- // add more migrations as needed
14
- };
23
+ async runMigrations() {
15
24
  const { version = '0.0.0' } = configStore.getProjectInfo();
16
25
  const { version: pilotVersion } = configStore.getPilotReleaseInfo();
17
26
  const lastMigratedVersion = semver.parse(version);
@@ -20,50 +29,55 @@ export const migrationService = {
20
29
  return;
21
30
  }
22
31
  clm.debug(`Running migrations from ${lastMigratedVersion.version} to ${currentVersion.version}`);
23
- clm.debug(`semver.gt(v, version): ${semver.gt('0.8.0', version)}`);
24
- clm.debug(`semver.lte(v, currentVersion.version): ${semver.lte('0.8.0', currentVersion.version)}`);
25
- const migrationVersions = Object.keys(migrations)
32
+ const migrationKeys = Object.keys(migrations)
26
33
  .filter(v => semver.gt(v, version) && semver.lte(v, currentVersion.version))
27
34
  .sort(semver.compare);
28
- if (migrationVersions.length > 0) {
29
- clm.preStep(`Migration versions to run: ${migrationVersions}`);
30
- for (const version of migrationVersions) {
31
- migrations[version]();
32
- }
35
+ if (migrationKeys.length === 0) {
36
+ clm.debug('No migrations applicable.');
37
+ configStore.setProjectInfo({ version: currentVersion.toString() });
38
+ return;
39
+ }
40
+ const summary = migrationKeys.map(k => `${k} (${migrations[k].description})`).join(', ');
41
+ clm.preStep(`Migration versions to run: ${summary}`);
42
+ for (const key of migrationKeys) {
43
+ // eslint-disable-next-line no-await-in-loop
44
+ await runMigration(key, migrations[key]);
45
+ // Stamp per-migration so a later failure doesn't re-run earlier ones.
46
+ configStore.setProjectInfo({ version: key });
33
47
  }
34
48
  configStore.setProjectInfo({ version: currentVersion.toString() });
35
49
  }
36
50
  };
37
- function m0192intnet() {
38
- clm.step('Running migration 0.19.2-intnet...');
39
- projectHelper.upgradeHypergraph();
40
- }
41
- function m01807() {
42
- clm.step('Running migration 0.18.7...');
43
- projectHelper.upgradeHypergraph();
44
- }
45
- function m0140intnet1() {
46
- configStore.setProjectFlag('javaMemoryChecked', false);
47
- }
48
- function m0139() {
49
- clm.step('Running migration 0.13.9...');
50
- configStore.setProjectFlag('javaMemoryChecked', false);
51
- projectHelper.upgradeHypergraph();
51
+ async function runMigration(key, migration) {
52
+ clm.step(`Running migration ${key} — ${migration.description}...`);
53
+ if (!migration.requiresNodeRestart) {
54
+ await migration.run();
55
+ return;
56
+ }
57
+ const wasRunning = await dockerService.isRunning();
58
+ if (wasRunning) {
59
+ clm.preStep('Shutting down node to apply migration changes...');
60
+ const { layersToRun } = configStore.getProjectInfo();
61
+ await nodeService.leaveClusterAllLayers();
62
+ await nodeService.pollForLayersState(layersToRun, 'Offline');
63
+ await dockerService.dockerDown();
64
+ }
65
+ await migration.run();
66
+ if (wasRunning) {
67
+ clm.preStep('Rebuilding container with refreshed Dockerfile...');
68
+ await dockerService.dockerBuild();
69
+ clm.preStep('Restarting node...');
70
+ await dockerService.dockerRestartAll();
71
+ }
52
72
  }
53
- function m0125() {
54
- clm.step('Running migration 0.12.5...');
55
- configStore.setProjectFlag('javaMemoryChecked', false);
56
- // projectHelper.upgradeHypergraph();
57
- // installJava21();
73
+ async function refreshJavaHome() {
74
+ if (process.platform !== 'linux')
75
+ return;
76
+ const javaHome = await shellService
77
+ .runCommandWithOutput('dirname "$(dirname "$(readlink -f "$(which java)")")"')
78
+ .catch(() => '');
79
+ if (javaHome) {
80
+ process.env.JAVA_HOME = javaHome;
81
+ clm.debug(`JAVA_HOME refreshed to ${javaHome} for current process`);
82
+ }
58
83
  }
59
- // function installJava21() {
60
- // const pilotDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../..`);
61
- // clm.debug(`Running install-java-21.sh from ${pilotDir}`);
62
- //
63
- // const result = shell.exec('bash install-java-21.sh', {cwd: pilotDir});
64
- //
65
- // if (result.code > 0) {
66
- // console.log(result.stderr);
67
- // clm.error(`Failed to install dependencies. Please try again after resolving any errors.`);
68
- // }
69
- // }
@@ -155,6 +155,63 @@
155
155
  "logs.js"
156
156
  ]
157
157
  },
158
+ "mgkeys": {
159
+ "aliases": [],
160
+ "args": {
161
+ "prefix": {
162
+ "description": "A short name to be used for the key file prefix",
163
+ "name": "prefix",
164
+ "required": true
165
+ }
166
+ },
167
+ "description": "generate new keys for a metagraph",
168
+ "examples": [
169
+ "<%= config.bin %> <%= command.id %>"
170
+ ],
171
+ "flags": {
172
+ "alias": {
173
+ "char": "a",
174
+ "description": "alias to use for each key",
175
+ "name": "alias",
176
+ "default": "alias",
177
+ "hasDynamicHelp": false,
178
+ "multiple": false,
179
+ "type": "option"
180
+ },
181
+ "complexity": {
182
+ "char": "l",
183
+ "description": "generate new password with specified length",
184
+ "name": "complexity",
185
+ "hasDynamicHelp": false,
186
+ "multiple": false,
187
+ "type": "option"
188
+ },
189
+ "password": {
190
+ "char": "p",
191
+ "description": "if no complexity is specified, apply this value for each key",
192
+ "name": "password",
193
+ "default": "password",
194
+ "hasDynamicHelp": false,
195
+ "multiple": false,
196
+ "type": "option"
197
+ }
198
+ },
199
+ "hasDynamicHelp": false,
200
+ "hidden": true,
201
+ "hiddenAliases": [],
202
+ "id": "mgkeys",
203
+ "pluginAlias": "@constellation-network/node-pilot",
204
+ "pluginName": "@constellation-network/node-pilot",
205
+ "pluginType": "core",
206
+ "strict": true,
207
+ "enableJsonFlag": false,
208
+ "isESM": true,
209
+ "relativePath": [
210
+ "dist",
211
+ "commands",
212
+ "mgkeys.js"
213
+ ]
214
+ },
158
215
  "project": {
159
216
  "aliases": [],
160
217
  "args": {},
@@ -392,5 +449,5 @@
392
449
  ]
393
450
  }
394
451
  },
395
- "version": "0.23.0-testnet"
452
+ "version": "0.24.0-devnet.1"
396
453
  }
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.23.0-testnet",
4
+ "version": "0.24.0-devnet.1",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -21,7 +21,10 @@
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:mainnet": "npm publish --access public",
25
+ "pub:testnet": "npm publish --access public --tag testnet",
26
+ "pub:intnet": "npm publish --access public --tag intnet",
27
+ "pub:devnet": "npm publish --access public --tag devnet"
25
28
  },
26
29
  "types": "dist/index.d.ts",
27
30
  "engines": {
@@ -1,6 +1,8 @@
1
1
  FROM ubuntu:22.04
2
2
 
3
- RUN apt update && apt install -y openjdk-21-jre
3
+ ARG JAVA_VERSION=21
4
+
5
+ RUN apt update && apt install -y openjdk-${JAVA_VERSION}-jre
4
6
 
5
7
  RUN apt install -y curl jq wget
6
8
 
@@ -3,5 +3,6 @@ SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
3
3
 
4
4
  # --- build image ---
5
5
  DOCKER_IMAGE_VERSION="${DOCKER_IMAGE_VERSION:-test}"
6
- echo "Building tessellation image: constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION"
7
- docker build -t "constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION" -f "$SCRIPT_DIR/../Dockerfile" .
6
+ JAVA_VERSION="${JAVA_VERSION:-21}"
7
+ echo "Building tessellation image: constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION (Java $JAVA_VERSION)"
8
+ docker build --build-arg JAVA_VERSION="$JAVA_VERSION" -t "constellationnetwork/tessellation:$DOCKER_IMAGE_VERSION" -f "$SCRIPT_DIR/../Dockerfile" .
@@ -21,57 +21,66 @@ check_java_home() {
21
21
 
22
22
  }
23
23
 
24
- # Check and install Java 21
24
+ # Check and install Java. Version is controlled by the JAVA_VERSION env
25
+ # var (default 21). For mainnet (JAVA_VERSION=11), accept any existing
26
+ # Java install — host utilities (keytool.jar, wallet.jar) work fine on
27
+ # 11 or newer, so don't force-upgrade users who already have a JDK.
25
28
  check_java() {
26
- # echo "Checking for Java 21..."
29
+ JAVA_VERSION="${JAVA_VERSION:-21}"
30
+
27
31
  if command -v java >/dev/null 2>&1; then
28
- java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
29
- # echo "Found Java version: $java_version"
30
- if [[ "$java_version" == 21* ]] || [[ "$java_version" == 1.21* ]]; then
31
- echo "✅ Java 21 is installed."
32
+ java_version_str=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
33
+
34
+ if [[ "$JAVA_VERSION" == "11" ]]; then
35
+ # Mainnet: accept whatever's installed (don't force-upgrade)
36
+ echo "✅ Java is installed: $java_version_str (mainnet — keeping existing JDK)"
37
+ return 0
38
+ fi
39
+
40
+ if [[ "$java_version_str" == "$JAVA_VERSION"* ]] || [[ "$java_version_str" == "1.$JAVA_VERSION"* ]]; then
41
+ echo "✅ Java $JAVA_VERSION is installed."
32
42
  return 0
33
- else
34
- echo "⚠️ Java is installed but not version 21. Will attempt to install Java 21."
35
43
  fi
44
+
45
+ echo "⚠️ Java is installed but not version $JAVA_VERSION. Will attempt to install Java $JAVA_VERSION."
36
46
  else
37
- echo "⚠️ Java not found. Will attempt to install Java 21."
47
+ echo "⚠️ Java not found. Will attempt to install Java $JAVA_VERSION."
38
48
  fi
39
49
 
40
50
 
41
51
  case "$(uname)" in
42
52
  Linux)
43
53
  if command -v apt >/dev/null 2>&1; then
44
- echo "Installing Java 21 using apt..."
45
- sudo apt install -y openjdk-21-jdk
54
+ echo "Installing Java $JAVA_VERSION using apt..."
55
+ sudo apt install -y "openjdk-${JAVA_VERSION}-jdk"
46
56
  elif command -v yum >/dev/null 2>&1; then
47
- echo "Installing Java 21 using yum..."
48
- sudo yum install -y java-21-openjdk-devel
57
+ echo "Installing Java $JAVA_VERSION using yum..."
58
+ sudo yum install -y "java-${JAVA_VERSION}-openjdk-devel"
49
59
  else
50
- echo "⚠️ Unsupported Linux distribution. Please install Java 21 manually."
60
+ echo "⚠️ Unsupported Linux distribution. Please install Java $JAVA_VERSION manually."
51
61
  return 1
52
62
  fi
53
63
  ;;
54
64
  Darwin)
55
65
  if command -v brew >/dev/null 2>&1; then
56
- echo "Installing Java 21 using Homebrew..."
57
- # if brew tap | grep -q '^adoptopenjdk/openjdk$'; then brew untap adoptopenjdk/openjdk; fi
58
- brew install --cask temurin@21
66
+ echo "Installing Java $JAVA_VERSION using Homebrew..."
67
+ brew install --cask "temurin@${JAVA_VERSION}"
59
68
  else
60
- echo "⚠️ Homebrew not found. Please install Java 21 manually."
69
+ echo "⚠️ Homebrew not found. Please install Java $JAVA_VERSION manually."
61
70
  return 1
62
71
  fi
63
72
  ;;
64
73
  MINGW*|MSYS*|CYGWIN*)
65
- echo "On Windows, please install Java 21 manually from https://adoptopenjdk.net/"
74
+ echo "On Windows, please install Java $JAVA_VERSION manually from https://adoptium.net/"
66
75
  return 1
67
76
  ;;
68
77
  *)
69
- echo "⚠️ Unsupported OS: $(uname). Please install Java 21 manually."
78
+ echo "⚠️ Unsupported OS: $(uname). Please install Java $JAVA_VERSION manually."
70
79
  return 1
71
80
  ;;
72
81
  esac
73
82
 
74
- echo "✅ Java 21 installation complete."
83
+ echo "✅ Java $JAVA_VERSION installation complete."
75
84
  return 0
76
85
  }
77
86
 
@@ -44,7 +44,11 @@ if [ -f "$OUTPUT_DIR/version.sh" ]; then
44
44
  fi
45
45
  else
46
46
  [[ -z "${NETWORK}" ]] && { echo "No network specified."; usage; }
47
- bash "$SCRIPT_DIR/install-dependencies.sh"
47
+ if [ "$NETWORK" = "mainnet" ]; then
48
+ JAVA_VERSION=11 bash "$SCRIPT_DIR/install-dependencies.sh"
49
+ else
50
+ JAVA_VERSION=21 bash "$SCRIPT_DIR/install-dependencies.sh"
51
+ fi
48
52
  INSTALLED_NETWORK_TYPE=""
49
53
  fi
50
54
 
File without changes