Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(rpc): Update getblock RPC to more closely match zcashd #9006

Open
wants to merge 4 commits into
base: get-block-header
Choose a base branch
from

Conversation

conradoplg
Copy link
Collaborator

@conradoplg conradoplg commented Nov 8, 2024

Motivation

Currently zebra has partial support for getblock() and it mostly targets lightwalletd usage. For zcashd deprecation we want it to match zcashd more closely.

Specifications & References

zcashd RPC docs

Solution

Based on #8967

Since getblock() returns basically a superset of getblockheader(), I change our getblock() to call getblockheader() for all the shared fields.

Work on returning the additional non-header fields will be done in separate PRs.

I also changed getblockheader() return codes since whatever error it returns is now returned by getblock(), and we have committed to error codes in our snapshots. I also added the -5 error code which can also be returned by zcashd.

Since the previous behaviour can be still useful for performance reasons, I moved it to be carried out when verbosity=3 is used. It would be a simple change to lightwalletd. I'm not sure about the specific number though, should we use something farther off?

This also adds ZEBRAD_EXTRA_ARGS to zcash-rpc-diff because I was stubborn and wanted to make it work with cookie authentication 😆 Let me know if you'd prefer it in a separate PR, but it seems simple enough.

Tests

I adjusted the existing vectors.rs tests and updated the snapshots. I also tested it manually and with zcash-rpc-diff; the current diff is that size, blockcommitments authdataroot, chainhistoryroot, chainwork anchor, chainSupply and valuePools are not yet being filled; and verbosity=2 is still the same as 1 (i.e. tx is not expanded)

Follow-up Work

  • Check which of the remaining fields are truly required (some of them are undocumented). I'll ask the deprecation group.
  • Created issues for the fields we are going to work on

Additional information to put in Changelog

### Performance Regression

The `getblock()` change described below will impact lightwalletd operators who
back it with Zebra. The initial sync performance will drop unless you change
the `getblock()` call to use `verbosity=3`. See below for details.

### Changed

- The `getblock()` RPC now supports all the fields also returned by `getblockheader()`.
  The old partial support is now moved to `verbosity=3`; it might be useful for
  lightwalletd if you want to keep the same initial sync performance as before
  (you will need to changed lightwalletd source code to use `verbosity=3`)

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

@conradoplg conradoplg requested a review from a team as a code owner November 8, 2024 19:18
@conradoplg conradoplg requested review from oxarbitrage and removed request for a team November 8, 2024 19:18
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Nov 8, 2024
@conradoplg conradoplg added P-Medium ⚡ and removed C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG labels Nov 8, 2024
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Nov 8, 2024
@arya2 arya2 changed the title change(rpc): update getblock() to closer match zcashd change(rpc): Update getblock RPC to more closely match zcashd Nov 9, 2024
@arya2
Copy link
Contributor

arya2 commented Nov 9, 2024

This is looking good! I left some suggestions in #9008.

Since the previous behaviour can be still useful for performance reasons, I moved it to be carried out when verbosity=3 is used. It would be a simple change to lightwalletd. I'm not sure about the specific number though, should we use something farther off?

The new behaviour seems performant enough for lightwalletd to continue using verbosity = 1. I don't think we need to mention a performance regression in the changelog either.

The performance issue before (fixed in #5307) was that it was reading all of the block's transactions, the database queries added here should be quick, and, if they still have a measurable impact on lightwalletd sync performance, can be optimized easily (like by parallelizing or unifying state requests and maybe using an iterator to get the block hashes at height/height.next()) .

(Though we should make sure to cache block sizes by hash in a new column family when adding that field to avoid reading, deserializing, and then serializing the entire block to get its size.)

@mpguerra mpguerra linked an issue Nov 13, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update getblock RPC method
2 participants