Feature/json rpc api improvements - #793
Open
renatomaia wants to merge 26 commits into
Open
Conversation
renatomaia
force-pushed
the
feature/JsonRpcApiImprovements
branch
from
July 30, 2026 13:55
13bd7c4 to
31e82e1
Compare
renatomaia
force-pushed
the
feature/JsonRpcApiImprovements
branch
from
August 11, 2026 14:36
31e82e1 to
fc36dae
Compare
There was a problem hiding this comment.
Pull request overview
Expands the JSON-RPC API with batching, additional queries, richer filtering, updated schemas, and corresponding CLI support.
Changes:
- Adds batch dispatching with response budgeting and centralized error handling.
- Adds node information, virtual epoch lookup, output counts, ranges, and multi-value filters.
- Updates OpenRPC documentation, CLI commands, repository queries, and tests.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
internal/repository/repotest/report_test_cases.go |
Tests report index ranges. |
internal/repository/repotest/output_test_cases.go |
Tests output ranges and filters. |
internal/repository/repotest/input_test_cases.go |
Tests input index ranges. |
internal/repository/repotest/epoch_test_cases.go |
Tests epoch index ranges. |
internal/repository/repository.go |
Extends repository filters. |
internal/repository/postgres/report.go |
Implements report range filtering. |
internal/repository/postgres/output.go |
Implements output filtering and counts. |
internal/repository/postgres/input.go |
Implements input range filtering. |
internal/repository/postgres/epoch.go |
Implements epoch range filtering. |
internal/jsonrpc/util_test.go |
Closes test repositories. |
internal/jsonrpc/types.go |
Refactors JSON-RPC response encoding. |
internal/jsonrpc/limitedwriter.go |
Adds batch response budgeting. |
internal/jsonrpc/jsonrpc.go |
Adds methods, filters, and batch dispatch. |
internal/jsonrpc/jsonrpc-discover.json |
Updates the OpenRPC specification. |
internal/jsonrpc/jsonrpc_test.go |
Tests new API behavior. |
internal/jsonrpc/batchcalls_test.go |
Tests batch request handling. |
internal/jsonrpc/api/response.go |
Defines node information responses. |
internal/jsonrpc/api/params.go |
Adds parameters and positional decoding. |
internal/jsonrpc/api/params_test.go |
Tests parameter decoding. |
cmd/cartesi-rollups-cli/root/read/service/types.go |
Updates read-service parameter types. |
cmd/cartesi-rollups-cli/root/read/service/repository.go |
Supports multi-value repository filters. |
cmd/cartesi-rollups-cli/root/read/service/jsonrpc.go |
Updates JSON-RPC client validation. |
cmd/cartesi-rollups-cli/root/read/outputs/outputs.go |
Adds output filter flags. |
cmd/cartesi-rollups-cli/root/read/matchadvances/matchadvances.go |
Uses renamed match-advance parameters. |
cmd/cartesi-rollups-cli/root/read/epochs/epochs.go |
Adds repeated status filters. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
renatomaia
force-pushed
the
feature/JsonRpcApiImprovements
branch
3 times, most recently
from
August 14, 2026 01:22
0f77172 to
ea9ccde
Compare
… to single requests
…ion, and default block
…puts, and reports Changes include: - Added optional from and to JSON-RPC parameters. - Added IndexRange *Range to all four repository filters. - Added index-backed >= from and <= to PostgreSQL predicates shared by COUNT(*) and list queries. - Added shared hex-bound parsing and from <= to validation returning -32602 (invalid params). - Preserved positional-parameter compatibility by appending new fields after existing parameters. - Updated the OpenRPC specification. - Added repository tests confirming range composition with total count, descending order, offset, and limit. - Added no-database tests for reversed and malformed bounds.
…ctors
Changes:
- Added optional executed *bool to ListOutputsParams.
- output_type now accepts either one selector string or a non-empty selector array.
- Empty arrays return -32602 (invalid paramters).
- Changed OutputFilter.OutputType to a selector slice and added Executed.
- PostgreSQL now uses IN for selector OR semantics.
- Extracted shared execution and selector predicates reused by GetNumberOfPendingExecutableOutputs.
- Updated OpenRPC with string-or-array schema and executed.
- Added tests for:
- Single-selector compatibility
- Selector arrays
- Empty-array rejection
- Executed tri-state decoding
- Combined selector/execution filtering
- Unchanged nil-filter behavior required by validator claim generation
Targeted tests, package compilation, OpenRPC validation, and git diff --check pass. Validator compilation remains blocked by the environment’s missing
Cartesi machine C header.
- Added flag '--executed' to `read outputs`
- '--executed' filters for executed outputs.
- '--executed=false' filters for unexecuted outputs.
- Omitting the flag leaves execution status unfiltered.
- Updated the CLI example.
- Flag '--output-type' now can be repeated multiple times.
- All selectors are forwarded in request order.
- The help example and flag description were updated.
…utputs
Methods added:
- cartesi_getExecutedOutputCount
- cartesi_getPendingExecutableOutputCount
Each method:
- Accepts an application parameter.
- Returns {"data":"0x..."}.
- Explicitly checks application existence before querying the aggregate.
- Returns -32002 (application not found) for unknown applications.
- Is registered in the dispatch table.
Also updated the OpenRPC specification with the requested descriptions and added tests distinguishing unknown applications from existing applications with zero outputs.
- 'status' now accepts either a string or string array. - Every status is validated through 'EpochStatus.Scan'. - Invalid values return -32602 (invalid params) and identify the bad value. - An explicit empty array returns -32602 with Invalid epoch status: expected at least one status. - Added coverage for scalar/list decoding, multiple-status filtering, invalid list elements, and empty arrays. - Documents 'status' as 'oneOf': a single EpochStatus or a non-empty array of EpochStatus. - Documents omission as no filter and rejects empty arrays. - Documents the non-terminal watch set. - Clarifies terminal statuses never regress, preventing settled epochs from being re-read.
- '--status' now uses a repeatable string-array flag. - Multiple values are sent as StringOrList. - Updated help text and example.
Added 'UnsignedInteger256' schema for uint256 reference it in field 'Voucher.value'.
Updated these 'EvmAdvance' uint256 fields to reference 'UnsignedInteger256':
- chain_id
- block_number
- block_timestamp
- prev_randao
Kept 'EvmAdvance.index' and other genuine uint64 indexes on 'UnsignedInteger'.
…hAdvance - Renamed handler to handleGetMatchAdvance. - Renamed params struct to GetMatchAdvanceParams across node and CLI. - Updated OpenRPC discovery and JSON-RPC tests. - Normalized the parsed parent hash before repository lookup. - Added a mixed-case parent-hash regression test.
Tests covers all structs declared in `params.go`, comparing positional decoding against equivalent named decoding.
- Added 'executed' plus multiple 'output_type' selector coverage for 'cartesi_listOutputs'. - Added inclusive 'from'/'to' DB-fixture requests for epochs, inputs, outputs, and reports. - Updated count fixture to execute two vouchers, asserting executed 2 and pending 0.
- Warns at both cartesi_listOutputs and its executed parameter that executions occur out of index order. - Explicitly rejects output indexes, offsets, and counts as resume cursors. - Documents the complete count → bounded pending-set query → diff workflow. - Repeats the workflow on both output-count methods. - Notes that a race-free cursor belongs to a future ingestion API.
- Documented budgetWriter and limitedWriter behavior, including:
- Shared batch budget.
- Atomic response buffering.
- Exact-budget boundary behavior.
- Poison-on-overflow semantics.
- No budget consumption by the overflowing response.
- Updated constant documentation to cover both single and batch requests.
- Updated the OpenRPC description to document the 10 MB limit, -31003, retry guidance, and poison semantics.
renatomaia
force-pushed
the
feature/JsonRpcApiImprovements
branch
from
August 15, 2026 02:06
ea9ccde to
a5d2cef
Compare
- Omitted params - Top-level params: null - Empty positional arrays - Positional over-arity - Struct fields marked json:"-"
… a batch
The JSON-RPC server now:
- Calculates 'sum(limit)' for every list operation before dispatching a batch.
- Normalizes limits consistently with handlers:
- Omitted or zero → 50
- Above 10,000 → 10,000
- Allows a cumulative limit of exactly 10,000.
- Rejects totals above 10,000 before any handler or database query runs.
- Returns one batch-level -31003 error: Batch list item limit exceeded.
- Supports both named and positional parameters across every list method.
- Includes a registry coverage test so future list methods cannot silently
bypass the budget.
The client contract is documented in 'jsonrpc-discover.json', and operator
guidance—including the residual unbounded 'COUNT(*)' cost—is documented in
'docs/http-posture.md'.
renatomaia
force-pushed
the
feature/JsonRpcApiImprovements
branch
from
August 15, 2026 03:31
a5d2cef to
0b7c0c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JSON-RPC API Improvements
This PR implements nine improvements identified as F1 to F9 as described here, and other improvements described in review here.
Divergences from Proposed Fixes
COUNT(*)rather thanErrNotFoundfor an unknown application.Infolevel toDebuglevel, but the original behavior was kept because oneInfoline was allowed per batch in the description of feature F1.Commit relation to Features and Improvements
The table below lists the commits, and column
IDindicates which improvement is introduced.