Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Mar 2, 2023
1 parent dbc6cc3 commit b093c9b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
4 changes: 2 additions & 2 deletions config/management/genesis/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use diem_global_constants::{GENESIS_WAYPOINT, OPERATOR_ACCOUNT, OWNER_ACCOUNT, W
use diem_management::{
config::ConfigPath,
error::Error,
secure_backend::{MGMTSecureBackend, SharedBackend, ValidatorBackend},
secure_backend::{SharedBackend, ValidatorBackend},
};
use std::{convert::TryFrom, path::PathBuf, str::FromStr};
use std::{ path::PathBuf, str::FromStr};
use diem_secure_storage::{
CryptoStorage, OnDiskStorage, KVStorage
};
Expand Down
16 changes: 8 additions & 8 deletions ol/genesis-tools/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use anyhow::Result;
use diem_secure_storage::{GitHubStorage, Storage};
use vm_genesis::{TestValidator, Validator};
use std::{path::PathBuf, process::exit, time::Duration, thread};
use ol_types::{legacy_recovery::{save_recovery_file, read_from_recovery_file}, OLProgress};


use std::{path::PathBuf, process::exit};
use ol_types::{legacy_recovery::{save_recovery_file, read_from_recovery_file}};
use gumdrop::Options;
use diem_genesis_tool::genesis::Genesis;

use ol_genesis_tools::{
compare,
// swarm_genesis::make_swarm_genesis
fork_genesis::{
make_recovery_genesis_from_db_backup, make_recovery_genesis_from_vec_legacy_recovery,
make_recovery_genesis_from_vec_legacy_recovery,
},
process_snapshot::db_backup_into_recovery_struct, wizard, run::default_run,
};
use indicatif::ProgressIterator;


// #[tokio::main]
fn main() -> Result<()> {
Expand Down Expand Up @@ -86,7 +86,7 @@ fn main() -> Result<()> {
opts.genesis_repo_name.unwrap(),
opts.genesis_gh_token.unwrap(),
opts.debug,
);
)?;

Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion ol/genesis-tools/src/run.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! run forking genesis
use anyhow::Result;
use diem_secure_storage::{GitHubStorage, Storage};
use vm_genesis::{TestValidator};
Expand All @@ -12,7 +13,7 @@ use crate::{
};
use indicatif::ProgressIterator;


/// default genesis
pub fn default_run(
output_path: PathBuf,
snapshot_path: PathBuf,
Expand Down
42 changes: 23 additions & 19 deletions ol/genesis-tools/src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::path::PathBuf;
use std::str::FromStr;
use diem_types::chain_id::ChainId;
use diem_types::network_address::{NetworkAddress, Protocol};
use ol::mgmt::restore::Backup;
// use ol::mgmt::restore::Backup;


use crate::run;
Expand All @@ -32,15 +32,19 @@ fn test_wizard() {
let mut wizard = GenesisWizard::default();
wizard.start_wizard().unwrap();
}

/// Wizard for genesis
pub struct GenesisWizard {
///
pub namespace: String,
///
pub repo_owner: String,
///
pub repo_name: String,
github_username: String,
github_token: String,
data_path: PathBuf,
pub epoch: u64
///
pub epoch: u64
}

impl Default for GenesisWizard {
Expand Down Expand Up @@ -117,7 +121,7 @@ pub fn start_wizard(&mut self) -> anyhow::Result<()>{
self.repo_name.clone(),
self.github_token.clone(),
false
);
)?;

// create the files

Expand Down Expand Up @@ -294,24 +298,24 @@ fn git_setup(&mut self) -> anyhow::Result<()> {
Ok(())
}

fn restore_snapshot(&self, epoch: u64) -> anyhow::Result<()> {
let pb = ProgressBar::new(1)
.with_style(OLProgress::bar());
// fn restore_snapshot(&self, epoch: u64) -> anyhow::Result<()> {
// let pb = ProgressBar::new(1)
// .with_style(OLProgress::bar());

// We need to initialize the abscissa application state for this to work.. Else it panics
// TODO: fix panic of Backup::new().
// // We need to initialize the abscissa application state for this to work.. Else it panics
// // TODO: fix panic of Backup::new().

println!("Downloading snapshot for epoch {}", epoch);
// All we are doing is download the snapshot from github.
let backup = Backup::new(Option::from(epoch));
println!("Created backup object");
backup.fetch_backup(false)?;
println!("Downloaded snapshot for epoch {}", epoch);
// println!("Downloading snapshot for epoch {}", epoch);
// // All we are doing is download the snapshot from github.
// let backup = Backup::new(Option::from(epoch));
// println!("Created backup object");
// backup.fetch_backup(false)?;
// println!("Downloaded snapshot for epoch {}", epoch);

pb.inc(1);
pb.finish_and_clear();
Ok(())
}
// pb.inc(1);
// pb.finish_and_clear();
// Ok(())
// }

fn make_pull_request(&self) -> anyhow::Result<()> {
let gh_token_path = self.data_path.join("github_token.txt");
Expand Down
1 change: 0 additions & 1 deletion ol/genesis-tools/tests/snapshot_to_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ async fn test_read_db_backup_and_save_blob() {
make_recovery_genesis_from_db_backup(
output_path.clone(),
db_backup_path,
true,
false,
&genesis_vals,
)
Expand Down

0 comments on commit b093c9b

Please sign in to comment.