Skip to content

Feature/json rpc api improvements - #793

Open
renatomaia wants to merge 13 commits into
next/2.0from
feature/JsonRpcApiImprovements
Open

Feature/json rpc api improvements#793
renatomaia wants to merge 13 commits into
next/2.0from
feature/JsonRpcApiImprovements

Conversation

@renatomaia

Copy link
Copy Markdown

JSON-RPC API Improvements

Nine self-contained improvements identified as F1 to F9 as described here. The table below lists the commits, and column ID indicates which improvement is introduced.

ID Change Component Description
F1 feat jsonrpc add support for JSON-RPC 2.0 batch requests
refactor jsonrcp remove unused field 'data' from error reponses
F2 feat jsonrpc add operation to get epoch by a virtual contiguous index
F3 feat jsonrpc add operation to get Node info like its chain ID, version, and default block
F4 feat jsonrpc add inclusive index ranges to list epochs, inputs, outputs, and reports
F5 feat jsonrpc allows to filter output by execution and multiple selectors
feat cli allows to filter output by execution and multiple selectors
F6 feat jsonrpc add methods to get the count of executed and pending outputs
F7 feat jsonrpc support listing epochs with multiple statuses
feat cli support listing epochs with multiple statuses
F8 fix jsonrpc report 256-bit integer fields in OpenRPC specification
F9 refactor jsonrpc rename cartesi_getMatchAdvanced as cartesi_getMatchAdvance
test jsonrpc add tests for positional decoding of parameters

…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.
@renatomaia
renatomaia requested review from mpolitzer and vfusco July 30, 2026 13:51
…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.
@renatomaia
renatomaia force-pushed the feature/JsonRpcApiImprovements branch from 13bd7c4 to 31e82e1 Compare July 30, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant