Context / Problem
Today the CLI read subcommands query the node state directly from the database via the repository package. This is great for local development and for admin-style workflows where the CLI also performs node management tasks that require DB access.
However, developers and operators may want to run the CLI against a remote node (or a hosted service) and fetch the same read data through the JSON-RPC API instead of requiring direct DB connectivity.
We need a clean way to choose the datasource per invocation while keeping the current DB behavior as the default.
Proposed change
Introduce a datasource abstraction for the read command family with two implementations:
- DB datasource (default): current behavior using
repository (no change in semantics/output).
- JSON-RPC datasource: fetches data from a remote JSON-RPC endpoint and renders the same output as the DB datasource.
CLI UX:
- Add a global flag (and env var) to enable JSON-RPC mode, without breaking existing flows:
--jsonrpc-endpoint <url> (env: CARTESI_JSONRPC_API_ADDRESS)
- Commands outside
read that require DB access must remain unchanged for now.
Implementation should reuse the same method semantics and response shapes defined by internal/jsonrpc/jsonrpc-discover.json.
Deliverables
Acceptance criteria
Notes:
- Prefer keeping the rendering/formatting layer shared so only the data-fetching changes between datasources.
- If we already have common filtering/pagination conventions in the DB path, mirror them in JSON-RPC mode (same flag names, same defaults).
Context / Problem
Today the CLI
readsubcommands query the node state directly from the database via therepositorypackage. This is great for local development and for admin-style workflows where the CLI also performs node management tasks that require DB access.However, developers and operators may want to run the CLI against a remote node (or a hosted service) and fetch the same
readdata through the JSON-RPC API instead of requiring direct DB connectivity.We need a clean way to choose the datasource per invocation while keeping the current DB behavior as the default.
Proposed change
Introduce a datasource abstraction for the
readcommand family with two implementations:repository(no change in semantics/output).CLI UX:
--jsonrpc-endpoint <url>(env:CARTESI_JSONRPC_API_ADDRESS)readthat require DB access must remain unchanged for now.Implementation should reuse the same method semantics and response shapes defined by
internal/jsonrpc/jsonrpc-discover.json.Deliverables
readoperations (e.g.ReadService/ReadDatasource) that covers the existingreadentities (and the new PRT ones).repository.internal/jsonrpc/jsonrpc-discover.jsonreadroot command level so all subcommands share the same mechanism.Acceptance criteria
readcommand without new flags behaves exactly as before (same output, same defaults).read), and documented in--help, including env vars.cartesi-rollups-cli read epochs <app> --jsonrpc-endpoint <url>returns valid data and exits0.dbdatasource matches the JSON-RPC datasource output (normalized).readcommands that require DB connectivity are unaffected by these changes.Notes: