mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 04:48:21 +00:00
Optimizations, disable val client sync check & additional lcli tools (#834)
* Start adding interop genesis state to lcli * Use more efficient method to generate genesis state * Remove duplicate int_to_bytes32 * Add lcli command to change state genesis time * Add option to allow VC to start with unsynced BN * Set VC to do parallel key loading * Don't default to dummy eth1 backend * Add endpoint to dump operation pool * Add metrics for op pool * Remove state clone for slot notifier * Add mem size approximation for tree hash cache * Avoid cloning tree hash when getting head * Fix failing API tests * Address Michael's comments * Add HashMap::from_par_iter
This commit is contained in:
40
lcli/src/change_genesis_time.rs
Normal file
40
lcli/src/change_genesis_time.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use clap::ArgMatches;
|
||||
use ssz::{Decode, Encode};
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
|
||||
let path = matches
|
||||
.value_of("ssz-state")
|
||||
.ok_or_else(|| "ssz-state not specified")?
|
||||
.parse::<PathBuf>()
|
||||
.map_err(|e| format!("Unable to parse ssz-state: {}", e))?;
|
||||
|
||||
let genesis_time = matches
|
||||
.value_of("genesis-time")
|
||||
.ok_or_else(|| "genesis-time not specified")?
|
||||
.parse::<u64>()
|
||||
.map_err(|e| format!("Unable to parse genesis-time: {}", e))?;
|
||||
|
||||
let mut state: BeaconState<T> = {
|
||||
let mut file = File::open(&path).map_err(|e| format!("Unable to open file: {}", e))?;
|
||||
|
||||
let mut ssz = vec![];
|
||||
|
||||
file.read_to_end(&mut ssz)
|
||||
.map_err(|e| format!("Unable to read file: {}", e))?;
|
||||
|
||||
BeaconState::from_ssz_bytes(&ssz).map_err(|e| format!("Unable to decode SSZ: {:?}", e))?
|
||||
};
|
||||
|
||||
state.genesis_time = genesis_time;
|
||||
|
||||
let mut file = File::create(path).map_err(|e| format!("Unable to create file: {}", e))?;
|
||||
|
||||
file.write_all(&state.as_ssz_bytes())
|
||||
.map_err(|e| format!("Unable to write to file: {}", e))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user