-
Notifications
You must be signed in to change notification settings - Fork 120
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): Refactor format upgrades into trait #9263
base: main
Are you sure you want to change the base?
Conversation
fn description(&self) -> &'static str; | ||
|
||
/// Runs disk format upgrade. | ||
fn run( |
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.
run_migration()
may be a better name for this method.
/// | ||
/// # Panics | ||
/// | ||
/// If the state has not been upgraded to this format correctly. |
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.
/// | |
/// # Panics | |
/// | |
/// If the state has not been upgraded to this format correctly. |
…uct, `PruneTrees`, and moves the logic for tree deduplication to the trait impl
…des to use new trait
199059a
to
59c0b24
Compare
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 good overall, but I'm confused about some parts. (Sorry, not super familiar with the original code)
} | ||
|
||
fn format_upgrades() -> Vec<Box<dyn DiskFormatUpgrade>> { | ||
// Note: Disk format upgrades must be run in order. |
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.
I think it would be good to check if they upgrades are really in order and panic if they're not
// Note: Disk format upgrades must be run in order. | |
// Note: Disk format upgrades must be run in order of database version. |
|
||
use super::{CancelFormatChange, DiskFormatUpgrade}; | ||
|
||
/// Implements [`DiskFormatUpgrade`] for pruning duplicate Sapling and Orchard note commitment trees from database |
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.
Wrong docs?
if older_disk_version >= &upgrade.version() { | ||
upgrade | ||
.validate(db, cancel_receiver)? | ||
.expect("failed to validate db format"); | ||
continue; |
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.
I'm a bit confused about this. The original code does not seem to do validate if the disk version >= upgrade version. Is this required or just good to have? What is the performance impact?
Motivation
This PR organizes Zebra's disk format upgrades into trait implementations to make them more maintainable as more upgrades are gradually added.
Closes #7932
Solution
DiskFormatUpgrade
traitTests
This change should be covered by existing tests for applying db format upgrades.
Follow-up Work
The bundle of db format changes needed to match zcashd's RPC outputs.
PR Author's Checklist
PR Reviewer's Checklist