From 418b8da05456e87c7da0e606549cd918098dc113 Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Fri, 27 Sep 2024 17:05:56 -0300 Subject: [PATCH] ip --- .changeset/odd-phones-grab.md | 5 ++ apps/cli/src/commands/run.ts | 10 +++ .../cli/src/node/docker-compose-database.yaml | 4 +- .../cli/src/node/docker-compose-espresso.yaml | 71 +++++++++++++++++++ .../cli/src/node/docker-compose-explorer.yaml | 2 +- espresso-notes.md | 23 ++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-phones-grab.md create mode 100644 apps/cli/src/node/docker-compose-espresso.yaml create mode 100644 espresso-notes.md diff --git a/.changeset/odd-phones-grab.md b/.changeset/odd-phones-grab.md new file mode 100644 index 00000000..7988dda0 --- /dev/null +++ b/.changeset/odd-phones-grab.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": minor +--- + +add espersso dev node 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-database.yaml b/apps/cli/src/node/docker-compose-database.yaml index fb661ab1..b56441c9 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 @@ -8,3 +8,5 @@ services: retries: 5 environment: - POSTGRES_PASSWORD=password + ports: + - 5432:5432 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..6e480c26 --- /dev/null +++ b/apps/cli/src/node/docker-compose-espresso.yaml @@ -0,0 +1,71 @@ +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: ghcr.io/espressosystems/espresso-sequencer/espresso-dev-node:20240925 + #image: espresso-dev-node:local + 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_MNEMONI: ${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: | + http: + routers: + espresso: + rule: "PathPrefix(`/espresso`)" + middlewares: + - "remove-espresso-prefix" + service: espresso + middlewares: + remove-espresso-prefix: + replacePathRegex: + regex: "^/espresso/(.*)" + replacement: "/$1" + services: + espresso: + loadBalancer: + servers: + - url: "http://espresso:8770" 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/espresso-notes.md b/espresso-notes.md new file mode 100644 index 00000000..959b78f1 --- /dev/null +++ b/espresso-notes.md @@ -0,0 +1,23 @@ +## Sequencer API + +### Status API + +```shell +curl -fsSL http://localhost:8770/status/block-height + +curl -fsSL http://localhost:8770/status/success-rate + +curl -fsSL http://localhost:8770/status/time-since-last-decide + +curl -fsSL http://localhost:8770/status/metrics +``` + +### Node API + +```shell +curl -fsSL http://localhost:8770/node/block-height + +curl -fsSL http://localhost:8770/node/transactions/count + +curl -fsSL http://localhost:8770/node/payloads/total-size +```