feat(rpc)!: add lightwalletd-compatible gRPC server implementing CompactTxStreamer - #10953
feat(rpc)!: add lightwalletd-compatible gRPC server implementing CompactTxStreamer#10953arya2 wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in CompactTxStreamer gRPC server so Zebra can directly serve light clients.
Changes:
- Implements gRPC handlers using Zebra RPC, state, tip, and mempool services.
- Adds configuration, startup wiring, vendored protobufs, and generated bindings.
- Updates user and crate changelogs.
Assessment: The implementation targets an outdated lightwalletd schema and has unresolved correctness, DoS, backpressure, and test-coverage issues. The supplied metadata also lacks a link to the pre-discussed issue or maintainer acknowledgment.
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
CHANGELOG.md |
Documents the new server. |
zebra-rpc/CHANGELOG.md |
Records the crate API addition. |
zebra-rpc/build.rs |
Builds or copies protobuf artifacts. |
zebra-rpc/proto/compact_formats.proto |
Defines compact block messages. |
zebra-rpc/proto/service.proto |
Defines CompactTxStreamer. |
zebra-rpc/proto/__generated__/cash.z.wallet.sdk.rpc.rs |
Generated tonic bindings. |
zebra-rpc/src/config/rpc.rs |
Adds the listen address setting. |
zebra-rpc/src/lib.rs |
Exposes the module. |
zebra-rpc/src/lightwalletd.rs |
Converts chain data to compact messages. |
zebra-rpc/src/lightwalletd/methods.rs |
Implements the gRPC methods. |
zebra-rpc/src/lightwalletd/server.rs |
Initializes the tonic server. |
zebra-rpc/src/server/tests/vectors.rs |
Updates configuration fixtures. |
zebrad/src/commands/start.rs |
Starts and monitors the server. |
# Conflicts: # CHANGELOG.md # zebra-rpc/CHANGELOG.md
…ILABLE for transient failures
… the latest treestate to one block
|
Summary of what's been pushed here since Friday. Merged Two behaviour changes worth calling out. A missing commitment tree now returns Both have tests that fail without the fix, using a new in-process harness at Two findings were split out rather than grown into this PR: #11238 (re-vendoring the protos for transparent |
Motivation
Zcash light clients currently need a separate
lightwalletdinstance sitting between them and a full node. This PR lets Zebra serve light clients directly by implementing the lightwalletdCompactTxStreamergRPC interface inzebra-rpc.Close #11158
Solution
Adds a new
zebra_rpc::lightwalletdmodule: a tonic gRPC server implementing all 18CompactTxStreamermethods, enabled with a newrpc.lightwalletd_listen_addrconfig field (disabled by default).service.proto/compact_formats.protofiles fromzcash/lightwalletdare vendored intozebra-rpc/proto/and compiled by the existing build-script mechanism, with generated code checked intoproto/__generated__/so crates.io builds don't needprotoc.GetTreeState,GetSubtreeRoots,GetTaddressBalance,GetTaddressTxids,GetAddressUtxos,SendTransaction,GetLightdInfo) call the existing JSON-RPCRpcImplmethods in-process — the same methods lightwalletd calls on zcashd/Zebra over HTTP.GetBlock,GetBlockRange, and the nullifier variants) and mempool streams (GetMempoolTx,GetMempoolStream) are built directly from the read-state and mempool services, following the existing indexer gRPC server's patterns. Compact-block tree sizes are fetched by the block's own hash so a concurrent reorg can't makeChainMetadatainconsistent with the block.Excludeentries inGetMempoolTxare little-endian txid suffixes, andGetMempoolStreamsendsheight: 0for mempool transactions (Figure out what to do in librustzcash about the brokenGetTransactionmethod of lightwalletd zcash/librustzcash#1484).Pingis disabled, matching production lightwalletd instances.Tests
BlockIDconversion andExcludelist matching (byte order, ambiguous and empty entries).zebra-rpctests pass (cargo nextest run -p zebra-rpc --release: 113 passed).lightwalletd_listen_addrset, mined 5 blocks via thegenerateRPC, and exercised 12 methods with a tonicCompactTxStreamerClient(GetLightdInfo,GetLatestBlock,GetBlockby height and by hash,GetBlockRange,GetTreeState,GetLatestTreeState,GetMempoolTx,GetTaddressBalance,GetTaddressTxids,GetAddressUtxos), verifying hashes, heights, coinbase balances, and tree states.cargo fmt --checkandcargo clippy --workspace --all-targetsare clean for the touched crates.Specifications & References
GetTransactionmethod of lightwalletd zcash/librustzcash#1484 (RawTransaction height semantics)Follow-up Work
GetBlockRangeissues 3 sequential state reads per block; pipelining them would matter for full-chain light-client sync throughput.pub use wire::*re-exports all generated proto types fromzebra-rpc; a curated re-export would shrink the semver-checked public API surface.fs::read) means checked-in*_descriptor.binfiles now refresh from localprotocoutput, which regeneratedindexer_descriptor.binin this PR and may churn across contributor protoc versions.AI Disclosure
PR Checklist
type(scope): description