Skip to content

Commit

Permalink
feat(cli): add --enable-espresso to cartesi run
Browse files Browse the repository at this point in the history
With that option you can start a espresso-dev-node integrated into the
cartesi development environment.
  • Loading branch information
endersonmaia committed Oct 1, 2024
1 parent bfe1fd4 commit 09cd9a7
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 9 deletions.
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 @@ export default class Run extends BaseCommand<typeof Run> {
"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 @@ export default class Run extends BaseCommand<typeof Run> {
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
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"
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
23 changes: 23 additions & 0 deletions espresso-notes.md
Original file line number Diff line number Diff line change
@@ -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
```
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

0 comments on commit 09cd9a7

Please sign in to comment.