Skip to content

feat(rpc): fill size field in getblock with verbosity=2 - #9327

Merged
mergify[bot] merged 2 commits into
mainfrom
getblock-size
Mar 28, 2025
Merged

feat(rpc): fill size field in getblock with verbosity=2#9327
mergify[bot] merged 2 commits into
mainfrom
getblock-size

Conversation

@conradoplg

Copy link
Copy Markdown
Collaborator

Motivation

This fills the size field in the getblock RPC when verbosity=2.

To support verbosity=1 we would need to either take a performance hit (load all transactions from a block to get their sizes) or change the database to create a tx -> size index (which would be good to avoid if possible)

Might close #9020

Solution

Add a BlockAndSize request to the state which reads the raw block header and txs, gets their sizes, computes the block size from them, and finally parses it all to return the block.

Tests

I adjusted existing tests. I also tested it manually with zcash-rpc-diff.

The block size calculation logic was also tested manually with a throwaway program that computed block sizes from the state with both approaches and asserted that they are equal.

Specifications & References

Follow-up Work

We need to decide if this is enough for now or if we want to support verbosity=1. In that case, we will need to create a new issue for it.

PR Checklist

  • The PR name is suitable for the release notes.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.
  • If the PR shouldn't be in the release notes, it has the
    C-exclude-from-changelog label.

@conradoplg
conradoplg requested a review from a team as a code owner March 14, 2025 02:09
@conradoplg
conradoplg requested review from oxarbitrage and removed request for a team March 14, 2025 02:09
@github-actions github-actions Bot added the C-feature Category: New features label Mar 14, 2025
oxarbitrage
oxarbitrage previously approved these changes Mar 17, 2025

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

Looks good to me, thank you.

Comment thread zebra-state/src/service/finalized_state/zebra_db/block.rs Outdated

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

thanks @conradoplg

@mergify

mergify Bot commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-feature Category: New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getblock: return the size field

2 participants