Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ HARDHAT_URL = 'http://hardhat'
HARDHAT_PORT = '8545'
HARDHAT_PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
HARDHAT_CHAIN_ID=61999
GENLAYER_CHAIN_ID=61127
COMPOSE_PROFILES='hardhat'

BACKEND_BUILD_TARGET = 'debug'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ OPTIONS:

EXAMPLES:
genlayer init
genlayer init --numValidators 10 --headless --reset-db --localnet-version v0.10.2
genlayer init --numValidators 10 --headless --reset-db --localnet-version v0.123.0
genlayer init --ollama
```

Expand All @@ -71,7 +71,7 @@ EXAMPLES:
The GenLayer CLI always uses the latest compatible version of the environment, ensuring that you benefit from the most recent features, bug fixes, and optimizations without requiring manual updates. If a specific version is needed, you can specify it using the --localnet-version option when initializing the environment.

```bash
genlayer init --localnet-version v0.10.2
genlayer init --localnet-version v0.123.0
```

#### Start GenLayer environment
Expand Down
68 changes: 57 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- RPCDEBUGPORT=${RPCDEBUGPORT:-5001}
- WEBDRIVERHOST=${WEBDRIVERHOST:-webdriver}
- WEBDRIVERPORT=${WEBDRIVERPORT:-4444}
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
ports:
- "${RPCPORT:-5000}:${RPCPORT:-5000}"
- "${RPCDEBUGPORT:-5001}:${RPCDEBUGPORT:-5001}"
Expand All @@ -44,12 +45,14 @@ services:
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
start_period: 300s
depends_on:
database-migration:
condition: service_completed_successfully
webdriver:
condition: service_healthy
condition: service_healthy
redis:
condition: service_healthy
expose:
- "${RPCPORT:-5000}"
restart: always
Expand All @@ -63,6 +66,7 @@ services:
deploy:
replicas: ${JSONRPC_REPLICAS:-1}
volumes:
- genvm_cache:/genvm-cache
- hardhat_artifacts:/app/hardhat/artifacts
- hardhat_deployments:/app/hardhat/deployments

Expand Down Expand Up @@ -130,23 +134,65 @@ services:
image: yeagerai/simulator-database-migration:${LOCALNETVERSION:-latest}
environment:
- DB_URL=postgresql://${DBUSER:-postgres}:${DBPASSWORD:-postgres}@postgres/${DBNAME:-simulator_db}
- DBUSER=${DBUSER:-postgres}
- DBPASSWORD=${DBPASSWORD:-postgres}
- DBHOST=${DBHOST:-postgres}
- DBPORT=${DBPORT:-5432}
- DBNAME=${DBNAME:-simulator_db}
depends_on:
postgres:
condition: service_healthy

hardhat:
image: yeagerai/simulator-hardhat:${LOCALNETVERSION:-latest}
ports:
- "${HARDHAT_PORT:-8545}:8545"
consensus-worker:
image: yeagerai/simulator-consensus-worker:${LOCALNETVERSION:-latest}
environment:
- HARDHAT_NETWORK=hardhat
- PYTHONUNBUFFERED=1
- WORKER_PORT=4001
- WEBDRIVERHOST=${WEBDRIVERHOST:-webdriver}
- WEBDRIVERPORT=${WEBDRIVERPORT:-4444}
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
env_file:
- ./.env
volumes:
- hardhat_artifacts:/app/artifacts
- hardhat_deployments:/app/deployments
- hardhat_cache:/app/cache
- hardhat_snapshots:/app/snapshots
- genvm_cache:/genvm-cache
depends_on:
database-migration:
condition: service_completed_successfully
webdriver:
condition: service_healthy
redis:
condition: service_healthy
jsonrpc:
condition: service_healthy
deploy:
replicas: ${CONSENSUS_WORKERS:-1}
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"

redis:
image: redis:8-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
restart: always
security_opt:
- "no-new-privileges=true"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"

volumes:
genvm_cache:
hardhat_artifacts:
hardhat_deployments:
hardhat_cache:
Expand Down
2 changes: 1 addition & 1 deletion docs/api-references/environment/init.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Initialize the GenLayer Environment
| | --numValidators <numValidators> | Number of validators | No | `5` |
| | --headless | Headless mode | No | `false` |
| | --reset-db | Reset Database | No | `false` |
| | --localnet-version <localnetVersion> | Select a specific localnet version (minimum: v0.65.0) | No | `v0.65.0` |
| | --localnet-version <localnetVersion> | Select a specific localnet version (minimum: v0.123.0) | No | `v0.123.0` |
| | --ollama | Enable Ollama container | No | `false` |
| -h | --help | display help for command | No | |
4 changes: 2 additions & 2 deletions src/lib/config/simulator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const localnetCompatibleVersion = "v0.65.0";
export const localnetCompatibleVersion = "v0.123.0";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Default to a published Studio image tag

For a fresh installation, plain genlayer init now selects v0.123.0, but the commit's validation notes explicitly state that those stable images have not been published and only v0.123.0-rc.10 is usable. src/commands/general/index.ts uses this constant as the option default, and InitAction.execute() writes it directly to LOCALNETVERSION, which selects the service image tags in docker-compose.yml. Consequently, the default initialization fails to pull its images after already resetting the user's existing localnet. Use the published release-candidate tag as the default (separating the minimum-version constant if necessary), or publish the stable images before changing the default.

Useful? React with 👍 / 👎.

export const DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
export const CONTAINERS_NAME_PREFIX = "/genlayer-";
export const IMAGES_NAME_PREFIX = "yeagerai";
Expand Down Expand Up @@ -63,6 +63,6 @@ export const AI_PROVIDERS_CONFIG: AiProvidersConfigType = {

export const GENLAYER_REQUIRED_CONTAINERS = [
"genlayer-jsonrpc",
"genlayer-webrequest",
"genlayer-consensus-worker",
"genlayer-postgres"
]
19 changes: 19 additions & 0 deletions src/lib/services/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
- "anvil-local:host-gateway"
consensus-worker:
volumes:
- ./config-overrides/genvm-module-web.yaml:/genvm/config/genvm-module-web.yaml:ro
extra_hosts:
- "host.docker.internal:host-gateway"
- "anvil-local:host-gateway"
`;
fs.writeFileSync(overridePath, overrideContent);

Expand All @@ -358,7 +364,20 @@ services:
}

const genvmConfigPath = path.join(configDir, 'genvm-module-web.yaml');
// The backend replaces (not merges) the image's web config, so every field of the GenVM schema must be present.
const genvmConfigContent = `# Auto-generated by genlayer CLI — allows GenVM to reach localhost services
bind_address: 127.0.0.1:3032
webdriver_host: http://127.0.0.1:4444
lua_script_path: \${exeDir}/../config/genvm-web-default.lua
vm_count: 6
lua_path: \${exeDir}/../lib/genvm-lua/?.lua
data_dir: \${exeDir}/../data
signer_url: '#{signerUrl}'
signer_headers: {}
threads: 4
blocking_threads: 16
log_disable: ''
extra_tld: []
always_allow_hosts:
- "localhost"
- "127.0.0.1"
Expand Down
47 changes: 45 additions & 2 deletions tests/services/simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ describe("SimulatorService - Docker Tests", () => {
test("isLocalnetRunning should return true when all required containers are running", async () => {
const mockContainers = [
{Id: "container1", Names: ["/genlayer-jsonrpc1"], State: "running"},
{Id: "container2", Names: ["/genlayer-webrequest1"], State: "running"},
{Id: "container2", Names: ["/genlayer-consensus-worker1"], State: "running"},
{Id: "container3", Names: ["/genlayer-postgres1"], State: "running"},
{Id: "container4", Names: ["/genlayer-other-container1"], State: "running"},
{Id: "container5", Names: ["/genlayer-another-container1"], State: "exited"},
Expand All @@ -389,7 +389,7 @@ describe("SimulatorService - Docker Tests", () => {
test("isLocalnetRunning should return false when not all required containers are running", async () => {
const mockContainers = [
{Id: "container1", Names: ["/genlayer-jsonrpc2"], State: "running"},
{Id: "container2", Names: ["/genlayer-webrequest2"], State: "running"},
{Id: "container2", Names: ["/genlayer-consensus-worker2"], State: "running"},
{Id: "container3", Names: ["/genlayer-postgres2"], State: "exited"},
{Id: "container4", Names: ["/genlayer-other-container2"], State: "running"},
{Id: "container5", Names: ["/unrelated-container2"], State: "running"},
Expand Down Expand Up @@ -743,6 +743,49 @@ describe("setupLocalhostAccess", () => {
consoleWarnSpy.mockRestore();
});

test("should mount the web override on the consensus worker", () => {
vi.mocked(fs.existsSync).mockReturnValue(true);
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});

simulatorService.setupLocalhostAccess();

const overrideCall = vi.mocked(fs.writeFileSync).mock.calls.find(c =>
(c[0] as string).includes("docker-compose.override.yml")
);
const content = overrideCall![1] as string;
const workerSection = content.slice(content.indexOf("consensus-worker:"));
expect(content).toContain("consensus-worker:");
expect(workerSection).toContain("genvm-module-web.yaml:/genvm/config/genvm-module-web.yaml:ro");
expect(workerSection).toContain("host.docker.internal:host-gateway");

consoleWarnSpy.mockRestore();
});

test("should write a complete GenVM web module config", () => {
vi.mocked(fs.existsSync).mockReturnValue(true);
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});

simulatorService.setupLocalhostAccess();

const configCall = vi.mocked(fs.writeFileSync).mock.calls.find(c =>
(c[0] as string).includes("genvm-module-web.yaml")
);
expect(configCall).toBeDefined();
const content = configCall![1] as string;
for (const field of [
"bind_address:",
"webdriver_host:",
"lua_script_path:",
"signer_url:",
"extra_tld:",
"always_allow_hosts:",
]) {
expect(content).toContain(field);
}

consoleWarnSpy.mockRestore();
});

test("should create config-overrides directory if it does not exist", () => {
vi.mocked(fs.existsSync).mockReturnValue(false);
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
Expand Down
Loading