Skip to content

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

Merged
mergify[bot] merged 10 commits into
mainfrom
get-block
Dec 2, 2024
Merged

change(rpc): Update getblock RPC to more closely match zcashd#9006
mergify[bot] merged 10 commits into
mainfrom
get-block

Conversation

@conradoplg

@conradoplg conradoplg commented Nov 8, 2024

Copy link
Copy Markdown
Collaborator

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
@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

arya2 commented Nov 9, 2024

Copy link
Copy Markdown
Contributor

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

@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.

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

Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods.rs Outdated
Comment thread zebra-rpc/src/methods.rs
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
Comment thread zebra-rpc/src/methods.rs Outdated
Co-authored-by: Arya <aryasolhi@gmail.com>
arya2
arya2 previously approved these changes Nov 29, 2024

@arya2 arya2 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.

Thank you!

Comment thread zebra-rpc/src/methods.rs
@arya2 arya2 added A-rpc C-enhancement Category: This is an improvement and removed C-trivial labels Nov 29, 2024
@arya2

arya2 commented Nov 29, 2024

Copy link
Copy Markdown
Contributor

@mergify update

@mergify

mergify Bot commented Nov 29, 2024

Copy link
Copy Markdown
Contributor

update

✅ Branch has been successfully updated

@conradoplg

Copy link
Copy Markdown
Collaborator Author

@Mergifyio update

@mergify

mergify Bot commented Nov 29, 2024

Copy link
Copy Markdown
Contributor

update

✅ Branch has been successfully updated

@conradoplg

Copy link
Copy Markdown
Collaborator Author

@Mergifyio queue

@mergify

mergify Bot commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

queue

✅ The pull request has been merged automatically

Details

The pull request has been merged automatically at d1ae441

@mergify
mergify Bot merged commit d1ae441 into main Dec 2, 2024
@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

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