diff --git a/Cargo.lock b/Cargo.lock index af112497b7..3a4be60405 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2296,6 +2296,12 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "funty" version = "2.0.0" @@ -4427,6 +4433,7 @@ dependencies = [ "decaf377-rdsa", "directories", "ed25519-consensus", + "fs_extra", "futures", "hex", "http", diff --git a/crates/bin/pd/src/main.rs b/crates/bin/pd/src/main.rs index 8e30bca285..b4fcfe6568 100644 --- a/crates/bin/pd/src/main.rs +++ b/crates/bin/pd/src/main.rs @@ -559,20 +559,22 @@ 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(), ©_opts); + fs_extra::copy_items(&from, export_path.as_path(), ©_opts)?; tracing::info!("done copying"); if !prune { @@ -580,6 +582,13 @@ async fn main() -> anyhow::Result<()> { } 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!() } }