Skip to content

Commit

Permalink
fixed total process
Browse files Browse the repository at this point in the history
  • Loading branch information
nonast committed Mar 4, 2023
1 parent 04df840 commit 7fdda59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 3 additions & 4 deletions ol/genesis-tools/src/fork_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub fn make_recovery_genesis_from_vec_legacy_recovery(
// Otherwise, we might need to just collect the validator accounts
// for debugging or other test purposes.
// let expected_len_all_users = recovery.len() as u64;

let recovery_changeset = encode_recovery_genesis_changeset(
&all_validator_configs.vals,
&all_validator_configs.opers,
Expand All @@ -59,9 +58,7 @@ pub fn make_recovery_genesis_from_vec_legacy_recovery(
append_user_accounts,
recovery, // TODO: turn this into an option type
)?;

let gen_tx = Transaction::GenesisTransaction(WriteSetPayload::Direct(recovery_changeset));

save_genesis(&gen_tx, genesis_blob_path)?;
Ok(gen_tx)
}
Expand All @@ -86,7 +83,9 @@ pub fn make_recovery_genesis_from_vec_legacy_recovery(

/// save the genesis blob
pub fn save_genesis(gen_tx: &Transaction, output_path: PathBuf) -> Result<(), Error> {
let mut file = File::create(output_path)?;
let file_path = output_path.join("genesis").with_extension("blob");
println!("Saving genesis to: {:?}", &file_path);
let mut file = File::create(file_path)?;
let bytes = bcs::to_bytes(&gen_tx)?;
file.write_all(&bytes)?;
Ok(())
Expand Down
15 changes: 7 additions & 8 deletions ol/genesis-tools/src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl GenesisWizard {
} else {
// TODO(Nima): Instead of using a test, let's ask the user for the patht to a snapshot
let input = Input::<String>::new()
.with_prompt("Enter the (absolute) path to the snapshot")
.with_prompt("Enter the (absolute) path to the snapshot state.manifest file")
.interact_text()?;
PathBuf::from(input)
};
Expand All @@ -144,7 +144,7 @@ impl GenesisWizard {


// reset the safety rules
reset_safety_data(&self.data_path.join("key_store.json"), &app_config.format_oper_namespace());
reset_safety_data(&self.data_path, &app_config.format_oper_namespace());

// check db
self.maybe_backup_db();
Expand Down Expand Up @@ -253,7 +253,7 @@ impl GenesisWizard {
.interact().unwrap()
{
let storage_helper =
StorageHelper::get_with_path(self.data_path.join("key_store.json"));
StorageHelper::get_with_path(self.data_path.clone());

let mut owner_storage = storage_helper.storage(app_cfg.format_oper_namespace().clone());
owner_storage.set(OWNER_KEY, "").unwrap();
Expand Down Expand Up @@ -321,11 +321,10 @@ impl GenesisWizard {

pb.inc(1);
pb.set_message("registering the OPERATOR account.");
// The oper key is saved locally as key + -oper. This little hack works..
let set_oper =
ValidatorOperator::new(app_cfg.format_owner_namespace().clone(), &owner_shared);

ValidatorOperator::new(app_cfg.format_oper_namespace(), &owner_shared);
set_oper.execute()?;

// # OWNER does this
// # Links to an operator on github, creates the OWNER_ACCOUNT locally
// assign:
Expand Down Expand Up @@ -375,13 +374,13 @@ impl GenesisWizard {
}

fn check_keys_and_genesis(&self, app_cfg: &AppCfg) -> anyhow::Result<String> {
println!("Checking keys and genesis. Key name: {}", app_cfg.format_owner_namespace());
let val = Key::validator_backend(
app_cfg.format_oper_namespace().clone(),
app_cfg.format_owner_namespace().clone(),
self.data_path.clone(),
)?;

let v = Verify::new(&val,self.data_path.join("genesis.blob"));

Ok(v.execute()?)
}

Expand Down

0 comments on commit 7fdda59

Please sign in to comment.