genlayer 0.9.1 → 0.10.0-beta.0
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/.env.example +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/index.js +10 -8
- package/package.json +1 -1
- package/src/commands/general/index.ts +3 -1
- package/src/commands/general/init.ts +0 -1
- package/src/lib/config/simulator.ts +6 -4
- package/src/lib/services/simulator.ts +4 -3
- package/tests/actions/init.test.ts +2 -1
- package/tests/commands/init.test.ts +2 -1
- package/tests/services/simulator.test.ts +6 -6
package/.env.example
CHANGED
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -58904,7 +58904,7 @@ var {
|
|
|
58904
58904
|
} = import_index.default;
|
|
58905
58905
|
|
|
58906
58906
|
// package.json
|
|
58907
|
-
var version = "0.
|
|
58907
|
+
var version = "0.10.0-beta.0";
|
|
58908
58908
|
var package_default = {
|
|
58909
58909
|
name: "genlayer",
|
|
58910
58910
|
version,
|
|
@@ -59040,12 +59040,14 @@ function v4(options, buf, offset) {
|
|
|
59040
59040
|
var v4_default = v4;
|
|
59041
59041
|
|
|
59042
59042
|
// src/lib/config/simulator.ts
|
|
59043
|
+
var localnetCompatibleVersion = "v0.29.0";
|
|
59043
59044
|
var DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
|
|
59044
|
-
var
|
|
59045
|
+
var CONTAINERS_NAME_PREFIX = "/genlayer-";
|
|
59046
|
+
var IMAGES_NAME_PREFIX = "yeagerai";
|
|
59045
59047
|
var DEFAULT_RUN_SIMULATOR_COMMAND = (location, options) => ({
|
|
59046
|
-
darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose up ${options}"'`,
|
|
59047
|
-
win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose
|
|
59048
|
-
linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose up
|
|
59048
|
+
darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose -p genlayer up ${options}"'`,
|
|
59049
|
+
win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose -p genlayer up ${options} && pause"`,
|
|
59050
|
+
linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose -p genlayer up ${options} -d '`
|
|
59049
59051
|
});
|
|
59050
59052
|
var DEFAULT_RUN_DOCKER_COMMAND = {
|
|
59051
59053
|
darwin: "open -a Docker",
|
|
@@ -59792,7 +59794,7 @@ Run npm install -g genlayer to update
|
|
|
59792
59794
|
const containers = await this.docker.listContainers({ all: true });
|
|
59793
59795
|
const genlayerContainers = containers.filter(
|
|
59794
59796
|
(container) => container.Names.some(
|
|
59795
|
-
(name) => name.startsWith(
|
|
59797
|
+
(name) => name.startsWith(CONTAINERS_NAME_PREFIX)
|
|
59796
59798
|
)
|
|
59797
59799
|
);
|
|
59798
59800
|
for (const containerInfo of genlayerContainers) {
|
|
@@ -59807,7 +59809,7 @@ Run npm install -g genlayer to update
|
|
|
59807
59809
|
async resetDockerImages() {
|
|
59808
59810
|
const images = await this.docker.listImages();
|
|
59809
59811
|
const genlayerImages = images.filter(
|
|
59810
|
-
(image) => image.RepoTags?.some((tag) => tag.startsWith(
|
|
59812
|
+
(image) => image.RepoTags?.some((tag) => tag.startsWith(IMAGES_NAME_PREFIX))
|
|
59811
59813
|
);
|
|
59812
59814
|
for (const imageInfo of genlayerImages) {
|
|
59813
59815
|
const image = this.docker.getImage(imageInfo.Id);
|
|
@@ -62669,7 +62671,7 @@ async function startAction(options, simulatorService) {
|
|
|
62669
62671
|
|
|
62670
62672
|
// src/commands/general/index.ts
|
|
62671
62673
|
function initializeGeneralCommands(program2) {
|
|
62672
|
-
program2.command("init").description("Initialize the GenLayer Environment").option("--numValidators <numValidators>", "Number of validators", "5").option("--headless", "Headless mode", false).option("--reset-db", "Reset Database", false).option("--localnet-version <localnetVersion>", "Select a specific localnet version",
|
|
62674
|
+
program2.command("init").description("Initialize the GenLayer Environment").option("--numValidators <numValidators>", "Number of validators", "5").option("--headless", "Headless mode", false).option("--reset-db", "Reset Database", false).option("--localnet-version <localnetVersion>", "Select a specific localnet version", localnetCompatibleVersion).action((options) => initAction(options, simulator_default));
|
|
62673
62675
|
program2.command("up").description("Starts GenLayer's simulator").option("--reset-validators", "Remove all current validators and create new random ones", false).option("--numValidators <numValidators>", "Number of validators", "5").option("--headless", "Headless mode", false).option("--reset-db", "Reset Database", false).action((options) => startAction(options, simulator_default));
|
|
62674
62676
|
return program2;
|
|
62675
62677
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
|
|
2
3
|
import simulatorService from "../../lib/services/simulator";
|
|
3
4
|
import { initAction, InitActionOptions } from "./init";
|
|
4
5
|
import { startAction, StartActionOptions } from "./start";
|
|
6
|
+
import {localnetCompatibleVersion} from "../../lib/config/simulator";
|
|
5
7
|
|
|
6
8
|
export function initializeGeneralCommands(program: Command) {
|
|
7
9
|
program
|
|
@@ -10,7 +12,7 @@ export function initializeGeneralCommands(program: Command) {
|
|
|
10
12
|
.option("--numValidators <numValidators>", "Number of validators", "5")
|
|
11
13
|
.option("--headless", "Headless mode", false)
|
|
12
14
|
.option("--reset-db", "Reset Database", false)
|
|
13
|
-
.option("--localnet-version <localnetVersion>", "Select a specific localnet version",
|
|
15
|
+
.option("--localnet-version <localnetVersion>", "Select a specific localnet version", localnetCompatibleVersion)
|
|
14
16
|
.action((options: InitActionOptions) => initAction(options, simulatorService));
|
|
15
17
|
|
|
16
18
|
program
|
|
@@ -147,7 +147,6 @@ export async function initAction(options: InitActionOptions, simulatorService: I
|
|
|
147
147
|
simulatorService.addConfigToEnvFile(aiProvidersEnvVars);
|
|
148
148
|
simulatorService.addConfigToEnvFile({LOCALNETVERSION: localnetVersion});
|
|
149
149
|
|
|
150
|
-
|
|
151
150
|
// Run the GenLayer Simulator
|
|
152
151
|
console.log("Running the GenLayer Simulator...");
|
|
153
152
|
try {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export const localnetCompatibleVersion = "v0.29.0";
|
|
1
2
|
export const DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
|
|
2
|
-
export const
|
|
3
|
+
export const CONTAINERS_NAME_PREFIX = "/genlayer-";
|
|
4
|
+
export const IMAGES_NAME_PREFIX = "yeagerai";
|
|
3
5
|
export const DEFAULT_RUN_SIMULATOR_COMMAND = (location: string, options: string) => ({
|
|
4
|
-
darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose up ${options}"'`,
|
|
5
|
-
win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose
|
|
6
|
-
linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose up
|
|
6
|
+
darwin: `osascript -e 'tell application "Terminal" to do script "cd ${location} && docker compose build && docker compose -p genlayer up ${options}"'`,
|
|
7
|
+
win32: `start cmd.exe /c "cd /d ${location} && docker compose build && docker compose -p genlayer up ${options} && pause"`,
|
|
8
|
+
linux: `nohup bash -c 'cd ${location} && docker compose build && docker compose -p genlayer up ${options} -d '`,
|
|
7
9
|
});
|
|
8
10
|
export const DEFAULT_RUN_DOCKER_COMMAND = {
|
|
9
11
|
darwin: "open -a Docker",
|
|
@@ -8,7 +8,6 @@ import pkg from '../../../package.json'
|
|
|
8
8
|
|
|
9
9
|
import {rpcClient} from "../clients/jsonRpcClient";
|
|
10
10
|
import {
|
|
11
|
-
DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX,
|
|
12
11
|
DEFAULT_RUN_SIMULATOR_COMMAND,
|
|
13
12
|
DEFAULT_RUN_DOCKER_COMMAND,
|
|
14
13
|
STARTING_TIMEOUT_WAIT_CYLCE,
|
|
@@ -16,6 +15,8 @@ import {
|
|
|
16
15
|
AI_PROVIDERS_CONFIG,
|
|
17
16
|
AiProviders,
|
|
18
17
|
VERSION_REQUIREMENTS,
|
|
18
|
+
CONTAINERS_NAME_PREFIX,
|
|
19
|
+
IMAGES_NAME_PREFIX
|
|
19
20
|
} from "../config/simulator";
|
|
20
21
|
import {
|
|
21
22
|
checkCommand,
|
|
@@ -254,7 +255,7 @@ export class SimulatorService implements ISimulatorService {
|
|
|
254
255
|
const containers = await this.docker.listContainers({ all: true });
|
|
255
256
|
const genlayerContainers = containers.filter(container =>
|
|
256
257
|
container.Names.some(name =>
|
|
257
|
-
name.startsWith(
|
|
258
|
+
name.startsWith(CONTAINERS_NAME_PREFIX)
|
|
258
259
|
)
|
|
259
260
|
);
|
|
260
261
|
|
|
@@ -271,7 +272,7 @@ export class SimulatorService implements ISimulatorService {
|
|
|
271
272
|
public async resetDockerImages(): Promise<boolean> {
|
|
272
273
|
const images = await this.docker.listImages();
|
|
273
274
|
const genlayerImages = images.filter(image =>
|
|
274
|
-
image.RepoTags?.some(tag => tag.startsWith(
|
|
275
|
+
image.RepoTags?.some(tag => tag.startsWith(IMAGES_NAME_PREFIX))
|
|
275
276
|
);
|
|
276
277
|
|
|
277
278
|
for (const imageInfo of genlayerImages) {
|
|
@@ -7,6 +7,7 @@ import {mkdtempSync} from "fs";
|
|
|
7
7
|
import {join} from "path";
|
|
8
8
|
import fs from "fs";
|
|
9
9
|
import * as dotenv from "dotenv";
|
|
10
|
+
import {localnetCompatibleVersion} from "../../src/lib/config/simulator";
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
vi.mock("fs");
|
|
@@ -14,7 +15,7 @@ vi.mock("dotenv");
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
const tempDir = mkdtempSync(join(tmpdir(), "test-initAction-"));
|
|
17
|
-
const defaultActionOptions = { numValidators: 5, branch: "main", location: tempDir, headless: false, resetDb: false, localnetVersion:
|
|
18
|
+
const defaultActionOptions = { numValidators: 5, branch: "main", location: tempDir, headless: false, resetDb: false, localnetVersion: localnetCompatibleVersion };
|
|
18
19
|
|
|
19
20
|
describe("init action", () => {
|
|
20
21
|
let error: ReturnType<any>;
|
|
@@ -3,13 +3,14 @@ import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
|
|
|
3
3
|
import { initializeGeneralCommands } from "../../src/commands/general";
|
|
4
4
|
import { getCommand, getCommandOption } from "../utils";
|
|
5
5
|
import simulatorService from '../../src/lib/services/simulator'
|
|
6
|
+
import {localnetCompatibleVersion} from "../../src/lib/config/simulator";
|
|
6
7
|
|
|
7
8
|
const openFrontendSpy = vi.spyOn(simulatorService, "openFrontend");
|
|
8
9
|
const defaultOptions = {
|
|
9
10
|
numValidators: "5",
|
|
10
11
|
headless: false,
|
|
11
12
|
resetDb: false,
|
|
12
|
-
localnetVersion:
|
|
13
|
+
localnetVersion: localnetCompatibleVersion
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
vi.mock("inquirer", () => ({
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
checkCommand,
|
|
11
11
|
} from "../../src/lib/clients/system";
|
|
12
12
|
import {
|
|
13
|
-
|
|
13
|
+
CONTAINERS_NAME_PREFIX,
|
|
14
14
|
VERSION_REQUIREMENTS,
|
|
15
15
|
STARTING_TIMEOUT_ATTEMPTS,
|
|
16
|
-
DEFAULT_RUN_SIMULATOR_COMMAND,
|
|
16
|
+
DEFAULT_RUN_SIMULATOR_COMMAND, localnetCompatibleVersion, IMAGES_NAME_PREFIX,
|
|
17
17
|
} from "../../src/lib/config/simulator";
|
|
18
18
|
import { rpcClient } from "../../src/lib/clients/jsonRpcClient";
|
|
19
19
|
import * as semver from "semver";
|
|
@@ -375,12 +375,12 @@ describe("SimulatorService - Docker Tests", () => {
|
|
|
375
375
|
const mockContainers = [
|
|
376
376
|
{
|
|
377
377
|
Id: "container1",
|
|
378
|
-
Names: [`${
|
|
378
|
+
Names: [`${CONTAINERS_NAME_PREFIX}container1`],
|
|
379
379
|
State: "running",
|
|
380
380
|
},
|
|
381
381
|
{
|
|
382
382
|
Id: "container2",
|
|
383
|
-
Names: [`${
|
|
383
|
+
Names: [`${CONTAINERS_NAME_PREFIX}container2`],
|
|
384
384
|
State: "exited",
|
|
385
385
|
},
|
|
386
386
|
{
|
|
@@ -417,11 +417,11 @@ describe("SimulatorService - Docker Tests", () => {
|
|
|
417
417
|
const mockImages = [
|
|
418
418
|
{
|
|
419
419
|
Id: "image1",
|
|
420
|
-
RepoTags: [`${
|
|
420
|
+
RepoTags: [`${IMAGES_NAME_PREFIX}image1:${localnetCompatibleVersion}`],
|
|
421
421
|
},
|
|
422
422
|
{
|
|
423
423
|
Id: "image2",
|
|
424
|
-
RepoTags: [`${
|
|
424
|
+
RepoTags: [`${IMAGES_NAME_PREFIX}image2:${localnetCompatibleVersion}`],
|
|
425
425
|
},
|
|
426
426
|
{
|
|
427
427
|
Id: "image3",
|