mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 11:22:56 +00:00
stable futures fixes (#1124)
* Fix eth1 update functions * Fix genesis and client * Fix beacon node lib * Return appropriate runtimes from environment * Fix test rig * Refactor eth1 service update
This commit is contained in:
@@ -29,10 +29,10 @@ impl<E: EthSpec> LocalBeaconNode<E> {
|
||||
/// Starts a new, production beacon node on the tokio runtime in the given `context`.
|
||||
///
|
||||
/// The node created is using the same types as the node we use in production.
|
||||
pub fn production(
|
||||
pub async fn production(
|
||||
context: RuntimeContext<E>,
|
||||
mut client_config: ClientConfig,
|
||||
) -> impl Future<Item = Self, Error = String> {
|
||||
) -> Result<Self, String> {
|
||||
// Creates a temporary directory that will be deleted once this `TempDir` is dropped.
|
||||
let datadir = TempDir::new("lighthouse_node_test_rig")
|
||||
.expect("should create temp directory for client datadir");
|
||||
@@ -40,7 +40,7 @@ impl<E: EthSpec> LocalBeaconNode<E> {
|
||||
client_config.data_dir = datadir.path().into();
|
||||
client_config.network.network_dir = PathBuf::from(datadir.path()).join("network");
|
||||
|
||||
ProductionBeaconNode::new(context, client_config).map(move |client| Self {
|
||||
ProductionBeaconNode::new(context, client_config).await.map(move |client| Self {
|
||||
client: client.into_inner(),
|
||||
datadir,
|
||||
})
|
||||
@@ -105,43 +105,43 @@ impl<E: EthSpec> LocalValidatorClient<E> {
|
||||
/// are created in a temp dir then removed when the process exits.
|
||||
///
|
||||
/// The validator created is using the same types as the node we use in production.
|
||||
pub fn production_with_insecure_keypairs(
|
||||
pub async fn production_with_insecure_keypairs(
|
||||
context: RuntimeContext<E>,
|
||||
mut config: ValidatorConfig,
|
||||
keypair_indices: &[usize],
|
||||
) -> impl Future<Item = Self, Error = String> {
|
||||
) -> Result<Self, String> {
|
||||
// Creates a temporary directory that will be deleted once this `TempDir` is dropped.
|
||||
let datadir = TempDir::new("lighthouse-beacon-node")
|
||||
.expect("should create temp directory for client datadir");
|
||||
|
||||
config.key_source = KeySource::InsecureKeypairs(keypair_indices.to_vec());
|
||||
|
||||
Self::new(context, config, datadir)
|
||||
Self::new(context, config, datadir).await
|
||||
}
|
||||
|
||||
/// Creates a validator client that attempts to read keys from the default data dir.
|
||||
///
|
||||
/// - The validator created is using the same types as the node we use in production.
|
||||
/// - It is recommended to use `production_with_insecure_keypairs` for testing.
|
||||
pub fn production(
|
||||
pub async fn production(
|
||||
context: RuntimeContext<E>,
|
||||
config: ValidatorConfig,
|
||||
) -> impl Future<Item = Self, Error = String> {
|
||||
) -> Result<Self,String> {
|
||||
// Creates a temporary directory that will be deleted once this `TempDir` is dropped.
|
||||
let datadir = TempDir::new("lighthouse-validator")
|
||||
.expect("should create temp directory for client datadir");
|
||||
|
||||
Self::new(context, config, datadir)
|
||||
Self::new(context, config, datadir).await
|
||||
}
|
||||
|
||||
fn new(
|
||||
async fn new(
|
||||
context: RuntimeContext<E>,
|
||||
mut config: ValidatorConfig,
|
||||
datadir: TempDir,
|
||||
) -> impl Future<Item = Self, Error = String> {
|
||||
) -> Result<Self, String> {
|
||||
config.data_dir = datadir.path().into();
|
||||
|
||||
ProductionValidatorClient::new(context, config).map(move |mut client| {
|
||||
ProductionValidatorClient::new(context, config).await.map(move |mut client| {
|
||||
client
|
||||
.start_service()
|
||||
.expect("should start validator services");
|
||||
|
||||
Reference in New Issue
Block a user