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

Merged
merged 10 commits into from
Dec 2, 2024
Merged

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
@conradoplg conradoplg force-pushed the get-block branch 2 times, most recently from e3b050b to 618beb3 Compare November 8, 2024 19:33
@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
Base automatically changed from get-block-header to main November 18, 2024 12:16
@mergify mergify bot requested a review from a team as a code owner November 18, 2024 12:16
@mergify mergify bot requested review from upbqdn and removed request for a team November 18, 2024 12:16
oxarbitrage
oxarbitrage previously approved these changes Nov 18, 2024
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

It looks good, i made a few comments and documentation suggestions.

zebra-rpc/src/methods.rs Outdated Show resolved Hide resolved
zebra-rpc/src/methods.rs Outdated Show resolved Hide resolved
zebra-rpc/src/methods.rs Outdated Show resolved Hide resolved
zebra-rpc/src/methods.rs Outdated Show resolved Hide resolved
zebra-rpc/src/methods.rs Show resolved Hide resolved
zebra-rpc/src/methods.rs Outdated Show resolved Hide resolved
arya2
arya2 previously approved these changes Nov 29, 2024
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

Thank you!

@arya2 arya2 added A-rpc Area: Remote Procedure Call interfaces A-compatibility Area: Compatibility with other nodes or wallets, or standard rules C-enhancement Category: This is an improvement and removed C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG labels Nov 29, 2024
@arya2
Copy link
Contributor

arya2 commented Nov 29, 2024

@mergify update

Copy link
Contributor

mergify bot commented Nov 29, 2024

update

✅ Branch has been successfully updated

@conradoplg
Copy link
Collaborator Author

@Mergifyio update

Copy link
Contributor

mergify bot commented Nov 29, 2024

update

✅ Branch has been successfully updated

@conradoplg
Copy link
Collaborator Author

@Mergifyio queue

Copy link
Contributor

mergify bot commented Dec 2, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at d1ae441

@mergify mergify bot merged commit d1ae441 into main Dec 2, 2024
202 of 203 checks passed
@mergify mergify bot deleted the get-block branch December 2, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compatibility Area: Compatibility with other nodes or wallets, or standard rules A-rpc Area: Remote Procedure Call interfaces C-enhancement Category: This is an improvement P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update getblock RPC method
4 participants