mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
Fix spec for `beacon_chain_sim
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
use node_test_rig::{
|
||||
environment::{EnvironmentBuilder, RuntimeContext},
|
||||
testing_client_config, ClientConfig, LocalBeaconNode, LocalValidatorClient, ProductionClient,
|
||||
ValidatorConfig,
|
||||
testing_client_config, ClientConfig, ClientGenesis, LocalBeaconNode, LocalValidatorClient,
|
||||
ProductionClient, ValidatorConfig,
|
||||
};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use types::EthSpec;
|
||||
|
||||
pub type BeaconNode<E> = LocalBeaconNode<ProductionClient<E>>;
|
||||
@@ -27,7 +28,16 @@ fn simulation(num_nodes: usize, validators_per_node: usize) -> Result<(), String
|
||||
.multi_threaded_tokio_runtime()?
|
||||
.build()?;
|
||||
|
||||
let base_config = testing_client_config();
|
||||
let mut base_config = testing_client_config();
|
||||
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("should get system time")
|
||||
.as_secs();
|
||||
base_config.genesis = ClientGenesis::Interop {
|
||||
genesis_time: now,
|
||||
validator_count: num_nodes * validators_per_node,
|
||||
};
|
||||
|
||||
let boot_node =
|
||||
BeaconNode::production(env.service_context("boot_node".into()), base_config.clone());
|
||||
@@ -39,7 +49,7 @@ fn simulation(num_nodes: usize, validators_per_node: usize) -> Result<(), String
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let validators = nodes
|
||||
let _validators = nodes
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, node)| {
|
||||
@@ -90,25 +100,6 @@ fn new_with_bootnode_via_enr<E: EthSpec>(
|
||||
BeaconNode::production(context, config)
|
||||
}
|
||||
|
||||
fn new_with_bootnode_via_multiaddr<E: EthSpec>(
|
||||
context: RuntimeContext<E>,
|
||||
boot_node: &BeaconNode<E>,
|
||||
base_config: ClientConfig,
|
||||
) -> BeaconNode<E> {
|
||||
let mut config = base_config;
|
||||
config.network.libp2p_nodes.push(
|
||||
boot_node
|
||||
.client
|
||||
.libp2p_listen_addresses()
|
||||
.expect("bootnode must have a network")
|
||||
.first()
|
||||
.expect("bootnode must have at least one listen addr")
|
||||
.clone(),
|
||||
);
|
||||
|
||||
BeaconNode::production(context, config)
|
||||
}
|
||||
|
||||
fn new_validator_client<E: EthSpec>(
|
||||
context: RuntimeContext<E>,
|
||||
beacon_node: &BeaconNode<E>,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use beacon_node::{beacon_chain::BeaconChainTypes, Client, ClientGenesis, ProductionBeaconNode};
|
||||
use beacon_node::{beacon_chain::BeaconChainTypes, Client, ProductionBeaconNode};
|
||||
use environment::RuntimeContext;
|
||||
use futures::Future;
|
||||
use remote_beacon_node::RemoteBeaconNode;
|
||||
@@ -8,7 +8,7 @@ use tempdir::TempDir;
|
||||
use types::EthSpec;
|
||||
use validator_client::{validator_directory::ValidatorDirectoryBuilder, ProductionValidatorClient};
|
||||
|
||||
pub use beacon_node::{ClientConfig, ProductionClient};
|
||||
pub use beacon_node::{ClientConfig, ClientGenesis, ProductionClient};
|
||||
pub use environment;
|
||||
pub use validator_client::Config as ValidatorConfig;
|
||||
|
||||
@@ -60,6 +60,8 @@ pub fn testing_client_config() -> ClientConfig {
|
||||
client_config.rest_api.port = 0;
|
||||
client_config.websocket_server.port = 0;
|
||||
|
||||
client_config.dummy_eth1_backend = true;
|
||||
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("should get system time")
|
||||
@@ -121,6 +123,10 @@ impl<E: EthSpec> LocalValidatorClient<E> {
|
||||
let client =
|
||||
ProductionValidatorClient::new(context, config).expect("should start validator client");
|
||||
|
||||
client
|
||||
.start_service()
|
||||
.expect("should start validator client");
|
||||
|
||||
Self { client, datadir }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,10 +169,6 @@ impl<E: EthSpec> Service<ValidatorServiceClient, Keypair, E> {
|
||||
|
||||
let slots_per_epoch = E::slots_per_epoch();
|
||||
|
||||
// TODO: keypairs are randomly generated; they should be loaded from a file or generated.
|
||||
// https://github.com/sigp/lighthouse/issues/160
|
||||
//let keypairs = Arc::new(generate_deterministic_keypairs(8));
|
||||
|
||||
// Builds a mapping of Epoch -> Map(PublicKey, EpochDuty)
|
||||
// where EpochDuty contains slot numbers and attestation data that each validator needs to
|
||||
// produce work on.
|
||||
|
||||
Reference in New Issue
Block a user