Skip to content

Commit a0cc1ef

Browse files
committed
feat(cli): porto service
1 parent d4579f8 commit a0cc1ef

File tree

8 files changed

+211
-3
lines changed

8 files changed

+211
-3
lines changed

apps/cli/src/commands/start.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ const availableServices: Service[] = [
118118
waitTitle: `${chalk.cyan("passkey")} service starting...`,
119119
errorTitle: `${chalk.red("passkey")} service failed`,
120120
},
121+
{
122+
name: "porto",
123+
file: "docker-compose-porto.yaml",
124+
healthySemaphore: "porto-relay",
125+
healthyTitle: (port) =>
126+
`${chalk.cyan("porto")} service ready at ${chalk.cyan(`${host}:${port}/porto/{rpc,dialog,manager}`)}`,
127+
waitTitle: `${chalk.cyan("porto")} service starting...`,
128+
errorTitle: `${chalk.red("porto")} service failed`,
129+
},
121130
];
122131

123132
const serviceMonitorTask = (options: {

apps/cli/src/compose/docker-compose-anvil.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
anvil:
33
image: ${CARTESI_SDK_IMAGE}
4-
command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"]
4+
command: ["devnet", "--odyssey", "--block-time", "${BLOCK_TIME:-5}"]
55
healthcheck:
66
test: ["CMD", "eth_isready"]
77
start_period: 10s
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
services:
2+
porto-relay:
3+
image: ghcr.io/ithacaxyz/relay:3fc0de2
4+
platform: linux/x86_64
5+
depends_on:
6+
anvil:
7+
condition: service_healthy
8+
expose:
9+
- 9119
10+
environment:
11+
RUST_LOG: warn
12+
RELAY_MNEMONIC: ${CARTESI_AUTH_MNEMONIC:-test test test test test test test test test test test junk}
13+
command: ["--config-only"]
14+
healthcheck:
15+
test:
16+
[
17+
"CMD",
18+
"cast",
19+
"rpc",
20+
"--rpc-url",
21+
"http://localhost:9119",
22+
"health",
23+
]
24+
interval: 2s
25+
retries: 5
26+
volumes:
27+
- ./porto:/app
28+
29+
porto-rpc:
30+
image: oven/bun:latest
31+
expose:
32+
- 9220
33+
volumes:
34+
- ./porto/proxy.ts:/app/proxy.ts
35+
command: ["bun", "run", "/app/proxy.ts"]
36+
depends_on:
37+
anvil:
38+
condition: service_healthy
39+
environment:
40+
PORT: 9220
41+
RELAY_URL: http://porto-relay:9119
42+
ANVIL_URL: http://anvil:8545
43+
44+
porto-dialog:
45+
image: ${CARTESI_SDK_IMAGE}
46+
command:
47+
["busybox", "httpd", "-f", "-h", "/usr/share/porto/dialog", "-vv"]
48+
expose:
49+
- 80
50+
healthcheck:
51+
test: ["CMD", "curl", "-fsS", "http://127.0.0.1/"]
52+
start_period: 10s
53+
start_interval: 200ms
54+
interval: 10s
55+
timeout: 1s
56+
retries: 5
57+
58+
porto-manager:
59+
image: ${CARTESI_SDK_IMAGE}
60+
command:
61+
["busybox", "httpd", "-f", "-h", "/usr/share/porto/manager", "-vv"]
62+
expose:
63+
- 80
64+
healthcheck:
65+
test: ["CMD", "curl", "-fsS", "http://127.0.0.1/"]
66+
start_period: 10s
67+
start_interval: 200ms
68+
interval: 10s
69+
timeout: 1s
70+
retries: 5
71+
72+
proxy:
73+
volumes:
74+
- ./proxy/porto.yaml:/etc/traefik/conf.d/porto.yaml

apps/cli/src/compose/docker-compose-proxy.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
proxy:
3-
image: traefik:v3.3.4
3+
image: traefik:v3.4.1
44
healthcheck:
55
test: ["CMD", "traefik", "healthcheck", "--ping"]
66
start_period: 10s
@@ -18,7 +18,8 @@ services:
1818
"--providers.file.directory=/etc/traefik/conf.d",
1919
"--providers.file.watch=true",
2020
"--log",
21-
"--log.level=INFO",
21+
"--log.level=DEBUG",
22+
"--accesslog=true",
2223
]
2324
ports:
2425
- ${CARTESI_LISTEN_PORT:-6751}:8088
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Bun.serve({
2+
async fetch(request) {
3+
if (request.method === "GET") return new Response("Nada");
4+
5+
const body = await request.json();
6+
const target =
7+
body.method &&
8+
(body.method.startsWith("wallet_") || body.method === "health")
9+
? Bun.env.RELAY_URL!
10+
: Bun.env.ANVIL_URL!;
11+
return fetch(target, {
12+
body: JSON.stringify(body),
13+
headers: {
14+
"Content-Type": "application/json",
15+
},
16+
method: "POST",
17+
});
18+
},
19+
port: Number(Bun.env.PORT!),
20+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"13370":
2+
- address: 0x700b6A60ce7EaaEA56F065753d8dcB9653dbAD35
3+
kind: USDT
4+
- address: 0xA15BB66138824a1c7167f5E85b957d04Dd34E468
5+
kind: USDT
6+
- kind: ETH
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
server:
2+
address: 0.0.0.0
3+
port: 9119
4+
metrics_port: 9120
5+
max_connections: 5000
6+
chain:
7+
endpoints:
8+
- http://anvil:8545
9+
sequencer_endpoints: {}
10+
fee_tokens:
11+
- "0x0000000000000000000000000000000000000000"
12+
- "0x700b6A60ce7EaaEA56F065753d8dcB9653dbAD35"
13+
- "0xA15BB66138824a1c7167f5E85b957d04Dd34E468"
14+
fee_recipient: "0x0000000000000000000000000000000000000000"
15+
quote:
16+
constantRate: 1.0
17+
gas:
18+
intentBuffer: 100000
19+
txBuffer: 100000
20+
ttl: 30
21+
rateTtl: 300
22+
onramp:
23+
banxa:
24+
apiUrl: https://api.banxa-sandbox.com/
25+
blockchain: base
26+
secrets:
27+
api_key: ""
28+
transactions:
29+
num_signers: 16
30+
max_pending_transactions: 100
31+
max_transactions_per_signer: 16
32+
max_queued_per_eoa: 1
33+
balance_check_interval: 5
34+
nonce_check_interval: 60
35+
transaction_timeout: 60
36+
public_node_endpoints: {}
37+
priority_fee_percentile: 20
38+
orchestrator: "0xA16c8d51c3E2e80509489eF5147d30b33Af4E233"
39+
legacy_orchestrators: []
40+
legacy_delegations: []
41+
delegation_proxy: "0x4F3Ab48173433c831741262Ac71B6c78D6d0C622"
42+
simulator: "0xDe8e1bF42165bB8223DC3889AE0901D966834F41"
43+
database_url: null
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
http:
2+
routers:
3+
porto-rpc:
4+
rule: "Path(`/porto/rpc`)"
5+
middlewares:
6+
- cors
7+
- remove-porto-rpc-prefix
8+
service: porto-rpc
9+
porto-dialog:
10+
rule: "PathPrefix(`/porto/dialog`)"
11+
middlewares:
12+
- remove-porto-dialog-prefix
13+
service: porto-dialog
14+
porto-manager:
15+
rule: "PathPrefix(`/porto/manager`)"
16+
middlewares:
17+
- remove-porto-manager-prefix
18+
service: porto-manager
19+
middlewares:
20+
remove-porto-rpc-prefix:
21+
replacePathRegex:
22+
regex: "^/porto/rpc"
23+
replacement: ""
24+
remove-porto-dialog-prefix:
25+
replacePathRegex:
26+
regex: "^/porto/dialog/(.*)"
27+
replacement: "/$1"
28+
remove-porto-manager-prefix:
29+
replacePathRegex:
30+
regex: "^/porto/manager/(.*)"
31+
replacement: "/$1"
32+
cors:
33+
headers:
34+
accessControlAllowMethods:
35+
- GET
36+
- OPTIONS
37+
- PUT
38+
accessControlAllowHeaders: "*"
39+
accessControlAllowOriginList:
40+
- "*"
41+
accessControlMaxAge: 100
42+
addVaryHeader: true
43+
services:
44+
porto-rpc:
45+
loadBalancer:
46+
servers:
47+
- url: "http://porto-rpc:9220"
48+
porto-dialog:
49+
loadBalancer:
50+
servers:
51+
- url: "http://porto-dialog:80"
52+
porto-manager:
53+
loadBalancer:
54+
servers:
55+
- url: "http://porto-manager:80"

0 commit comments

Comments
 (0)