-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool Scrubber Graduation PR for V6 #1174
base: v6
Are you sure you want to change the base?
Changes from all commits
c3cc486
e87146d
665397f
6b4d243
89a8236
61c2316
69150d2
9f5e0ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ use crate::prelude::app_config; | |
use diem_types::transaction::SignedTransaction; | ||
use diem_wallet::WalletLibrary; | ||
use ol_types::{account::ValConfigs, pay_instruction::PayInstruction}; | ||
use std::path::PathBuf; | ||
use std::{path::PathBuf, process::exit}; | ||
|
||
/// Creates an account.json file for the validator | ||
pub fn write_manifest( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should return Result |
||
|
@@ -31,14 +31,22 @@ pub fn write_manifest( | |
|
||
let keys = KeyScheme::new(&wallet); | ||
let block = VDFProof::parse_block_file(cfg.get_block_dir().join("proof_0.json").to_owned()); | ||
|
||
return ValConfigs::new( | ||
let val_cfg_res = ValConfigs::new( | ||
Some(block), | ||
keys, | ||
cfg.profile.ip, | ||
cfg.profile.vfn_ip.unwrap_or("0.0.0.0".parse().unwrap()), | ||
autopay_batch, | ||
autopay_signed, | ||
) | ||
.create_manifest(miner_home) | ||
); | ||
|
||
let val_cfg = match val_cfg_res { | ||
Ok(cfg) => cfg, | ||
Err(error) => { | ||
println!("Could not create validator config: {:?}", error); | ||
exit(1); | ||
} | ||
|
||
}; | ||
return val_cfg.create_manifest(miner_home) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ impl Runnable for ValConfigCmd { | |
// let _entry_args = entrypoint::get_args(); | ||
let (_, _, w) = wallet::get_account_from_prompt(); | ||
|
||
let val_cfg = ValConfigs::new( | ||
let val_cfg_res = ValConfigs::new( | ||
None, | ||
KeyScheme::new(&w), | ||
self.val_ip.expect("neeed a validator ip address"), | ||
|
@@ -41,6 +41,11 @@ impl Runnable for ValConfigCmd { | |
None, | ||
); | ||
|
||
let val_cfg = match val_cfg_res { | ||
Ok(cfg) => cfg, | ||
Err(error) => panic!("Could not create validator config: {:?}", error), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove panic! for exit() |
||
}; | ||
|
||
let txt = format!("New consensus pubkey: {} \n | ||
New validator network addresses: {}, \n | ||
New vfn fullnode network addresses: {}", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ use diem_crypto::x25519::PublicKey; | |
use diem_global_constants::{DEFAULT_PUB_PORT, DEFAULT_VAL_PORT, DEFAULT_VFN_PORT}; | ||
use diem_types::{ | ||
account_address::AccountAddress, | ||
network_address::{NetworkAddress}, | ||
network_address::NetworkAddress, | ||
transaction::{SignedTransaction, TransactionPayload}, | ||
}; | ||
|
||
|
@@ -85,12 +85,11 @@ impl ValConfigs { | |
vfn_ip_address: Ipv4Addr, | ||
autopay_instructions: Option<Vec<PayInstruction>>, | ||
autopay_signed: Option<Vec<SignedTransaction>>, | ||
) -> Self { | ||
) -> Result<ValConfigs, anyhow::Error> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Result<ValConfigs... |
||
let owner_address = keys.child_0_owner.get_address(); | ||
|
||
let val_pubkey = | ||
PublicKey::from_ed25519_public_bytes(&keys.child_2_val_network.get_public().to_bytes()) | ||
.unwrap(); | ||
PublicKey::from_ed25519_public_bytes(&keys.child_2_val_network.get_public().to_bytes())?; | ||
|
||
let val_addr_for_val_net = | ||
ValConfigs::make_unencrypted_addr(&val_ip_address, val_pubkey, NetworkId::Validator); | ||
|
@@ -115,12 +114,11 @@ impl ValConfigs { | |
// to connect to its fullnode. | ||
let vfn_pubkey = PublicKey::from_ed25519_public_bytes( | ||
&keys.child_3_fullnode_network.get_public().to_bytes(), | ||
) | ||
.unwrap(); | ||
)?; | ||
let vfn_addr_obj = | ||
ValConfigs::make_unencrypted_addr(&vfn_ip_address, vfn_pubkey, NetworkId::Public); | ||
|
||
Self { | ||
let new_conf = Self { | ||
/// Proof zero of the onboarded miner | ||
block_zero, | ||
ow_human_name: owner_address, | ||
|
@@ -133,15 +131,16 @@ impl ValConfigs { | |
op_consensus_pubkey: keys.child_4_consensus.get_public().to_bytes().to_vec(), | ||
// 0L todo diem-1.4.1 | ||
// op_validator_network_addresses: bcs::to_bytes(&vec![encrypted_addr]).unwrap(), | ||
op_validator_network_addresses: bcs::to_bytes(&vec![&val_addr_for_val_net]).unwrap(), | ||
op_fullnode_network_addresses: bcs::to_bytes(&vec![&vfn_addr_obj]).unwrap(), | ||
op_validator_network_addresses: bcs::to_bytes(&vec![&val_addr_for_val_net])?, | ||
op_fullnode_network_addresses: bcs::to_bytes(&vec![&vfn_addr_obj])?, | ||
op_val_net_addr_for_vals: val_addr_for_val_net.to_owned(), | ||
op_val_net_addr_for_vfn: val_addr_for_vfn_net.to_owned(), | ||
op_vfn_net_addr_for_public: vfn_addr_obj.to_owned(), | ||
op_human_name: format!("{}-oper", owner_address), //NOTE: This must match ol/types/src/config.rs format_oper_namespace | ||
autopay_instructions, | ||
autopay_signed, | ||
} | ||
}; | ||
Ok(new_conf) | ||
} | ||
/// Creates the json file needed for onchain account creation - validator | ||
pub fn create_manifest(&self, mut json_path: PathBuf) -> Result<(), anyhow::Error>{ | ||
|
@@ -231,7 +230,7 @@ impl ValConfigs { | |
let tx = signed.iter().nth(i).unwrap(); | ||
let payload = tx.clone().into_raw_transaction().into_payload(); | ||
if let TransactionPayload::Script(s) = payload { | ||
match instr.check_instruction_match_tx(s.clone()) { | ||
match instr.check_instruction_match_tx(&s) { // Now passing reference instead of s.clone() (Michael64) | ||
Ok(_) => {} | ||
Err(e) => { | ||
// TODO: should this panic? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write_account_json should return Result