Skip to content
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

Store cumulative work in the finalized state for each height #7109

Open
8 tasks
teor2345 opened this issue Jun 29, 2023 · 0 comments
Open
8 tasks

Store cumulative work in the finalized state for each height #7109

teor2345 opened this issue Jun 29, 2023 · 0 comments
Labels
A-state Area: State / database changes C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage

Comments

@teor2345
Copy link
Contributor

teor2345 commented Jun 29, 2023

Motivation

We need to store block work in the finalized state database to:

  1. efficiently calculate getnetworksolps & getnetworkhashps responses, and
  2. show the full cumulative chain work in chain fork progress bars (and other logging and metrics)

Otherwise, we have to load:

  1. block headers for the RPC height range to calculate solutions per second
  2. block headers for the entire chain to calculate cumulative work

Specifications

See the upgrade design docs for more details.

Implementation Steps

  • update the database format in the Zebra docs
  • increment the state minor version
  • write the new format in the block write task
  • update older formats in the format upgrade task
  • test that the new format works when creating a new state, and updating an older state

Complex Code or Requirements

This will need an in-place format update. There's no need to wait for this update to complete, or do it in any particular order. The RPCs can fall back to loading block headers, and the chain forks can use the partial cumulative work.

If we store the cumulative work, we can calculate the block work for height using:
cumulative_work(height) - cumulative_work(height - 1)

Testing

Compare the work bits and RPC outputs with zcashd.

Optional Cleanups

  • Use the full work in Chain
  • Replace PartialCumulativeWork with Work in Chain
  • Delete the PartialCumulativeWork type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-state Area: State / database changes C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage
Projects
Status: New
Development

No branches or pull requests

2 participants