feat(rpc): fill size field in getblock with verbosity=2 - #9327
Merged
Conversation
conradoplg
force-pushed
the
getblock-size
branch
from
March 14, 2025 13:06
424da9f to
83d1279
Compare
oxarbitrage
previously approved these changes
Mar 17, 2025
oxarbitrage
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me, thank you.
Contributor
|
This pull request has been removed from the queue for the following reason: 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This fills the
sizefield in thegetblockRPC whenverbosity=2.To support
verbosity=1we 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
BlockAndSizerequest 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
C-exclude-from-changeloglabel.