-
Notifications
You must be signed in to change notification settings - Fork 106
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
fix(rpc): Fix bugs and performance of getnetworksolps
& getnetworkhashps
RPCs
#7647
Conversation
36ee052
to
6f53183
Compare
Block Range: Manual Performance and Compatibility TestingThis code produces identical results to It becomes noticeably slower around 10,000 blocks. It takes 1 second for 100,000 blocks, 14 seconds for 1000,000 blocks, and 1 minute for the entire chain. Since it's fast for the default range and typical ranges, and it finishes in a reasonable time for the whole chain, I don't think we need to do anything further here. If someone tells us the performance on large ranges is an issue, we can open a ticket then. I used the following numbers of blocks:
Here is a sample output:
|
Initial Height: Compatibility TestingI tried these heights and they produced the same results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks excellent, thank you for the doc cleanups.
@Mergifyio refresh |
✅ Pull request refreshed |
Motivation
When
getnetworksolps
&getnetworkhashps
are run over a large block range, they are extremely slow or produce incorrect results.There are also some bugs,
zcashd
incompatibilities, and unsupported argument values in the RPC implementation.This is a partial performance and bug fix for #6688, but it doesn't limit the height range.
Specifications
zcashd
implements these RPCs using this function:https://github.com/zcash/zcash/blob/482f120f635e342061005d5218d7cc18d1f342b5/src/rpc/mining.cpp#L48-L83
I re-wrote the implementation to match what the
zcashd
function does.Complex Code or Requirements
We want to match
zcashd
's behaviour and performance. Some performance improvements require database changes (#7109), but they are out of scope for this ticket and PR.To improve performance, I iterated over block headers, rather than full blocks. To do this, I re-wrote the chain iterator code so it was generic over the chain item. (Block, block header, etc.)
The
zcashd
code is fairly complicated, so I tried to follow it closely.Solution
Compatibility fixes:
zcashd
's codezcashd
accepts, and handle them likezcashd
Bug fixes:
zcashd
Related changes:
Unrelated changes:
Testing
Add extra test cases for RPC arguments.
I manually tested this change using
zcash-rpc-diff
, see the comments for details.Review
This PR is ready for review.
Reviewer Checklist
Follow Up Work
Test the performance of the new code to work out if we need to limit the height range.
Test for invalid answers when large heights are supplied.