Skip to content

Commit

Permalink
ol restore defaults to only fetch the epoch boundary. --highest-versi…
Browse files Browse the repository at this point in the history
…on must be explicitly passed if the user wants versions beyond the epoch boundary (this is still experimental).
  • Loading branch information
0o-de-lally committed Jun 19, 2022
1 parent 7f8fddc commit 21c6942
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
11 changes: 4 additions & 7 deletions ol/cli/src/commands/restore_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@ pub struct RestoreCmd {
#[options(short="v", help = "specify a version or height if there is more than one per archive")]
version: Option<u64>,

#[options(short="b", help = "only restore the boundary, not an advanced version.")]
boundary_only: bool,

#[options(help = "get only the exact last block at the end of an epoch. Not extra blocks at the start of following epoch.")]
exclude_buffer: bool,
#[options(short="h", help = "fetch the highest version available, of the latest epoch.")]
highest_version: bool,
}

impl Runnable for RestoreCmd {
/// Start the application.
fn run(&self) {
match mgmt::restore::fast_forward_db(self.verbose, self.epoch, self.version, self.boundary_only) {
Ok(_) => {},
match mgmt::restore::fast_forward_db(self.verbose, self.epoch, self.version, self.highest_version) {
Ok(_) => {println!("SUCCESS")},
Err(e) => println!("ERROR: could not complete db restore, message: {:?}", e),
};
}
Expand Down
15 changes: 7 additions & 8 deletions ol/cli/src/mgmt/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn fast_forward_db(
verbose: bool,
epoch: Option<u64>,
version_opt: Option<u64>,
boundary_only: bool,
highest_version: bool,
) -> Result<(), Error> {
let mut backup = Backup::new(epoch);

Expand All @@ -64,14 +64,13 @@ pub fn fast_forward_db(
backup.set_waypoint()?;

println!("\nRestoring db from archive to home path");
backup.restore_backup(verbose, version_opt, boundary_only)?;
backup.restore_backup(verbose, version_opt, highest_version)?;

println!("\nCreating fullnode.node.yaml to home path");
backup.create_fullnode_yaml()?;

println!("\nResetting Safety Data in key_store.json\n");
diem_genesis_tool::key::reset_safety_data(&backup.home_path, &backup.node_namespace);
println!("SUCCESS");

Ok(())
}
Expand Down Expand Up @@ -180,10 +179,8 @@ impl Backup {
&self,
verbose: bool,
version_opt: Option<u64>,
boundary_only: bool,
highest_version: bool,
) -> Result<(), Error> {
dbg!(&version_opt);

let db_path = &self.home_path.join("db/");

let restore_path = self.restore_path.clone();
Expand All @@ -204,8 +201,10 @@ impl Backup {
verbose,
)?;

// Restore an advanced version in the epoch
if !boundary_only {
// Only restore a Version beyond the epoch boundary if explicitly requested
if highest_version || version_opt.is_some() {
println!("WARN: restoring a version beyond epoch boundary is EXPERIMENTAL");

let version = version_opt.unwrap_or(get_heighest_version(restore_path)?);

let restore_path_for_version = self.restore_path.to_owned().join(version.to_string());
Expand Down

0 comments on commit 21c6942

Please sign in to comment.