Skip to content

Commit

Permalink
cleanup unused files. clippy,
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Feb 16, 2023
1 parent e80ea3c commit a2fe6c5
Show file tree
Hide file tree
Showing 25 changed files with 568 additions and 1,315 deletions.
564 changes: 348 additions & 216 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions diem-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

mod genesis_context;
use anyhow::Error;
use diem_state_view::StateView;
use ol_types::legacy_recovery::{ValStateRecover, OperRecover, LegacyRecovery};
use std::env;
use crate::genesis_context::GenesisStateView;
Expand All @@ -21,7 +20,7 @@ use diem_types::{
account_config::{
self,
events::{CreateAccountEvent},
DESIGNATED_DEALER_MODULE, AccountResource, CurrencyInfoResource,
DESIGNATED_DEALER_MODULE,
},
chain_id::{ChainId},
contract_event::ContractEvent,
Expand Down Expand Up @@ -50,9 +49,6 @@ use transaction_builder::encode_create_designated_dealer_script_function;
//////// 0L ////////
use diem_global_constants::{GENESIS_VDF_SECURITY_PARAM, genesis_delay_difficulty};
pub use ol_types::{config::IS_PROD, genesis_proof::GenesisMiningProof};
use move_core_types::move_resource::MoveStructType;
use diem_types::access_path::AccessPath;
use move_core_types::move_resource::MoveResource;

// The seed is arbitrarily picked to produce a consistent key. XXX make this more formal?
const GENESIS_SEED: [u8; 32] = [42; 32];
Expand Down Expand Up @@ -206,7 +202,7 @@ pub fn encode_recovery_genesis_changeset(
val_set: &[AccountAddress],
chain: u8,
append_users: bool,
legacy_data: &Vec<LegacyRecovery>,
legacy_data: &[LegacyRecovery],
) -> Result<ChangeSet, Error> {
let mut stdlib_modules = Vec::new();
// create a data view for move_vm
Expand Down Expand Up @@ -249,7 +245,7 @@ pub fn encode_recovery_genesis_changeset(
// Recover the user accounts
diem_logger::info!("Starting user migration... ");
if append_users {
migrate_end_users(&mut session, &legacy_data).expect("failed to recover users");
migrate_end_users(&mut session, legacy_data).expect("failed to recover users");
}

// Trigger reconfiguration so that the validator set is updated.
Expand Down Expand Up @@ -281,7 +277,7 @@ pub fn encode_recovery_genesis_changeset(

/// fuction to iterate through a list of LegacyRecovery and recover the user accounts by calling a GenesisMigration.move in the VM. (as opposed to crafting writesets individually which could be fallible).

fn migrate_end_users(session: &mut Session<StateViewCache<GenesisStateView>>, legacy_data: &Vec<LegacyRecovery>) -> Result<u64, anyhow::Error>{
fn migrate_end_users(session: &mut Session<StateViewCache<GenesisStateView>>, legacy_data: &[LegacyRecovery]) -> Result<u64, anyhow::Error>{

let filtered_data: Vec<&LegacyRecovery>= legacy_data.iter()
.filter(|d| {
Expand Down
8 changes: 4 additions & 4 deletions ol/genesis-tools/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! -- morrissey via github copilot

use crate::db_utils;
use crate::recover;
use anyhow;
use diem_types::account_address::AccountAddress;
use diem_types::account_state::AccountState;
use ol_types::legacy_recovery::LegacyRecovery;
use ol_types::legacy_recovery::read_from_recovery_file;
use std::convert::TryFrom;
use std::path::PathBuf;

Expand All @@ -26,7 +26,7 @@ pub struct CompareError {
}
/// Compare the balances in a recovery file to the balances in a genesis blob.
pub fn compare_recovery_vec_to_genesis_blob(
recovery: &Vec<LegacyRecovery>,
recovery: &[LegacyRecovery],
genesis_path: PathBuf,
) -> Result<Vec<CompareError>, anyhow::Error> {
// start an empty btree map
Expand All @@ -35,7 +35,7 @@ pub fn compare_recovery_vec_to_genesis_blob(
// iterate over the recovery file and compare balances
let (db_rw, _) = db_utils::read_db_and_compute_genesis(genesis_path)?;

recovery.into_iter().enumerate().for_each(|(i, v)| {
recovery.iter().enumerate().for_each(|(i, v)| {
if v.account.is_none() {
err_list.push(CompareError {
index: i as u64,
Expand Down Expand Up @@ -133,7 +133,7 @@ pub fn compare_json_to_genesis_blob(
json_path: PathBuf,
genesis_path: PathBuf,
) -> Result<Vec<CompareError>, anyhow::Error> {
let recovery = recover::read_from_recovery_file(&json_path);
let recovery = read_from_recovery_file(&json_path);
compare_recovery_vec_to_genesis_blob(&recovery, genesis_path)
}

Expand Down
49 changes: 0 additions & 49 deletions ol/genesis-tools/src/exec_migration.rs

This file was deleted.

22 changes: 0 additions & 22 deletions ol/genesis-tools/src/fetch_archive.rs

This file was deleted.

18 changes: 3 additions & 15 deletions ol/genesis-tools/src/fork_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

use crate::process_snapshot::{db_backup_into_recovery_struct};
use crate::recover::{
recover_validator_configs,
};
use anyhow::{Error};

use anyhow::{Error};
use diem_types::account_address::AccountAddress;


use diem_types::transaction::{Transaction, WriteSetPayload};





use ol_types::legacy_recovery::LegacyRecovery;

use ol_types::legacy_recovery::{LegacyRecovery, recover_validator_configs};
use vm_genesis::encode_recovery_genesis_changeset;

/// Make a recovery genesis blob from archive
Expand All @@ -44,7 +32,7 @@ pub async fn make_recovery_genesis_from_db_backup(

/// Make a recovery genesis blob
pub fn make_recovery_genesis_from_vec_legacy_recovery(
recovery: &Vec<LegacyRecovery>,
recovery: &[LegacyRecovery],
genesis_vals: Vec<AccountAddress>,
genesis_blob_path: PathBuf,
append_user_accounts: bool,
Expand Down
7 changes: 2 additions & 5 deletions ol/genesis-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
unused_qualifications
)]

pub mod fetch_archive;
// pub mod fetch_archive; // Deprecated. Validators will fetch backup zip manually.
// pub mod fork_daemon; // Note: 0L deleted: This is feature (fork daemon shouldn't be exposed yet, it will not ship with this version of the recovery tool)
pub mod compare;
pub mod db_utils;
pub mod fork_genesis;
pub mod process_snapshot;
pub mod read_snapshot;
pub mod recover;
pub mod exec_migration;
// pub mod exec_migration_alt;
pub mod ol_genesis_context;
// pub mod recover;
// pub mod swarm_genesis; // Note: 0L deleted: starting a test environment (Swarm in v5) has changed. Now we would use Forge. And that would be external to main code. Either in ./src/tests or in the Smoke tests directory.
18 changes: 7 additions & 11 deletions ol/genesis-tools/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use diem_types::account_address::AccountAddress;
use std::{path::PathBuf, process::exit};

use ol_types::legacy_recovery::{save_recovery_file, read_from_recovery_file};
use gumdrop::Options;
use ol_genesis_tools::{
compare,
Expand All @@ -10,8 +10,6 @@ use ol_genesis_tools::{
make_recovery_genesis_from_db_backup, make_recovery_genesis_from_vec_legacy_recovery,
},
process_snapshot::db_backup_into_recovery_struct,
recover::read_from_recovery_file,
recover::save_recovery_file,
};

#[tokio::main]
Expand Down Expand Up @@ -80,7 +78,7 @@ async fn main() -> Result<()> {
)
.await
.expect("ERROR: could not create genesis from snapshot");
return Ok(());
Ok(())
}
// Path 2:
// if we have a Recovery JSON file, let's use that.
Expand All @@ -98,7 +96,7 @@ async fn main() -> Result<()> {
opts.legacy
)
.expect("ERROR: failed to create genesis from recovery file");
return Ok(());
Ok(())
} else {
panic!("ERROR: must provide --snapshot-path or --recovery-json-path, exiting.");
}
Expand All @@ -107,7 +105,7 @@ async fn main() -> Result<()> {
opts.output_path.unwrap(),
opts.recovery_json_path.unwrap(),
)?;
if err_list.len() > 0 {
if !err_list.is_empty() {
println!("ERROR: found errors:");

err_list.into_iter().for_each(|ce| {
Expand All @@ -132,12 +130,10 @@ async fn main() -> Result<()> {
.await
.expect("could not export DB into JSON recovery file");

save_recovery_file(&recovery_struct, &json_destination_path).expect(&format!(
"ERROR: recovery data extracted, but failed to save file {:?}",
&json_destination_path
));
save_recovery_file(&recovery_struct, &json_destination_path).unwrap_or_else(|_| panic!("ERROR: recovery data extracted, but failed to save file {:?}",
&json_destination_path));

return Ok(());
Ok(())
} else {
println!("ERROR: no options provided, exiting.");
exit(1);
Expand Down
44 changes: 0 additions & 44 deletions ol/genesis-tools/src/ol_genesis_context.rs

This file was deleted.

Loading

0 comments on commit a2fe6c5

Please sign in to comment.