gRPC: Add searchUtxos method#1123
Conversation
14cdaa3 to
13372e9
Compare
1eef5e8 to
b39d938
Compare
2ddd5a9 to
67ed4f7
Compare
7447c6f to
00ac34e
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new SearchUtxos gRPC endpoint to the cardano-rpc Query service, enabling predicate-based UTxO filtering plus cursor-based pagination, and updates the protobuf schema + generated bindings accordingly.
Changes:
- Introduce server-side predicate matching and
SearchUtxosquery handling (including address-extraction optimization and cursor pagination). - Update protobuf definitions to add
SearchUtxosand make several fieldsoptional, regenerating Haskell proto-lens bindings and updating wrapper modules. - Add Hedgehog tests covering predicate semantics and pagination behavior.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/Predicate.hs |
New property tests for predicate/address/asset matching and address extraction. |
cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/Pagination.hs |
New property tests for cursor pagination behavior and a multi-digit index regression case. |
cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs |
Implements searchUtxosMethod and adds paginateByTxIn. |
cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Predicate.hs |
New predicate evaluation + address extraction helpers used by SearchUtxos. |
cardano-rpc/src/Cardano/Rpc/Server/Internal/Tracing.hs |
Adds tracing span constructors/messages for SearchUtxos. |
cardano-rpc/src/Cardano/Rpc/Server.hs |
Registers SearchUtxos handler in the QueryService method list. |
cardano-rpc/src/Cardano/Rpc/Proto/Api/UtxoRpc/Submit.hs |
Adjusts re-exported field lenses via hiding to avoid name collisions. |
cardano-rpc/src/Cardano/Rpc/Proto/Api/UtxoRpc/Query.hs |
Updates wrapper import hiding list due to regenerated fields/methods. |
cardano-rpc/proto/utxorpc/v1beta/query/query.proto |
Adds SearchUtxos RPC and marks several fields as optional. |
cardano-rpc/proto/utxorpc/v1beta/cardano/cardano.proto |
Marks Address/Asset/TxOutput pattern fields as optional. |
cardano-rpc/gen/Proto/Utxorpc/V1beta/Query/Query_Fields.hs |
Regenerated lenses for new optional fields (e.g., maybe'maxItems, maybe'startToken). |
cardano-rpc/gen/Proto/Utxorpc/V1beta/Query/Query.hs |
Regenerated Query service/messages including searchUtxos and optional field presence. |
cardano-rpc/gen/Proto/Utxorpc/V1beta/Cardano/Cardano_Fields.hs |
Regenerated lenses for optional pattern fields. |
cardano-rpc/gen/Proto/Utxorpc/V1beta/Cardano/Cardano.hs |
Regenerated message types to reflect optional fields (record fields now Maybe under the hood). |
cardano-rpc/cardano-rpc.cabal |
Exposes new predicate module and adds test-suite deps/modules. |
.changes/20260423_cardano_rpc_search_utxos.yml |
Changelog fragment describing the new RPC and predicate/pagination behavior. |
| kind: | ||
| - feature | ||
| description: | | ||
| Add searchUtxos gRPC method to the UTxO RPC query service, implementing predicate-based UTxO filtering with address, asset, and boolean combinators, plus cursor-based pagination. |
There was a problem hiding this comment.
The changelog fragment is marked only as feature, but this PR changes the public Haskell API generated from the protobufs (e.g., several message fields are now optional, which changes generated record field types to Maybe in exposed cardano-rpc:gen modules, and Cardano.Rpc.Proto.Api.UtxoRpc.Submit now hides previously re-exported field lenses). This should be classified as a breaking change (add breaking to kind: and update the description to call out the specific API surface changes for downstream users).
| limit = if maxItems > 0 then fromIntegral maxItems else 100 | ||
| page = take limit afterToken |
There was a problem hiding this comment.
maxItems is an int32 and can be negative over the wire; currently any maxItems <= 0 silently falls back to the default page size (100). This makes an invalid client value behave like a valid request and can lead to unexpectedly large responses. Consider explicitly rejecting negative maxItems (e.g., return an InvalidArgument-style error) or clamping it to 0/1 with documented semantics.
00ac34e to
749eaec
Compare
| import Proto.Utxorpc.V1beta.Submit.Submit_Fields hiding | ||
| ( allOf | ||
| , anyOf | ||
| , cardano | ||
| , fieldMask | ||
| , items | ||
| , match | ||
| , maybe'cardano | ||
| , maybe'chain | ||
| , maybe'fieldMask | ||
| , maybe'match | ||
| , maybe'parsedState | ||
| , maybe'predicate | ||
| , nativeBytes | ||
| , not | ||
| , predicate | ||
| , vec'allOf | ||
| , vec'anyOf | ||
| , vec'items | ||
| , vec'not | ||
| ) |
There was a problem hiding this comment.
This module now hides a large set of identifiers from Proto.Utxorpc.V1beta.Submit.Submit_Fields while still re-exporting the module, which removes previously exported field lenses/selectors from the public Cardano.Rpc.Proto.Api.UtxoRpc.Submit API. If this is intentional (to avoid name collisions), it should be called out as a breaking change and ideally documented; otherwise consider not hiding (or re-export under a qualified name) to preserve the existing API surface.
| import Proto.Utxorpc.V1beta.Submit.Submit_Fields hiding | |
| ( allOf | |
| , anyOf | |
| , cardano | |
| , fieldMask | |
| , items | |
| , match | |
| , maybe'cardano | |
| , maybe'chain | |
| , maybe'fieldMask | |
| , maybe'match | |
| , maybe'parsedState | |
| , maybe'predicate | |
| , nativeBytes | |
| , not | |
| , predicate | |
| , vec'allOf | |
| , vec'anyOf | |
| , vec'items | |
| , vec'not | |
| ) | |
| import Proto.Utxorpc.V1beta.Submit.Submit_Fields |
749eaec to
94c0515
Compare
94c0515 to
752ed8a
Compare
752ed8a to
dfa1e77
Compare
Context
Implements:
searchUtxosmethod of query service cardano-node#6364PR upstreaming proto changes:
optionalutxorpc/spec#194E2E tests in:
Checklist