This commit syncs Prater

This commit is contained in:
Michael Sproul
2022-02-03 20:23:30 +11:00
parent 6c05b1de9b
commit f6230a5143
7 changed files with 30 additions and 15 deletions

View File

@@ -42,7 +42,8 @@ pub fn run<T: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(),
let mut deposit_tree = DepositDataTree::create(&[], 0, DEPOSIT_TREE_DEPTH);
let mut deposit_root = Hash256::zero();
for (index, validator) in state.validators_mut().iter_mut().enumerate() {
let mut validators = state.validators_mut();
for index in 0..validators.len() {
let (secret, _) =
recover_validator_secret_from_mnemonic(seed.as_bytes(), index as u32, KeyType::Voting)
.map_err(|e| format!("Unable to generate validator key: {:?}", e))?;
@@ -52,11 +53,11 @@ pub fn run<T: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(),
eprintln!("{}: {}", index, keypair.pk);
validator.pubkey = keypair.pk.into();
validators.get_mut(index).unwrap().pubkey = keypair.pk.into();
// Update the deposit tree.
let mut deposit_data = DepositData {
pubkey: validator.pubkey,
pubkey: validators.get(index).unwrap().pubkey,
// Set this to a junk value since it's very time consuming to generate the withdrawal
// keys and it's not useful for the time being.
withdrawal_credentials: Hash256::zero(),
@@ -69,6 +70,7 @@ pub fn run<T: EthSpec>(testnet_dir: PathBuf, matches: &ArgMatches) -> Result<(),
.map_err(|e| format!("failed to create deposit tree: {:?}", e))?;
deposit_root = deposit_tree.root();
}
drop(validators);
// Update the genesis validators root since we changed the validators.
*state.genesis_validators_root_mut() = state.validators().tree_hash_root();

View File

@@ -43,7 +43,7 @@ pub fn run_transition_blocks<T: EthSpec>(
let block: SignedBeaconBlock<T> =
load_from_ssz_with(&block_path, spec, SignedBeaconBlock::from_ssz_bytes)?;
let post_state = do_transition(pre_state, block, spec)?;
let post_state = do_transition(pre_state.clone(), block, spec)?;
let mut output_file =
File::create(output_path).map_err(|e| format!("Unable to create output file: {:?}", e))?;
@@ -52,6 +52,9 @@ pub fn run_transition_blocks<T: EthSpec>(
.write_all(&post_state.as_ssz_bytes())
.map_err(|e| format!("Unable to write to output file: {:?}", e))?;
drop(pre_state);
drop(post_state);
Ok(())
}