Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional espresso-dev-node to cartesi run #80

Open
wants to merge 1 commit into
base: feature/add-espresso-dev-node-to-sdk
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions .changeset/fresh-mangos-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": minor
---

add `--enable-espresso` to `cartesi run`
10 changes: 10 additions & 0 deletions apps/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"disable local paymaster service to save machine resources",
summary: "disable paymaster service",
}),
"enable-espresso": Flags.boolean({
default: false,
description: "enable Espresso development node ",
summary: "enable Espresso development node",
}),
"epoch-length": Flags.integer({
description: "length of an epoch (in blocks)",
default: 720,
Expand Down Expand Up @@ -153,6 +158,11 @@
composeFiles.push("docker-compose-paymaster.yaml");
}

// espresso development node
if (flags["enable-espresso"]) {
composeFiles.push("docker-compose-espresso.yaml");
}

// load the no-backend compose file
if (flags["no-backend"]) {
composeFiles.push("docker-compose-host.yaml");
Expand Down Expand Up @@ -208,7 +218,7 @@
});
} catch (e: unknown) {
// 130 is a graceful shutdown, so we can swallow it
if ((e as any).exitCode !== 130) {

Check warning on line 221 in apps/cli/src/commands/run.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
throw e;
}
} finally {
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/commands/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class Shell extends BaseCommand<typeof Shell> {
const ext2 = path.join(containerDir, path.basename(ext2Path));
const ramSize = "128Mi";
const driveLabel = "root";
const sdkImage = "cartesi/sdk:0.10.0"; // XXX: how to resolve sdk version?
const sdkImage = "cartesi/sdk:0.11.0"; // XXX: how to resolve sdk version?
const args = [
"run",
"--interactive",
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/src/node/docker-compose-anvil.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
anvil:
image: cartesi/sdk:0.10.0
image: cartesi/sdk:0.11.0
command:
[
"devnet",
Expand All @@ -19,7 +19,7 @@ services:
- 8545:8545

dapp_deployer:
image: cartesi/sdk:0.10.0
image: cartesi/sdk:0.11.0
restart: on-failure
depends_on:
anvil:
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/node/docker-compose-bundler.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
alto:
image: cartesi/sdk:0.10.0
image: cartesi/sdk:0.11.0
command:
- "alto"
- "--entrypoints"
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/node/docker-compose-database.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
database:
image: postgres:15-alpine
image: postgres:16-alpine
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres || exit 1"]
interval: 10s
Expand Down
124 changes: 124 additions & 0 deletions apps/cli/src/node/docker-compose-espresso.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
services:
espresso_database_creator:
image: postgres:16-alpine
command: ["createdb", "sequencer"]
depends_on:
database:
condition: service_healthy
environment:
PGHOST: ${PGHOST:-database}
PGPORT: ${PGPORT:-5432}
PGUSER: ${PGUSER:-postgres}
PGPASSWORD: ${PGPASSWORD:-password}
PGDATABASE: ${PGDATABASE:-postgres}

espresso:
image: cartesi/espresso:0.11.0
command: ["/usr/bin/espresso-dev-node"]
deploy:
resources:
limits:
cpus: "4"
memory: "1G"
ports:
- 8770:8770
- 8771:8771
- 8772:8772
- 20000:20000
depends_on:
espresso_database_creator:
condition: service_completed_successfully
database:
condition: service_healthy
environment:
ESPRESSO_SEQUENCER_L1_PROVIDER: ${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://anvil:8545}
ESPRESSO_SEQUENCER_API_PORT: 8770
ESPRESSO_BUILDER_PORT: 8771
ESPRESSO_PROVER_PORT: 8772
ESPRESSO_DEV_NODE_PORT: 20000
ESPRESSO_SEQUENCER_POSTGRES_HOST: database
ESPRESSO_SEQUENCER_POSTGRES_PORT: 5432
ESPRESSO_SEQUENCER_POSTGRES_USER: postgres
ESPRESSO_SEQUENCER_POSTGRES_PASSWORD: password
ESPRESSO_SEQUENCER_POSTGRES_DATABASE: sequencer
ESPRESSO_SEQUENCER_ETH_MNEMONIC: ${CARTESI_AUTH_MNEMONIC:-test test test test test test test test test test test junk}

prompt:
image: debian:bookworm-slim
environment:
PROMPT_TXT_07_ESPRESSO: "Espresso running at http://localhost:${CARTESI_LISTEN_PORT}/espresso/"

traefik-config-generator:
environment:
TRAEFIK_CONFIG_ESPRESSO_DEV: |
http:
routers:
espresso-dev:
rule: "PathPrefix(`/espresso/dev`)"
middlewares:
- "remove-espresso-dev-prefix"
service: espresso-dev
middlewares:
remove-espresso-dev-prefix:
replacePathRegex:
regex: "^/espresso/dev/(.*)"
replacement: "/$1"
services:
espresso-dev:
loadBalancer:
servers:
- url: "http://espresso:20000"
TRAEFIK_CONFIG_ESPRESSO_SEQUENCER: |
http:
routers:
espresso-sequencer:
rule: "PathPrefix(`/espresso/sequencer`)"
middlewares:
- "remove-espresso-sequencer-prefix"
service: espresso-sequencer
middlewares:
remove-espresso-sequencer-prefix:
replacePathRegex:
regex: "^/espresso/sequencer/(.*)"
replacement: "/$1"
services:
espresso-sequencer:
loadBalancer:
servers:
- url: "http://espresso:8770"
endersonmaia marked this conversation as resolved.
Show resolved Hide resolved
TRAEFIK_CONFIG_ESPRESSO_BUILDER: |
http:
routers:
espresso-builder:
rule: "PathPrefix(`/espresso/builder`)"
middlewares:
- "remove-espresso-builder-prefix"
service: espresso-builder
middlewares:
remove-espresso-builder-prefix:
replacePathRegex:
regex: "^/espresso/builder/(.*)"
replacement: "/$1"
services:
espresso-builder:
loadBalancer:
servers:
- url: "http://espresso:8771"
TRAEFIK_CONFIG_ESPRESSO_PROVER: |
http:
routers:
espresso-prover:
rule: "PathPrefix(`/espresso/prover`)"
middlewares:
- "remove-espresso-prover-prefix"
service: espresso-prover
middlewares:
remove-espresso-prover-prefix:
replacePathRegex:
regex: "^/espresso/prover/(.*)"
replacement: "/$1"
services:
espresso-prover:
loadBalancer:
servers:
- url: "http://espresso:8772"
2 changes: 1 addition & 1 deletion apps/cli/src/node/docker-compose-explorer.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
database_creator:
image: postgres:15-alpine
image: postgres:16-alpine
command: ["createdb", "squid"]
depends_on:
database:
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/node/docker-compose-paymaster.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
mock-verifying-paymaster:
image: cartesi/sdk:0.10.0
image: cartesi/sdk:0.11.0
command: "mock-verifying-paymaster"
environment:
- ALTO_RPC=http://alto:4337
Expand Down
4 changes: 2 additions & 2 deletions packages/mock-verifying-paymaster/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
anvil:
image: cartesi/sdk:0.10.0
image: cartesi/sdk:0.11.0
command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"]
healthcheck:
test: ["CMD", "eth_isready"]
Expand All @@ -13,7 +13,7 @@ services:
- 8545:8545

alto:
image: cartesi/sdk:0.10.0
image: cartesi/sdk:0.11.0
command:
[
"alto",
Expand Down
Loading