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/commands/shell.ts b/apps/cli/src/commands/shell.ts index 3c8a928b..29b1308a 100644 --- a/apps/cli/src/commands/shell.ts +++ b/apps/cli/src/commands/shell.ts @@ -33,7 +33,7 @@ export default class Shell extends BaseCommand { 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", diff --git a/apps/cli/src/node/docker-compose-anvil.yaml b/apps/cli/src/node/docker-compose-anvil.yaml index 8b507aa8..fc209260 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.10.0 + image: cartesi/sdk:0.11.0 command: [ "devnet", @@ -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: diff --git a/apps/cli/src/node/docker-compose-bundler.yaml b/apps/cli/src/node/docker-compose-bundler.yaml index 3295d207..b45fb65d 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.10.0 + image: cartesi/sdk:0.11.0 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..97314b8f --- /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/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" + 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 6829ed3a..b88aac51 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.10.0 + image: cartesi/sdk:0.11.0 command: "mock-verifying-paymaster" environment: - ALTO_RPC=http://alto:4337 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 +``` diff --git a/packages/mock-verifying-paymaster/docker-compose.yaml b/packages/mock-verifying-paymaster/docker-compose.yaml index e38bfa1e..c3e3b950 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.10.0 + image: cartesi/sdk:0.11.0 command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"] healthcheck: test: ["CMD", "eth_isready"] @@ -13,7 +13,7 @@ services: - 8545:8545 alto: - image: cartesi/sdk:0.10.0 + image: cartesi/sdk:0.11.0 command: [ "alto",