feat(rpc)!: add getstandardfee RPC returning the ZIP-317 marginal fee - #10717
Conversation
dcb7eca to
d5ef3c6
Compare
oxarbitrage
left a comment
There was a problem hiding this comment.
A whole new RPC to return a constant feels like overkill. Two options to consider:
- Add a
standard_feefield togetblockchaininfo— this is the natural home for protocol parameters, requires no new endpoint, and zcashd has added fields to this response over the years without breaking clients (JSON-RPC clients generally ignore unknown fields). This would be my preference. - Keep it as a new endpoint — avoids any theoretical compatibility risk with strict-parsing clients. But if we go this route, the
z_prefix isn't right
(zcashd convention reserves it for shielded operations), and the height/version fields need justification since the fee is not height-dependent.
Either way, the 5000 marginal fee already exists as MARGINAL_FEE in https://github.com/ZcashFoundation/zebra/blob/v5.2.0/zebra-chain/src/transaction/unmined/zip317.rs#L23
d5ef3c6 to
90331b2
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new JSON-RPC endpoint intended to let wallets/indexers query a node-recommended “standard fee” (currently the static ZIP-317 marginal fee), as part of the dynamic fees effort in zebra-rpc. It also exposes the ZIP-317 marginal fee constant from zebra-chain for reuse.
Changes:
- Added a new RPC method and response type for standard-fee querying in
zebra-rpc. - Exported ZIP-317’s
MARGINAL_FEEconstant fromzebra-chainfor cross-crate use. - Added a unit test and a changelog entry documenting the new RPC.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| zebra-rpc/src/methods/types/getstandardfee.rs | Adds the response type for the new standard-fee RPC. |
| zebra-rpc/src/methods/types.rs | Wires the new RPC types module into the types module tree. |
| zebra-rpc/src/methods/tests/vectors.rs | Adds a unit test for the new RPC method. |
| zebra-rpc/src/methods.rs | Adds the RPC trait method + server implementation returning a static fee. |
| zebra-chain/src/transaction/unmined/zip317.rs | Makes MARGINAL_FEE public so zebra-rpc can reference it. |
| CHANGELOG.md | Documents the addition of the new RPC endpoint. |
getstandardfee RPC returning the ZIP-317 marginal fee
gustavovalverde
left a comment
There was a problem hiding this comment.
Considering this is an interface-only PR, the value here is freezing a shape that wallets, indexers, and other consumers bind to. That makes the result struct and the method name matter more than the (correct) constant
So, before the shape is frozen, there are two things to settle:
- The response omits the
heightfield from the agreed interface in #10716. - The registered wire name
getstandardfeedisagrees with thez_getstandardfeein #10716 and the branch.
The rest are naming/convention cleanups that are cheap to do now while the surface is new.
…cal action
Add a parameterless `getstandardfee` JSON-RPC method that returns the
recommended standard fee per logical action. This is the static interface
placeholder (version 0): it returns the existing ZIP-317 marginal fee (5000
zatoshis, reusing `MARGINAL_FEE` from zip317.rs) so wallets can integrate
against a stable method signature now, while a future change replaces the
value with a dynamic estimate and increments the version field without
altering the result shape.
The result object is { standard_fee, version }.
50fb681 to
d6b7847
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
conradoplg
left a comment
There was a problem hiding this comment.
Sorry for the late feedback but I don't see why this should be a RPC method instead of a librustzcash method. Most wallets don't talk directly to Zebra, so this is useless to most of them
@conradoplg Thanks, and no worries! This PR only ships the interface, but the dynamic estimator that follows prices actions off node-local state (fee distribution of recent blocks). So the estimate has to originate at the node regardless of where the wallet-facing API lives. I was just expecting an indexer to gRPC it for the wallet in the end. A librustzcash helper wrapping that call would be complementary, and I'd support adding that as well. Does that address your concern? |
Ah I see, thanks for the context! |
getstandardfee RPC returning the ZIP-317 marginal feegetstandardfee RPC returning the ZIP-317 marginal fee
65adcb1
into
ZcashFoundation:main
Superseded by upstream getstandardfee (ZcashFoundation/zebra#10717, released in v6.3.0). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Motivation
Add a node-side RPC that wallets can call to get a recommended fee, as part of the dynamic fees effort. This PR lands only the interface: a parameterless
getstandardfeemethod returning a stable result shape, so wallets and the indexers (Zaino, lightwalletd) can integrate now.The fee estimation algorithm is deliberately decoupled and will be added later.
Discussed on the arborist call and acknowledged by @gustavovalverde
Closes #10716
Solution
Add the
getstandardfeeJSON-RPC method (zebra-rpc):{ standard_fee, version }:standard_fee: recommended fee per logical action, in zatoshis. Currently the static ZIP-317 marginal fee,5000.version: estimator version identifier;0marks the static placeholder. A future dynamic estimator increments this while keeping the result shape.The value is a compile-time constant.
Tests
rpc_getstandardfee(inzebra-rpc/src/methods/tests/vectors.rs) drives the method with aMockChainTipand assertsstandard_fee == 5000, andversion == 0.cargo fmt --all -- --check,cargo clippy -p zebra-rpc --all-targets -- -D warnings, andcargo test -p zebra-rpc --lib rpc_getstandardfeeall pass.Specifications & References
Follow-up Work
standard_feeconstant with the dynamic fee estimator (separate PR, gated on ZIP review). That change incrementsversionand is non-breaking with respect to this interface.AI Disclosure
PR Checklist
feat(rpc): add getstandardfee RPC returning the ZIP-317 marginal fee