Make getnetworksolps
& getnetworkhashps
RPCs more efficient by caching difficulties and times
#7403
Labels
A-compatibility
Area: Compatibility with other nodes or wallets, or standard rules
A-concurrency
Area: Async code, needs extra work to make it work properly.
A-rpc
Area: Remote Procedure Call interfaces
A-state
Area: State / database changes
C-bug
Category: This is a bug
C-enhancement
Category: This is an improvement
C-tech-debt
Category: Code maintainability issues
I-slow
Problems with performance or responsiveness
I-usability
Zebra is hard to understand or use
S-needs-triage
Status: A bug report needs triage
Motivation
In ticket #6688 we did some quick fixes to speed up the
getnetworksolps
&getnetworkhashps
RPCs.This ticket is for a long-term fix that is even faster, and supports quick work calculations over the full block range.
Specifications
https://zips.z.cash/protocol/protocol.pdf#blockheader
Read the state upgrade instructions before starting this ticket:
https://github.com/ZcashFoundation/zebra/blob/main/book/src/dev/state-db-upgrades.md#upgrading-the-state-database
Complex Code or Requirements
This ticket requires a state upgrade:
Then changes to the RPC calculations:
complex optimisation - don't do this
If that's not fast enough, we can:
PoWMedianBlockSpan/2
blocks' times: this is always the minimum because the "strictly greater than the median-time-past" rule requires the time to increase when the median increasesPoWMedianBlockSpan/2 * 4500
blocks' times: this is always the maximum because the "less than or equal to the median-time past plus 60*90 seconds" rule limits the maximum to 4500 greater than the median, and the "strictly greater than the median-time-past" rule guarantees regular time increases, so the median0..=2
on mainnet or height0..=653606
on testnet, if they are inside the range, because these rules don't apply to them,Then carefully test they produce the same results as the full range over a large number of random ranges. (Using a proptest?)
Testing
The original tests should pass before and after this change, but we should extend their ranges.
We should manually check that the RPC is faster on large ranges, using the RPC test cases from PR #7647.
Related Work
getnetworksolps
&getnetworkhashps
RPCs hang with large num_blocks #6688The text was updated successfully, but these errors were encountered: