Skip to content

feat(rpc)!: add getstandardfee RPC returning the ZIP-317 marginal fee - #10717

Merged
gustavovalverde merged 3 commits into
ZcashFoundation:mainfrom
ShieldedLabs:feature/z_getstandardfee-stub
Jul 16, 2026
Merged

feat(rpc)!: add getstandardfee RPC returning the ZIP-317 marginal fee#10717
gustavovalverde merged 3 commits into
ZcashFoundation:mainfrom
ShieldedLabs:feature/z_getstandardfee-stub

Conversation

@aphelionz

@aphelionz aphelionz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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 getstandardfee method 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 getstandardfee JSON-RPC method (zebra-rpc):

  • Parameters: none.
  • Result object { standard_fee, version }:
    • standard_fee: recommended fee per logical action, in zatoshis. Currently the static ZIP-317 marginal fee, 5000.
    • version: estimator version identifier; 0 marks the static placeholder. A future dynamic estimator increments this while keeping the result shape.

The value is a compile-time constant.

Tests

  • New unit test rpc_getstandardfee (in zebra-rpc/src/methods/tests/vectors.rs) drives the method with a MockChainTip and asserts standard_fee == 5000, and version == 0.
  • cargo fmt --all -- --check, cargo clippy -p zebra-rpc --all-targets -- -D warnings, and cargo test -p zebra-rpc --lib rpc_getstandardfee all pass.

Specifications & References

  • ZIP 317 (marginal fee = 5000 zatoshis per logical action).

Follow-up Work

  • Replace the static standard_fee constant with the dynamic fee estimator (separate PR, gated on ZIP review). That change increments version and is non-breaking with respect to this interface.

AI Disclosure

  • AI tools were used: Claude Code for the implementation, the unit test, and this PR description. The contributor is the responsible author.

PR Checklist

  • The PR title follows conventional commits: feat(rpc): add getstandardfee RPC returning the ZIP-317 marginal fee
  • The PR follows the contribution guidelines.
  • This change was discussed in an issue or with the team beforehand.
  • The solution is tested.
  • The documentation and changelogs are up to date.

@aphelionz
aphelionz force-pushed the feature/z_getstandardfee-stub branch from dcb7eca to d5ef3c6 Compare June 15, 2026 21:18
@oxarbitrage
oxarbitrage self-requested a review June 19, 2026 20:04

@oxarbitrage oxarbitrage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A whole new RPC to return a constant feels like overkill. Two options to consider:

  1. Add a standard_fee field to getblockchaininfo — 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.
  2. 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

Comment thread zebra-rpc/src/methods.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_FEE constant from zebra-chain for 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.

Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods/types/getstandardfee.rs
Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods/tests/vectors.rs
Comment thread CHANGELOG.md
Comment thread zebra-rpc/src/methods/types.rs
@aphelionz aphelionz changed the title feat(rpc): add z_getstandardfee RPC returning the ZIP-317 marginal fee feat(rpc): add getstandardfee RPC returning the ZIP-317 marginal fee Jun 24, 2026

@gustavovalverde gustavovalverde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 height field from the agreed interface in #10716.
  • The registered wire name getstandardfee disagrees with the z_getstandardfee in #10716 and the branch.

The rest are naming/convention cleanups that are cheap to do now while the surface is new.

Comment thread zebra-rpc/src/methods/types/get_standard_fee.rs
Comment thread zebra-rpc/src/methods.rs
Comment thread zebra-rpc/src/methods/types/get_standard_fee.rs
Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods.rs Outdated
Copilot AI review requested due to automatic review settings June 26, 2026 23:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread zebra-rpc/src/methods.rs Outdated
…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 }.
@aphelionz
aphelionz force-pushed the feature/z_getstandardfee-stub branch from 50fb681 to d6b7847 Compare June 27, 2026 18:18
Copilot AI review requested due to automatic review settings July 2, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread zebra-rpc/src/methods/tests/vectors.rs
Comment thread zebra-rpc/src/methods/tests/vectors.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 2, 2026 18:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread zebra-chain/src/transaction/unmined/zip317.rs
Comment thread CHANGELOG.md

@conradoplg conradoplg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

@aphelionz

Copy link
Copy Markdown
Contributor Author

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?

@conradoplg

Copy link
Copy Markdown
Collaborator

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!

@conradoplg
conradoplg dismissed gustavovalverde’s stale review July 7, 2026 23:31

comments were addressed

@conradoplg conradoplg changed the title feat(rpc): add getstandardfee RPC returning the ZIP-317 marginal fee feat(rpc)!: add getstandardfee RPC returning the ZIP-317 marginal fee Jul 10, 2026
@gustavovalverde
gustavovalverde merged commit 65adcb1 into ZcashFoundation:main Jul 16, 2026
116 of 121 checks passed
@aphelionz
aphelionz deleted the feature/z_getstandardfee-stub branch July 16, 2026 17:25
aphelionz added a commit to ShieldedLabs/fees-monolith that referenced this pull request Aug 17, 2026
Superseded by upstream getstandardfee (ZcashFoundation/zebra#10717,
released in v6.3.0).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: getstandardfee v0 (interface placeholder for dynamic fee estimation)

6 participants