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

change(state): Expose ZebraDb methods that can create different kinds of databases #8002

Merged
merged 24 commits into from
Nov 28, 2023

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Nov 27, 2023

Motivation

We want to be able to create a blockchain scanner results database as a completely separate database directory and instance. This is a rough draft of a first step, which allows different kinds of databases to be created using ZebraDb::new().

Close #8001

PR Author Checklist

Check before marking the PR as ready for review:

  • Will the PR name make sense to users?
  • Does the PR have a priority label?
  • Have you added or updated tests?
  • Is the documentation up to date?

If a checkbox isn't relevant to the PR, mark it as done.

Specifications

See the ticket for a rough design.

Complex Code or Requirements

There are a lot of code changes in this PR already, so I'd like to do the scanner database and its tests in another ticket.

Solution

  • Provide access to ZebraDb and WriteBatch outside the state
  • Pass column families to ZebradDb::new()
  • Allow the database kind and current version to be changed in:
    • config.rs
    • finalized_state.rs
    • ZebraDb
    • DiskDb
    • upgrade.rs
  • Make some upgrade.rs methods easier to use, simplify their arguments

Testing

Tests for new kinds of databases will be added when we add this database to the scanner.

The current state tests were updated and give good coverage.

Review

This PR blocks "Persistent storage of scanner results" in the MVP in #7728.

I'm looking for a review for a correct refactor. Missing functionality or additional refactors should go in the follow-up tickets #7926 and #7937.

Reviewer Checklist

Check before approving the PR:

  • Does the PR scope match the ticket?
  • Are there enough tests to make sure it works? Do the tests cover the PR motivation?
  • Are all the PR blockers dealt with?
    PR blockers can be dealt with in new tickets or PRs.

And check the PR Author checklist is complete.

Follow Up Work

@teor2345 teor2345 added C-enhancement Category: This is an improvement P-Medium ⚡ A-state Area: State / database changes A-blockchain-scanner Area: Blockchain scanner of shielded transactions labels Nov 27, 2023
@teor2345 teor2345 self-assigned this Nov 27, 2023
@teor2345 teor2345 requested a review from a team as a code owner November 27, 2023 01:49
@teor2345 teor2345 requested review from upbqdn and removed request for a team November 27, 2023 01:49
@teor2345 teor2345 requested review from a team as code owners November 27, 2023 20:22
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Nov 27, 2023
oxarbitrage
oxarbitrage previously approved these changes Nov 27, 2023
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from some unused code warnings this looks good, @teor2345 and I were in a meeting earlier today where they explained me the important parts of this PR, changes put ourselves one step closer to our needs of creating a database from the zebra-scan crate.

zebra-state/src/config.rs Outdated Show resolved Hide resolved
mergify bot added a commit that referenced this pull request Nov 28, 2023
@mergify mergify bot merged commit 1d241af into main Nov 28, 2023
129 checks passed
@mergify mergify bot deleted the db-kind branch November 28, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-scanner Area: Blockchain scanner of shielded transactions A-state Area: State / database changes C-enhancement Category: This is an improvement C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-use existing raw database code for the scanner, without splitting the state yet
2 participants