From 165e229197c93f73b46358f145ac110bc0447dda Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Fri, 27 Sep 2024 17:05:56 -0300 Subject: [PATCH 1/2] feat(cli): add `--enable-espresso` to `cartesi run` With that option you can start a espresso-dev-node integrated into the cartesi development environment. --- .changeset/fresh-mangos-wink.md | 5 + apps/cli/src/commands/run.ts | 10 ++ apps/cli/src/node/docker-compose-anvil.yaml | 4 +- apps/cli/src/node/docker-compose-bundler.yaml | 2 +- .../cli/src/node/docker-compose-database.yaml | 2 +- .../cli/src/node/docker-compose-espresso.yaml | 124 ++++++++++++++++++ .../cli/src/node/docker-compose-explorer.yaml | 2 +- .../src/node/docker-compose-paymaster.yaml | 2 +- .../docker-compose.yaml | 4 +- 9 files changed, 147 insertions(+), 8 deletions(-) create mode 100644 .changeset/fresh-mangos-wink.md create mode 100644 apps/cli/src/node/docker-compose-espresso.yaml diff --git a/.changeset/fresh-mangos-wink.md b/.changeset/fresh-mangos-wink.md new file mode 100644 index 00000000..0d91097a --- /dev/null +++ b/.changeset/fresh-mangos-wink.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": minor +--- + +add `--enable-espresso` to `cartesi run` diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index 4dd12bb6..a1d80f35 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -35,6 +35,11 @@ export default class Run extends BaseCommand { "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, @@ -153,6 +158,11 @@ export default class Run extends BaseCommand { 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"); diff --git a/apps/cli/src/node/docker-compose-anvil.yaml b/apps/cli/src/node/docker-compose-anvil.yaml index 219a771f..d2f64a32 100644 --- a/apps/cli/src/node/docker-compose-anvil.yaml +++ b/apps/cli/src/node/docker-compose-anvil.yaml @@ -1,6 +1,6 @@ services: anvil: - image: cartesi/sdk:0.12.0-alpha.1 + image: cartesi/sdk:0.12.0-alpha.3 command: [ "devnet", @@ -19,7 +19,7 @@ services: - 8545:8545 dapp_deployer: - image: cartesi/sdk:0.12.0-alpha.1 + image: cartesi/sdk:0.12.0-alpha.3 restart: on-failure depends_on: anvil: diff --git a/apps/cli/src/node/docker-compose-bundler.yaml b/apps/cli/src/node/docker-compose-bundler.yaml index 7237cc15..dd29c4cc 100644 --- a/apps/cli/src/node/docker-compose-bundler.yaml +++ b/apps/cli/src/node/docker-compose-bundler.yaml @@ -1,6 +1,6 @@ services: alto: - image: cartesi/sdk:0.12.0-alpha.1 + image: cartesi/sdk:0.12.0-alpha.3 command: - "alto" - "--entrypoints" diff --git a/apps/cli/src/node/docker-compose-database.yaml b/apps/cli/src/node/docker-compose-database.yaml index fb661ab1..e5a66dc4 100644 --- a/apps/cli/src/node/docker-compose-database.yaml +++ b/apps/cli/src/node/docker-compose-database.yaml @@ -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 diff --git a/apps/cli/src/node/docker-compose-espresso.yaml b/apps/cli/src/node/docker-compose-espresso.yaml new file mode 100644 index 00000000..7739615b --- /dev/null +++ b/apps/cli/src/node/docker-compose-espresso.yaml @@ -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/sdk:0.12.0-alpha.3 + command: ["/usr/local/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" + 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" diff --git a/apps/cli/src/node/docker-compose-explorer.yaml b/apps/cli/src/node/docker-compose-explorer.yaml index f73b2fb2..716a7a9e 100644 --- a/apps/cli/src/node/docker-compose-explorer.yaml +++ b/apps/cli/src/node/docker-compose-explorer.yaml @@ -1,6 +1,6 @@ services: database_creator: - image: postgres:15-alpine + image: postgres:16-alpine command: ["createdb", "squid"] depends_on: database: diff --git a/apps/cli/src/node/docker-compose-paymaster.yaml b/apps/cli/src/node/docker-compose-paymaster.yaml index 4c9bf35e..3b819afe 100644 --- a/apps/cli/src/node/docker-compose-paymaster.yaml +++ b/apps/cli/src/node/docker-compose-paymaster.yaml @@ -1,6 +1,6 @@ services: mock-verifying-paymaster: - image: cartesi/sdk:0.12.0-alpha.1 + image: cartesi/sdk:0.12.0-alpha.3 command: "mock-verifying-paymaster" environment: - ALTO_RPC=http://alto:4337 diff --git a/packages/mock-verifying-paymaster/docker-compose.yaml b/packages/mock-verifying-paymaster/docker-compose.yaml index 4ab09ca9..722c74cb 100644 --- a/packages/mock-verifying-paymaster/docker-compose.yaml +++ b/packages/mock-verifying-paymaster/docker-compose.yaml @@ -1,6 +1,6 @@ services: anvil: - image: cartesi/sdk:0.12.0-alpha.1 + image: cartesi/sdk:0.12.0-alpha.3 command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"] healthcheck: test: ["CMD", "eth_isready"] @@ -13,7 +13,7 @@ services: - 8545:8545 alto: - image: cartesi/sdk:0.12.0-alpha.1 + image: cartesi/sdk:0.12.0-alpha.3 command: [ "alto", From 5747f6473974697cbd71bf4de77a2d3386385ad1 Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Thu, 23 Jan 2025 11:40:25 -0300 Subject: [PATCH 2/2] fixup! feat(cli): add `--enable-espresso` to `cartesi run` --- apps/cli/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cli/src/config.ts b/apps/cli/src/config.ts index 6ecbfe08..19d12e78 100644 --- a/apps/cli/src/config.ts +++ b/apps/cli/src/config.ts @@ -74,7 +74,7 @@ export class InvalidStringArrayError extends Error { const DEFAULT_FORMAT = "ext2"; const DEFAULT_RAM = "128Mi"; const DEFAULT_RAM_IMAGE = "/usr/share/cartesi-machine/images/linux.bin"; -export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.1"; +export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.3"; type Builder = "directory" | "docker" | "empty" | "none" | "tar"; type DriveFormat = "ext2" | "sqfs";