mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Modify bn CLI to parse eth2_testnet_dir
This commit is contained in:
@@ -34,3 +34,4 @@ logging = { path = "../eth2/utils/logging" }
|
|||||||
futures = "0.1.29"
|
futures = "0.1.29"
|
||||||
environment = { path = "../lighthouse/environment" }
|
environment = { path = "../lighthouse/environment" }
|
||||||
genesis = { path = "genesis" }
|
genesis = { path = "genesis" }
|
||||||
|
eth2_testnet = { path = "../eth2/utils/eth2_testnet" }
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub const NOTIFIER_INTERVAL_SECONDS: u64 = 15;
|
|||||||
/// Create a warning log whenever the peer count is at or below this value.
|
/// Create a warning log whenever the peer count is at or below this value.
|
||||||
pub const WARN_PEER_COUNT: usize = 1;
|
pub const WARN_PEER_COUNT: usize = 1;
|
||||||
/// Interval between polling the eth1 node for genesis information.
|
/// Interval between polling the eth1 node for genesis information.
|
||||||
pub const ETH1_GENESIS_UPDATE_INTERVAL_MILLIS: u64 = 500;
|
pub const ETH1_GENESIS_UPDATE_INTERVAL_MILLIS: u64 = 7_000;
|
||||||
|
|
||||||
/// Builds a `Client` instance.
|
/// Builds a `Client` instance.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use futures::{
|
|||||||
Future,
|
Future,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use slog::{debug, error, info, Logger};
|
use slog::{debug, error, info, trace, Logger};
|
||||||
use state_processing::{
|
use state_processing::{
|
||||||
initialize_beacon_state_from_eth1, is_valid_genesis_state,
|
initialize_beacon_state_from_eth1, is_valid_genesis_state,
|
||||||
per_block_processing::process_deposit, process_activations,
|
per_block_processing::process_deposit, process_activations,
|
||||||
@@ -158,7 +158,7 @@ impl Eth1GenesisService {
|
|||||||
{
|
{
|
||||||
Ok(Loop::Break((spec, genesis_state)))
|
Ok(Loop::Break((spec, genesis_state)))
|
||||||
} else {
|
} else {
|
||||||
debug!(
|
trace!(
|
||||||
service_4.core.log,
|
service_4.core.log,
|
||||||
"No eth1 genesis block found";
|
"No eth1 genesis block found";
|
||||||
"cached_blocks" => service_4.core.block_cache_len(),
|
"cached_blocks" => service_4.core.block_cache_len(),
|
||||||
@@ -205,15 +205,16 @@ impl Eth1GenesisService {
|
|||||||
.filter(|block| {
|
.filter(|block| {
|
||||||
self.highest_known_block()
|
self.highest_known_block()
|
||||||
.map(|n| block.number <= n)
|
.map(|n| block.number <= n)
|
||||||
.unwrap_or_else(|| false)
|
.unwrap_or_else(|| true)
|
||||||
})
|
})
|
||||||
.find(|block| {
|
.find(|block| {
|
||||||
let mut highest_processed_block = self.highest_processed_block.lock();
|
let mut highest_processed_block = self.highest_processed_block.lock();
|
||||||
|
let block_number = block.number;
|
||||||
|
|
||||||
let next_new_block_number =
|
let next_new_block_number =
|
||||||
highest_processed_block.map(|n| n + 1).unwrap_or_else(|| 0);
|
highest_processed_block.map(|n| n + 1).unwrap_or_else(|| 0);
|
||||||
|
|
||||||
if block.number < next_new_block_number {
|
if block_number < next_new_block_number {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +223,17 @@ impl Eth1GenesisService {
|
|||||||
*highest_processed_block = Some(block.number);
|
*highest_processed_block = Some(block.number);
|
||||||
Ok(val)
|
Ok(val)
|
||||||
})
|
})
|
||||||
|
.map(|is_valid| {
|
||||||
|
if !is_valid {
|
||||||
|
info!(
|
||||||
|
self.core.log,
|
||||||
|
"Inspected new eth1 block";
|
||||||
|
"msg" => "did not trigger genesis",
|
||||||
|
"block_number" => block_number
|
||||||
|
);
|
||||||
|
};
|
||||||
|
is_valid
|
||||||
|
})
|
||||||
.unwrap_or_else(|_| {
|
.unwrap_or_else(|_| {
|
||||||
error!(
|
error!(
|
||||||
self.core.log,
|
self.core.log,
|
||||||
|
|||||||
@@ -306,16 +306,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.help("A file from which to read the state"))
|
.help("A file from which to read the state"))
|
||||||
)
|
)
|
||||||
/*
|
/*
|
||||||
* `sigp`
|
* `eth1`
|
||||||
*
|
*
|
||||||
* Connect to a Sigma Prime testnet.
|
* Connect to a Sigma Prime testnet.
|
||||||
*/
|
*/
|
||||||
.subcommand(SubCommand::with_name("sigp")
|
.subcommand(SubCommand::with_name("eth1")
|
||||||
.about("Connect to a Sigma Prime testnet on Goerli.")
|
.about("Connect to a testnet defined by an eth2_testnet directory.")
|
||||||
.arg(Arg::with_name("file")
|
.arg(Arg::with_name("directory")
|
||||||
.value_name("JSON_FILE")
|
.value_name("DIRECTORY")
|
||||||
.required(true)
|
.index(1)
|
||||||
.help("A sigma_prime_testnet.json file"))
|
.help("A directory generated by lcli. Defaults to ~/.lighthouse/testnet. See lcli testnet --help"))
|
||||||
)
|
)
|
||||||
/*
|
/*
|
||||||
* `prysm`
|
* `prysm`
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use client::{ClientConfig, ClientGenesis, Eth2Config};
|
use client::{ClientConfig, ClientGenesis, Eth2Config};
|
||||||
use eth2_config::{read_from_file, write_to_file};
|
use eth2_config::{read_from_file, write_to_file};
|
||||||
|
use eth2_testnet::Eth2TestnetDir;
|
||||||
use genesis::recent_genesis_time;
|
use genesis::recent_genesis_time;
|
||||||
use lighthouse_bootstrap::Bootstrapper;
|
use lighthouse_bootstrap::Bootstrapper;
|
||||||
use rand::{distributions::Alphanumeric, Rng};
|
use rand::{distributions::Alphanumeric, Rng};
|
||||||
@@ -251,6 +252,37 @@ fn process_testnet_subcommand(
|
|||||||
|
|
||||||
builder.set_genesis(ClientGenesis::DepositContract)
|
builder.set_genesis(ClientGenesis::DepositContract)
|
||||||
}
|
}
|
||||||
|
("eth1", Some(_)) => {
|
||||||
|
let mut spec = &mut builder.eth2_config.spec;
|
||||||
|
let mut client_config = &mut builder.client_config;
|
||||||
|
|
||||||
|
let directory: PathBuf = cli_args
|
||||||
|
.value_of("datadir")
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_or_else(|| client_config.data_dir.join("testnet"));
|
||||||
|
|
||||||
|
let eth2_testnet_dir = Eth2TestnetDir::load(directory)
|
||||||
|
.map_err(|e| format!("Unable to open testnet dir: {}", e))?;
|
||||||
|
|
||||||
|
spec.min_deposit_amount = 100;
|
||||||
|
spec.max_effective_balance = 3_200_000_000;
|
||||||
|
spec.ejection_balance = 1_600_000_000;
|
||||||
|
spec.effective_balance_increment = 100_000_000;
|
||||||
|
spec.min_genesis_time = 0;
|
||||||
|
spec.genesis_fork = Fork {
|
||||||
|
previous_version: [0; 4],
|
||||||
|
current_version: [0, 0, 0, 42],
|
||||||
|
epoch: Epoch::new(0),
|
||||||
|
};
|
||||||
|
|
||||||
|
client_config.eth1.deposit_contract_address = eth2_testnet_dir.deposit_contract_address;
|
||||||
|
client_config.eth1.deposit_contract_deploy_block =
|
||||||
|
eth2_testnet_dir.deposit_contract_deploy_block;
|
||||||
|
client_config.eth1.follow_distance = 16;
|
||||||
|
client_config.dummy_eth1_backend = false;
|
||||||
|
|
||||||
|
builder.set_genesis(ClientGenesis::DepositContract)
|
||||||
|
}
|
||||||
(cmd, Some(_)) => {
|
(cmd, Some(_)) => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Invalid valid method specified: {}. See 'testnet --help'.",
|
"Invalid valid method specified: {}. See 'testnet --help'.",
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ pub fn new_testnet<T: EthSpec>(
|
|||||||
|
|
||||||
Eth2TestnetDir::new(
|
Eth2TestnetDir::new(
|
||||||
output_dir,
|
output_dir,
|
||||||
format!("0x{}", deposit_contract.address()),
|
format!("{}", deposit_contract.address()),
|
||||||
deploy_block.as_u64(),
|
deploy_block.as_u64(),
|
||||||
min_genesis_time,
|
min_genesis_time,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user