Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add espresso-reader #150

Draft
wants to merge 8 commits into
base: feature/cli-run-v2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class InvalidStringArrayError extends Error {
const DEFAULT_FORMAT = "ext2";
const DEFAULT_RAM = "128Mi";
const DEFAULT_RAM_IMAGE = "/usr/share/cartesi-machine/images/linux.bin";
export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.5";
export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.6";

type Builder = "directory" | "docker" | "empty" | "none" | "tar";
type DriveFormat = "ext2" | "sqfs";
Expand Down
2 changes: 1 addition & 1 deletion 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.12.0-alpha.5
image: cartesi/sdk:0.12.0-alpha.6
command:
[
"devnet",
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.12.0-alpha.5
image: cartesi/sdk:0.12.0-alpha.6
command:
- "alto"
- "--entrypoints"
Expand Down
6 changes: 6 additions & 0 deletions apps/cli/src/node/docker-compose-envfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ services:
validator:
env_file:
- ./.cartesi.env
espresso_reader:
env_file:
- ./.cartesi.env
espresso:
env_file:
- ./.cartesi.env
70 changes: 69 additions & 1 deletion apps/cli/src/node/docker-compose-espresso.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,56 @@ services:
validator:
environment:
CARTESI_FEATURE_INPUT_READER_ENABLED: false

espresso_reader_migrate:
image: golang:1.23
command:
- /bin/bash
- -c
- |
git clone --depth 1 https://github.com/cartesi/rollups-espresso-reader.git --branch v0.2.1-node-20250128
cd rollups-espresso-reader
make migrate
env_file:
- ${CARTESI_BIN_PATH}/node/default.env
depends_on:
database:
condition: service_healthy
environment:
DATABASE_URL: postgres://postgres:password@database:5432/espresso_reader

espresso_reader:
image: cartesi/sdk:0.12.0-alpha.6
command: "cartesi-rollups-espresso-reader"
ports:
- 8081
depends_on:
espresso_reader_migrate:
condition: service_completed_successfully
espresso:
condition: service_healthy
env_file:
- ${CARTESI_BIN_PATH}/node/default.env
environment:
ESPRESSO_SERVICE_ENDPOINT: ":8081"
ESPRESSO_BASE_URL: http://espresso:8770
ESPRESSO_NAMESPACE: 51025
ESPRESSO_STARTING_BLOCK: 101

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rollups-espresso-reader does a weird thing: it publishes two endpoints /nonce and /submit on a port configurable with env ESPRESSO_SERVICE_ENDPOINT (default I think is 8080). We'd need to expose these too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about this format?

  • /espresso/reader/nonce
  • /espresso/reader/submit

If the developer interaction if gonna be focused on those endpoints, we could even hide everything from espresso-dev-node and only publish those at /espresso/submit and /espresso/nonce, also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miltonjonat I sent a fixup where you can access those endpoints at:

  • http://localhost:8080/espresso/reader/nonce
  • http://localhost:8080/espresso/reader/submit

Please, let me know if it works!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, these endpoints are currently conveniences for the Espresso integration, and strictly speaking they could (or should?) be part of another component separate from the reader itself. So, no, I wouldn't use "reader" there.

Frankly, I think it's also quite odd to put it under "espresso" in this context, because that "espresso" there is meant to be the (local) Espresso Network, while these are endpoints on the Node itself.

Tbh, the idea here was also that the Node would provide /nonce and /submit functionalities as something more universal (i.e., to also be used when integrated with Avail, Celestia, etc). And that clients wouldn't even know which alt-DA was being used by the app/node.

TL;DR, I'd use http://localhost:8080/nonce and http://localhost:8080/submit directly; or we could come up with a nice namespace for convenience endpoints of this kind (maybe http://localhost:8080/tx/nonce?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand there is no unified way to send a transaction. anvil expects ethereum transactions as specified by eth_sendTransaction, espresso expects a transaction object, avail has its own spec.

So having a single /nonce and /submit at the root of the service, regardless the configured DA, with various formats will be extremely confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm exposing those espresso-dev-node ports to the host to test if thins are working, but they should be removed on the final version of this PR togethers with the /espresso endpoints for the proxy.

About the /nonce and /submit endpoints from the espresso-reader, I need a definition so I can apply in this PR.

Copy link

@miltonjonat miltonjonat Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand there is no unified way to send a transaction. anvil expects ethereum transactions as specified by eth_sendTransaction, espresso expects a transaction object, avail has its own spec.

So having a single /nonce and /submit at the root of the service, regardless the configured DA, with various formats will be extremely confusing.

I see this differently. With Paio, we standardized an EIP-712 structure to be used when submitting tx's. This structure includes the target chainId and app address, nonce, and envisions payment info too. Avail and Celestia integrations would use this via Paio, and we adopted it for the Espresso integration as well (Espresso itself doesn't have any spec on the payload you submit, which doesn't even need to be signed atm). The idea is that you would use /nonce and /submit for all L2 tx submissions (i.e., that use Paio / alt-DA), while of course clients would still send direct L1 Eth tx's via the InputBox for L1->L2 messages.

Now, another interesting discussion would be to provide a standard Eth JSON-RPC API on the Node for these L2 tx's. I'd like that, but I don't know how viable it is. It would be part of that redesign discussion for all this architecture.

Copy link

@miltonjonat miltonjonat Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, one path what would be very adherent to the current architecture would be something like L2tx, leading to http://localhost:8080/L2tx/nonce and http://localhost:8080/L2tx/submit (I suggested tx above, but I admit that L2tx would be more precise)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you going to use a single format for DAs with different requirements?
I.e. how do you define the namespace in case of Espresso?

Copy link

@miltonjonat miltonjonat Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current design, the client/user does not inform any DA-specific parameters in the payload it submits. Whatever is required to submit to the alt-DA configured for the application should be given by DA-specific parameters defined upon deployment of the app, and stored as on-chain app configuration. The Node will fetch that from the application contract (it's currently defined as an ABI encoded method+parameters), and thus know how to handle tx submission when /submit is called.


espresso:
image: cartesi/sdk:0.12.0-alpha.3
image: cartesi/sdk:0.12.0-alpha.6
command: ["/usr/local/bin/espresso-dev-node"]
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:8770/v0/status/block-height",
]
interval: 10s
timeout: 1s
retries: 5
deploy:
resources:
limits:
Expand All @@ -33,6 +80,8 @@ services:
condition: service_completed_successfully
database:
condition: service_healthy
anvil:
condition: service_healthy
environment:
ESPRESSO_SEQUENCER_L1_PROVIDER: ${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://anvil:8545}
ESPRESSO_SEQUENCER_API_PORT: 8770
Expand Down Expand Up @@ -125,3 +174,22 @@ services:
loadBalancer:
servers:
- url: "http://espresso:8772"

TRAEFIK_CONFIG_ESPRESSO_READER: |
http:
routers:
espresso-reader:
rule: "PathPrefix(`/espresso/reader`)"
middlewares:
- "remove-espresso-reader-prefix"
service: espresso-reader
middlewares:
remove-espresso-reader-prefix:
replacePathRegex:
regex: "^/espresso/reader/(.*)"
replacement: "/$1"
services:
espresso-reader:
loadBalancer:
servers:
- url: "http://espresso_reader:8081"
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.12.0-alpha.5
image: cartesi/sdk:0.12.0-alpha.6
command: "mock-verifying-paymaster"
environment:
- ALTO_RPC=http://alto:4337
Expand Down
Loading