Skip to content

Commit

Permalink
pd: scaffolding for jmt pruning command
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed Sep 7, 2023
1 parent 5e0c52f commit bd2ca1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,27 +559,36 @@ async fn main() -> anyhow::Result<()> {
t.write_configs()?;
}
RootCommand::Export {
data_path,
export_path,
mut data_path,
mut export_path,
prune,
} => {
tracing::info!("exporting state to {}", export_path.display());
use fs_extra;

tracing::info!("exporting state to {}", export_path.display());
let copy_opts = fs_extra::dir::CopyOptions::new();
data_path.push("rocksdb");
let from = [data_path.as_path()];
tracing::info!(
?data_path,
?export_path,
"copying from data dir to export dir",
);
fs_extra::copy_items(&from, export_path.as_path(), &copy_opts);
fs_extra::copy_items(&from, export_path.as_path(), &copy_opts)?;

tracing::info!("done copying");
if !prune {
return Ok(());
}

tracing::info!("pruning JMT tree");
export_path.push("rocksdb");
let export = Storage::load(export_path).await?;
let _ = StateDelta::new(export.latest_snapshot());
// TODO:
// - add utilities in `penumbra_storage` to prune a tree
// - apply the delta to the exported storage
// - apply checks: root hash, size, etc.
todo!()
}
}
Expand Down

0 comments on commit bd2ca1c

Please sign in to comment.