Mark optional fields in SearchUtxosRequest with optional#194
Open
carbolymer wants to merge 1 commit intoutxorpc:mainfrom
Open
Mark optional fields in SearchUtxosRequest with optional#194carbolymer wants to merge 1 commit intoutxorpc:mainfrom
optional#194carbolymer wants to merge 1 commit intoutxorpc:mainfrom
Conversation
3 tasks
cdebf78 to
8ec8f95
Compare
8ec8f95 to
563fbdd
Compare
scarmuega
approved these changes
May 1, 2026
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.
Motivation
In proto3, fields without the
optionalkeyword are not given presence tracking.An empty
bytesfield and one that was never set are represented identically on the wire and in generated code.As a result, "the client left this filter blank" cannot be distinguished from "the client wants to match on empty bytes" by the server, and "no more pages" cannot be distinguished from "an empty token was set" by the client.
The
SearchUtxospredicate hierarchy is built on combining address patterns, asset patterns and boolean operators.Each pattern field is intended as a filter: when present it should constrain the result set, and when absent it should be ignored.
Without
optional, the proto3 default (empty bytes, zero, empty string) must be treated as "absent" by implementations.This convention is fragile and cannot be enforced by the encoding itself.
With
optional, fields are represented with presence-aware types in generated code (e.g.Maybein Haskell,has_checks in other languages), so the "absent vs default" distinction is handled naturally rather than through ad-hoc empty checks.Changes
The following fields are marked as
optionalto enable presence semantics:AddressPattern:exact_address,payment_part,delegation_partAssetPattern:policy_id,asset_nameTxOutputPattern:address,assetUtxoPredicate:matchSearchUtxosRequest:predicate,max_items,start_tokenSearchUtxosResponse:next_tokenWire compatibility
The wire encoding is not changed by adding
optionalto scalar and message fields.Existing clients and servers that treat default values as absent are not affected.