mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Fix issues with testnet dir, update docs (#992)
* Fix issues with testnet dir, update docs * Remove "simple testnet" docs * Tear out old "bn testnet" stuff * Add back ClientGenesis::Interop * Tidy * Remove lighthouse-bootstrap module * Fix bug with spec constant mismatch * Ensure beacon-node.toml is written to correct dir * Add -t alias for --testnet-dir * Update book/src/local-testnets.md Co-Authored-By: Age Manning <Age@AgeManning.com> * Add --purge CLI flag * Update purge docs * Perform manual delete of files in purge * Rename --purge to --purge-db * Address Michael's comments Co-authored-by: Age Manning <Age@AgeManning.com>
This commit is contained in:
@@ -3,7 +3,6 @@ use eth2_hashing::hash;
|
||||
use rayon::prelude::*;
|
||||
use ssz::Encode;
|
||||
use state_processing::initialize_beacon_state_from_eth1;
|
||||
use std::time::SystemTime;
|
||||
use types::{BeaconState, ChainSpec, DepositData, EthSpec, Hash256, Keypair, PublicKey, Signature};
|
||||
|
||||
/// Builds a genesis state as defined by the Eth2 interop procedure (see below).
|
||||
@@ -57,18 +56,6 @@ pub fn interop_genesis_state<T: EthSpec>(
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
/// Returns the system time, mod 30 minutes.
|
||||
///
|
||||
/// Used for easily creating testnets.
|
||||
pub fn recent_genesis_time(minutes: u64) -> u64 {
|
||||
let now = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
let secs_after_last_period = now.checked_rem(minutes * 60).unwrap_or(0);
|
||||
now - secs_after_last_period
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -4,28 +4,5 @@ mod interop;
|
||||
|
||||
pub use eth1::Config as Eth1Config;
|
||||
pub use eth1_genesis_service::Eth1GenesisService;
|
||||
pub use interop::{interop_genesis_state, recent_genesis_time};
|
||||
pub use interop::interop_genesis_state;
|
||||
pub use types::test_utils::generate_deterministic_keypairs;
|
||||
|
||||
use ssz::Decode;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
/// Load a `BeaconState` from the given `path`. The file should contain raw SSZ bytes (i.e., no
|
||||
/// ASCII encoding or schema).
|
||||
pub fn state_from_ssz_file<E: EthSpec>(path: PathBuf) -> Result<BeaconState<E>, String> {
|
||||
File::open(path.clone())
|
||||
.map_err(move |e| format!("Unable to open SSZ genesis state file {:?}: {:?}", path, e))
|
||||
.and_then(|mut file| {
|
||||
let mut bytes = vec![];
|
||||
file.read_to_end(&mut bytes)
|
||||
.map_err(|e| format!("Failed to read SSZ file: {:?}", e))?;
|
||||
Ok(bytes)
|
||||
})
|
||||
.and_then(|bytes| {
|
||||
BeaconState::from_ssz_bytes(&bytes)
|
||||
.map_err(|e| format!("Unable to parse SSZ genesis state file: {:?}", e))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user