Skip to content

Conversation

@endersonmaia
Copy link
Contributor

@endersonmaia endersonmaia commented Feb 3, 2025

You can test this with:

pnpm build --filter @cartesi/cli
alias cartesi-dev=$PWD/apps/cli/dist/index.js
cartesi-dev create --branch=prerelease/sdk-12 --template=go my-go-dapp-v2 
cd my-go-dapp-v2
cartesi-dev build
cartesi-dev rollups start --services espresso,graphql
cartesi-dev rollups deploy

The rollups-espresso-reader endpoints should be available at:

@endersonmaia endersonmaia self-assigned this Feb 3, 2025
@changeset-bot
Copy link

changeset-bot bot commented Feb 3, 2025

🦋 Changeset detected

Latest commit: 79f7ac7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@endersonmaia endersonmaia marked this pull request as draft February 3, 2025 19:24
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2025

Coverage Report for ./apps/cli

Status Category Percentage Covered / Total
🔵 Lines 27.46% 293 / 1067
🔵 Statements 27.41% 298 / 1087
🔵 Functions 27.27% 51 / 187
🔵 Branches 25.74% 121 / 470
File CoverageNo changed files found.
Generated in workflow #387 for commit 79f7ac7 by the Vitest Coverage Report Action

@endersonmaia endersonmaia force-pushed the feature/add-espresso-reader-to-cli branch from 0a1e320 to 4bf2c98 Compare February 4, 2025 14:42
@miltonjonat
Copy link

Instructions fixing typos :)

pnpm build --filter @cartesi/cli
alias cartesi-dev=$PWD/apps/cli/bin/run.js
cartesi-dev create --branch=prerelease/sdk-12 --template=go my-go-dapp-v2 
cd my-go-dapp-v2
cartesi-dev build
cartesi-dev run --enable-espresso

Copy link

@miltonjonat miltonjonat left a comment

Choose a reason for hiding this comment

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

I couldn't access the espresso endpoint on http://localhost:8080/espresso, only directly on http://localhost:8770. Is that expected?

@endersonmaia
Copy link
Contributor Author

I couldn't access the espresso endpoint on http://localhost:8080/espresso, only directly on http://localhost:8770. Is that expected?

It's missing some instructions. We expose 4 espresso API endpoints via names PATHs, they are:

  • http://localhost:8080/espresso/sequencer
  • http://localhost:8080/espresso/builder
  • http://localhost:8080/espresso/prover
  • http://localhost:8080/espresso/dev

So if you wanna call the /v0/status/block-height you should call

curl http://localhost:8080/espresso/sequencer/v0/status/block-height

DATABASE_URL: postgres://postgres:password@database:5432/espresso_reader
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

@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.

Copy link

@miltonjonat miltonjonat Mar 17, 2025

Choose a reason for hiding this comment

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

Coming back to this from the discussions on #171, I'm now thinking that a path that would make sense would be http://localhost:8080/eip712/nonce and http://localhost:8080/eip712/submit

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

EIP-712 is a typed structured data hashing and signing standard. I don't think it should be the name of the service.

@endersonmaia endersonmaia force-pushed the feature/add-espresso-reader-to-cli branch 2 times, most recently from dc4d99a to fda0e28 Compare February 7, 2025 12:51
@endersonmaia endersonmaia force-pushed the feature/cli-run-v2 branch 2 times, most recently from a82afdd to a7e55c5 Compare February 27, 2025 13:18
@endersonmaia endersonmaia force-pushed the feature/add-espresso-reader-to-cli branch 3 times, most recently from a697bb4 to 933a91d Compare February 27, 2025 19:32
@tuler tuler force-pushed the feature/cli-run-v2 branch from a7e55c5 to 7feeb21 Compare February 28, 2025 14:36
@endersonmaia endersonmaia force-pushed the feature/add-espresso-reader-to-cli branch from 933a91d to 0a9b6e4 Compare February 28, 2025 18:19
@endersonmaia endersonmaia marked this pull request as ready for review February 28, 2025 18:19
@miltonjonat
Copy link

miltonjonat commented Mar 3, 2025

I tried it out, had some issues, and couldn't run in the end.

  1. ./apps/cli/bin/run.js is not being generated by pnpm build
  2. If I go to that directory and run pnpm build, it generates output in the dist folder. It seems to work if I use alias cartesi-dev=$PWD/apps/cli/dist/index.js; using cartesi-dev build works
  3. cartesi-dev run --enable-espresso fails, with message service "espresso_reader_migration" didn't complete successfully: exit 1. Full log (with verbose): cartesi-dev.run.log.zip

@tuler tuler force-pushed the feature/cli-run-v2 branch 2 times, most recently from 44df851 to 1297ea6 Compare March 5, 2025 22:17
@endersonmaia
Copy link
Contributor Author

I tried it out, had some issues, and couldn't run in the end.

  1. ./apps/cli/bin/run.js is not being generated by pnpm build
  2. If I go to that directory and run pnpm build, it generates output in the dist folder. It seems to work if I use alias cartesi-dev=$PWD/apps/cli/dist/index.js; using cartesi-dev build works
  3. cartesi-dev run --enable-espresso fails, with message service "espresso_reader_migration" didn't complete successfully: exit 1. Full log (with verbose): cartesi-dev.run.log.zip

The failure was error: migration failed: type "ethereum_address" does not exist.

The migration code doesn't mention the creation of this ethereum_address type.

https://github.com/cartesi/rollups-espresso-reader/blob/v0.2.1-node-20250128/internal/repository/postgres/schema/migrations/000001_espresso_db.up.sql

@miltonjonat
Copy link

That's part of the Node migration, which has to be executed before the Espresso Reader's one.
https://github.com/cartesi/rollups-node//blob/feature/new-build-20250128/internal/repository/postgres/schema/migrations/000001_create_initial_schema.up.sql#L4

@endersonmaia
Copy link
Contributor Author

That's part of the Node migration, which has to be executed before the Espresso Reader's one. https://github.com/cartesi/rollups-node//blob/feature/new-build-20250128/internal/repository/postgres/schema/migrations/000001_create_initial_schema.up.sql#L4

Sent a fixup for that. 0fb7ac6

I'll have to rebase this on top of feature/cli-run-v2, it has a lot of braking changes, then I'll provide a cleaner commit history so we can go back to testing this again.

@tuler tuler force-pushed the feature/cli-run-v2 branch 2 times, most recently from 39558cf to d496299 Compare March 6, 2025 18:31
@endersonmaia endersonmaia force-pushed the feature/add-espresso-reader-to-cli branch from 0fb7ac6 to 544d18b Compare March 6, 2025 20:43
@miltonjonat
Copy link

@endersonmaia cool new instructions! I like the --services espresso,graphql thing.
Unfortunately, it didn't run: migrations failed again. It seems that the database is dying for some reason, even when running without any extra services.

@tuler
Copy link
Member

tuler commented Mar 10, 2025

Strange that it is reporting a database url as postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable, with database name as rollupsdb. It should be postgres.

Did you change any of that?

@miltonjonat
Copy link

Strange that it is reporting a database url as postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable, with database name as rollupsdb. It should be postgres.

Did you change any of that?

I didn't change anything, but AFAIK in Node v2 the database is always called rollupsdb (e.g., https://github.com/cartesi/rollups-node/blob/feature/new-build/Makefile#L82)
Btw, which Node branch/tag are you guys using? The Espresso Reader is currently on https://github.com/cartesi/rollups-node/releases/tag/v2.0.0-dev-20250128

@tuler
Copy link
Member

tuler commented Mar 11, 2025

Btw, which Node branch/tag are you guys using?

We are testing locally with branch feature/new-build while we wait for a tag.

@tuler
Copy link
Member

tuler commented Mar 11, 2025

AFAIK in Node v2 the database is always called `rollupsdb

We define the env var

CARTESI_DATABASE_CONNECTION="postgres://postgres:password@database:5432/postgres?sslmode=disable"

@miltonjonat
Copy link

Right.. maybe it's not going through, or not being respected by the Node code..?

@endersonmaia
Copy link
Contributor Author

rollups-node v2 changed the ENV config from CARTESI_POSTGRES_ENDPOINT to CARTESI_DATABASE_CONNECTION

I'm already using CARTESI_ENDPOINT_CONNECTION where @tuler pointed out in his last comment.

For espresso-reader, I'm using CARTESI_POSTGRES_ENDPOINT still.

@endersonmaia
Copy link
Contributor Author

endersonmaia commented Mar 11, 2025

@miltonjonat my suggestion is that you go to the cartesi/rollups-node local repository at the feature/new-build branch and run make image.

Then you'll have a cartesi/rollups-node:devel available locally and your tests may run just fine.

Let me know if anything changes.

@tuler tuler force-pushed the feature/cli-run-v2 branch 2 times, most recently from b295744 to 48ddef2 Compare March 14, 2025 20:31
@tuler tuler force-pushed the feature/cli-run-v2 branch 3 times, most recently from b999336 to 24ad87e Compare March 17, 2025 14:09
Base automatically changed from feature/cli-run-v2 to prerelease/v2-alpha March 17, 2025 14:23
@tuler
Copy link
Member

tuler commented Mar 17, 2025

Time to rebase this one.

@endersonmaia endersonmaia force-pushed the feature/add-espresso-reader-to-cli branch from f6996c4 to 7e1b164 Compare March 17, 2025 19:03
@tuler tuler force-pushed the feature/add-espresso-reader-to-cli branch 2 times, most recently from ad79708 to babb7bd Compare March 18, 2025 14:43
@tuler tuler force-pushed the feature/add-espresso-reader-to-cli branch from 62cdb80 to 79f7ac7 Compare March 18, 2025 15:31
@endersonmaia endersonmaia requested a review from tuler March 18, 2025 16:27
@endersonmaia endersonmaia merged commit 19ff387 into prerelease/v2-alpha Mar 18, 2025
2 checks passed
@endersonmaia endersonmaia deleted the feature/add-espresso-reader-to-cli branch March 18, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants