Skip to content

Commit

Permalink
feat(cli): flags to disable optional services (explorer, bundler, pay…
Browse files Browse the repository at this point in the history
…master)
  • Loading branch information
tuler committed Aug 6, 2024
1 parent 6c9967e commit 448fe60
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-cougars-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": minor
---

flags to disable optional services (explorer, bundler, paymaster)
30 changes: 28 additions & 2 deletions apps/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ export default class Run extends BaseCommand<typeof Run> {
description: "interval between blocks (in seconds)",
default: 5,
}),
"disable-explorer": Flags.boolean({
default: false,
description:
"disable local explorer service to save machine resources",
summary: "disable explorer service",
}),
"disable-bundler": Flags.boolean({
default: false,
description:
"disable local bundler service to save machine resources",
summary: "disable bundler service",
}),
"disable-paymaster": Flags.boolean({
default: false,
description:
"disable local paymaster service to save machine resources",
summary: "disable paymaster service",
}),
"epoch-length": Flags.integer({
description: "length of an epoch (in blocks)",
default: 720,
Expand Down Expand Up @@ -99,10 +117,18 @@ export default class Run extends BaseCommand<typeof Run> {
composeFiles.push("docker-compose-anvil.yaml");

// explorer
composeFiles.push("docker-compose-explorer.yaml");
if (!flags["disable-explorer"]) {
composeFiles.push("docker-compose-explorer.yaml");
}

// account abstraction
composeFiles.push("docker-compose-aa.yaml");
if (!flags["disable-bundler"]) {
composeFiles.push("docker-compose-bundler.yaml");
}
if (!flags["disable-paymaster"] && !flags["disable-bundler"]) {
// only add paymaster if bundler is enabled
composeFiles.push("docker-compose-paymaster.yaml");
}

// load the no-backend compose file
if (flags["no-backend"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,13 @@ services:
- "--polling-interval"
- "100"
- "--enable-debug-endpoints"

mock-verifying-paymaster:
image: cartesi/sdk:0.10.0
command: "mock-verifying-paymaster"
environment:
- ALTO_RPC=http://alto:4337
- ANVIL_RPC=http://anvil:8545

prompt:
image: debian:bookworm-slim
environment:
PROMPT_TXT_06_PAYMASTER: "Paymaster running at http://localhost:${CARTESI_LISTEN_PORT}/paymaster/"
PROMPT_TXT_07_BUNDLER: "Bundler running at http://localhost:${CARTESI_LISTEN_PORT}/bundler/"
PROMPT_TXT_06_BUNDLER: "Bundler running at http://localhost:${CARTESI_LISTEN_PORT}/bundler/rpc"

traefik-config-generator:
environment:
TRAEFIK_CONFIG_PAYMASTER: |
http:
routers:
paymaster:
rule: "PathPrefix(`/paymaster`)"
middlewares:
- "remove-paymaster-prefix"
service: paymaster
middlewares:
remove-paymaster-prefix:
replacePathRegex:
regex: "^/paymaster/(.*)"
replacement: "/$1"
services:
paymaster:
loadBalancer:
servers:
- url: "http://mock-verifying-paymaster:3000"
TRAEFIK_CONFIG_BUNDLER: |
http:
routers:
Expand Down
5 changes: 0 additions & 5 deletions apps/cli/src/node/docker-compose-database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ services:
retries: 5
environment:
- POSTGRES_PASSWORD=password

database_creator:
depends_on:
database:
condition: service_healthy
3 changes: 3 additions & 0 deletions apps/cli/src/node/docker-compose-explorer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ services:
database_creator:
image: postgres:15-alpine
command: ["createdb", "squid"]
depends_on:
database:
condition: service_healthy
environment:
PGHOST: ${PGHOST:-database}
PGPORT: ${PGPORT:-5432}
Expand Down
33 changes: 33 additions & 0 deletions apps/cli/src/node/docker-compose-paymaster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
mock-verifying-paymaster:
image: cartesi/sdk:0.10.0
command: "mock-verifying-paymaster"
environment:
- ALTO_RPC=http://alto:4337
- ANVIL_RPC=http://anvil:8545

prompt:
image: debian:bookworm-slim
environment:
PROMPT_TXT_07_PAYMASTER: "Paymaster running at http://localhost:${CARTESI_LISTEN_PORT}/paymaster/"

traefik-config-generator:
environment:
TRAEFIK_CONFIG_PAYMASTER: |
http:
routers:
paymaster:
rule: "PathPrefix(`/paymaster`)"
middlewares:
- "remove-paymaster-prefix"
service: paymaster
middlewares:
remove-paymaster-prefix:
replacePathRegex:
regex: "^/paymaster/(.*)"
replacement: "/$1"
services:
paymaster:
loadBalancer:
servers:
- url: "http://mock-verifying-paymaster:3000"

0 comments on commit 448fe60

Please sign in to comment.