Repository navigation
Honour field masks in ReadParams and WatchMempool - #1394
Draft
carbolymer wants to merge 11 commits into
Draft
carbolymer wants to merge 11 commits into
carbolymer wants to merge 11 commits into
Conversation
carbolymer
changed the base branch from
master
to
mgalazyn/feature/grpc-waitfortx
October 23, 2026 06:27
carbolymer
force-pushed
the
mgalazyn/feature/rpc-support-fieldmasks
branch
from
October 23, 2026 09:14
ba1c957 to
f6ce428
Compare
carbolymer
force-pushed
the
mgalazyn/feature/rpc-support-fieldmasks
branch
2 times, most recently
from
October 23, 2026 11:15
7687d83 to
3a71f22
Compare
Port the path normalisation of protobuf's Java FieldMaskTree: a field absorbs its sub-paths, duplicates collapse and paths read back sorted. Paths with empty segments are dropped.
Paths are rooted at the response message and may continue through repeated message fields. Paths that do not name a field are dropped whole; an absent mask or a "*" path selects everything.
Fields outside the mask are reset to their defaults, recursing into singular and repeated message fields. A oneof member is reset only when it is the active member, because proto-lens setters replace the whole oneof.
Handlers describe each response field as a fill: its lens label and the action that obtains its value. The mask decides which fills run, so a node query or conversion for an unselected field never runs and its value is never evaluated.
ReadParams now returns only the fields its mask selects, and skips the protocol parameters query or the chain tip queries when the mask does not need them.
Paths start at the response message, for example tx.native_bytes. The transaction is serialised and converted only when the mask or the request's predicate needs it. Proto/Api/UtxoRpc/Submit.hs now exposes the fieldMask lens of the request.
subMaskEach gives the part of a field mask below a repeated message field, and fillEach builds each element of that field lazily against it.
ReadParams, ReadUtxos and SearchUtxos build ledger_tip from one shared query, so each can skip it when its field mask does not select ledger_tip.
ReadUtxos returns only the fields its mask selects. It skips the UTxO query when items is not selected and the chain tip queries when ledger_tip is not, and serialises and converts each UTxO only for the fields the mask selects.
SearchUtxos returns only the fields its mask selects. It skips the UTxO query when neither items nor next_token is selected and the chain tip queries when ledger_tip is not, and converts each UTxO of the page only for the fields the mask selects. The new fillShared helper runs a shared action once for all the fields that read its result.
carbolymer
force-pushed
the
mgalazyn/feature/rpc-support-fieldmasks
branch
from
October 26, 2026 10:42
3a71f22 to
ef9cfd6
Compare
This branch has not been deployed
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.
Context
Every cardano-rpc method that carries a
field_maskaccepted it and ignored it.This PR makes
ReadParamsandWatchMempoolhonour the mask, through one generic implementation driven by proto-lens descriptors.There are no hand-written per-message tables, so each remaining method needs only a few lines to support masks.
Mask semantics:
valuesortx.native_bytes.field_mask.proto, which allows a repeated field only as the last segment. The utxorpc Go SDK and Dolos both use such paths.*path, returns everything.Laziness: proto-lens records have strict fields, so trimming a fully built response saves only bandwidth.
The handlers therefore skip the node queries and conversions that the mask does not need.
ReadParamsskips the protocol parameters query and the era lookup whenvaluesis not selected, and the chain tip queries whenledger_tipis not selected.WatchMempoolserialises and converts a transaction only when the mask or the request predicate needs it.Behaviour note: a
ReadParamsrequest that selects onlyledger_tipno longer determines the era.Not in this PR:
ReadGenesis,ReadEraSummary,ReadUtxos,SearchUtxos,FetchBlockandFollowTipwill follow in separate PRs.ReadState,ReadData,ReadTxandDumpHistoryare not implemented yet.This PR is stacked on #1351 (the
grpc-waitfortxbranch), so the diff shows only the field mask commits.References:
How to trust this PR
Review commit by commit. Each commit is one phase, and its tests were written first.
FieldMaskTree. Paths with empty segments are dropped.Tests are unit tests and Hedgehog properties per phase.
The laziness tests pass
error "forced"for the unselected inputs and fully evaluate the result.The whole
cardano-rpc-testsuite passes.Checklist
.changes/