Skip to content

gRPC: Add searchUtxos method#1123

Merged
carbolymer merged 1 commit intomasterfrom
mgalazyn/feature/searchutxos
Apr 30, 2026
Merged

gRPC: Add searchUtxos method#1123
carbolymer merged 1 commit intomasterfrom
mgalazyn/feature/searchutxos

Conversation

@carbolymer
Copy link
Copy Markdown
Contributor

@carbolymer carbolymer commented Mar 10, 2026

Context

Implements:

PR upstreaming proto changes:

E2E tests in:

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@carbolymer carbolymer self-assigned this Mar 10, 2026
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch 4 times, most recently from 14cdaa3 to 13372e9 Compare March 17, 2026 19:49
Comment thread cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/Predicate.hs Fixed
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch 3 times, most recently from 1eef5e8 to b39d938 Compare March 20, 2026 20:20
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch 2 times, most recently from 2ddd5a9 to 67ed4f7 Compare April 14, 2026 18:08
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch 10 times, most recently from 7447c6f to 00ac34e Compare April 28, 2026 09:52
@carbolymer carbolymer marked this pull request as ready for review April 28, 2026 09:52
Copilot AI review requested due to automatic review settings April 28, 2026 09:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SearchUtxos query handling (including address-extraction optimization and cursor pagination).
  • Update protobuf definitions to add SearchUtxos and make several fields optional, 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.

Comment on lines +3 to +6
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.
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

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

Copilot generated this review using guidance from repository custom instructions.
Comment thread cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs Outdated
Comment on lines +184 to +185
limit = if maxItems > 0 then fromIntegral maxItems else 100
page = take limit afterToken
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Comment on lines +14 to +34
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
)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread cardano-rpc/src/Cardano/Rpc/Proto/Api/UtxoRpc/Query.hs
Comment thread cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs
Comment thread cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs Outdated
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch from 749eaec to 94c0515 Compare April 30, 2026 09:27
@carbolymer carbolymer enabled auto-merge April 30, 2026 09:29
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch from 94c0515 to 752ed8a Compare April 30, 2026 09:42
@carbolymer carbolymer disabled auto-merge April 30, 2026 09:43
@carbolymer carbolymer force-pushed the mgalazyn/feature/searchutxos branch from 752ed8a to dfa1e77 Compare April 30, 2026 09:56
@carbolymer carbolymer enabled auto-merge April 30, 2026 09:58
@carbolymer carbolymer added this pull request to the merge queue Apr 30, 2026
Merged via the queue into master with commit 12bc59b Apr 30, 2026
33 checks passed
@carbolymer carbolymer deleted the mgalazyn/feature/searchutxos branch April 30, 2026 11:41
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.

gRPC: UTxORPC searchUtxos method of query service

4 participants