mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Fix spec for `beacon_chain_sim
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
use node_test_rig::{
|
use node_test_rig::{
|
||||||
environment::{EnvironmentBuilder, RuntimeContext},
|
environment::{EnvironmentBuilder, RuntimeContext},
|
||||||
testing_client_config, ClientConfig, LocalBeaconNode, LocalValidatorClient, ProductionClient,
|
testing_client_config, ClientConfig, ClientGenesis, LocalBeaconNode, LocalValidatorClient,
|
||||||
ValidatorConfig,
|
ProductionClient, ValidatorConfig,
|
||||||
};
|
};
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use types::EthSpec;
|
use types::EthSpec;
|
||||||
|
|
||||||
pub type BeaconNode<E> = LocalBeaconNode<ProductionClient<E>>;
|
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()?
|
.multi_threaded_tokio_runtime()?
|
||||||
.build()?;
|
.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 =
|
let boot_node =
|
||||||
BeaconNode::production(env.service_context("boot_node".into()), base_config.clone());
|
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<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let validators = nodes
|
let _validators = nodes
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, node)| {
|
.map(|(i, node)| {
|
||||||
@@ -90,25 +100,6 @@ fn new_with_bootnode_via_enr<E: EthSpec>(
|
|||||||
BeaconNode::production(context, config)
|
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>(
|
fn new_validator_client<E: EthSpec>(
|
||||||
context: RuntimeContext<E>,
|
context: RuntimeContext<E>,
|
||||||
beacon_node: &BeaconNode<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 environment::RuntimeContext;
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use remote_beacon_node::RemoteBeaconNode;
|
use remote_beacon_node::RemoteBeaconNode;
|
||||||
@@ -8,7 +8,7 @@ use tempdir::TempDir;
|
|||||||
use types::EthSpec;
|
use types::EthSpec;
|
||||||
use validator_client::{validator_directory::ValidatorDirectoryBuilder, ProductionValidatorClient};
|
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 environment;
|
||||||
pub use validator_client::Config as ValidatorConfig;
|
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.rest_api.port = 0;
|
||||||
client_config.websocket_server.port = 0;
|
client_config.websocket_server.port = 0;
|
||||||
|
|
||||||
|
client_config.dummy_eth1_backend = true;
|
||||||
|
|
||||||
let now = SystemTime::now()
|
let now = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.expect("should get system time")
|
.expect("should get system time")
|
||||||
@@ -121,6 +123,10 @@ impl<E: EthSpec> LocalValidatorClient<E> {
|
|||||||
let client =
|
let client =
|
||||||
ProductionValidatorClient::new(context, config).expect("should start validator client");
|
ProductionValidatorClient::new(context, config).expect("should start validator client");
|
||||||
|
|
||||||
|
client
|
||||||
|
.start_service()
|
||||||
|
.expect("should start validator client");
|
||||||
|
|
||||||
Self { client, datadir }
|
Self { client, datadir }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,10 +169,6 @@ impl<E: EthSpec> Service<ValidatorServiceClient, Keypair, E> {
|
|||||||
|
|
||||||
let slots_per_epoch = E::slots_per_epoch();
|
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)
|
// Builds a mapping of Epoch -> Map(PublicKey, EpochDuty)
|
||||||
// where EpochDuty contains slot numbers and attestation data that each validator needs to
|
// where EpochDuty contains slot numbers and attestation data that each validator needs to
|
||||||
// produce work on.
|
// produce work on.
|
||||||
|
|||||||
Reference in New Issue
Block a user