From 2e1d657d4c66261ed36f9dd9c0d06d8f6c48934b Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 23 Sep 2020 13:04:19 +1000 Subject: [PATCH] Rename BeaconNodeClient -> BeaconNodeHttpClient --- beacon_node/http_api/tests/tests.rs | 6 +++--- common/eth2/src/lib.rs | 4 ++-- common/eth2/src/lighthouse.rs | 4 ++-- testing/node_test_rig/src/lib.rs | 6 +++--- testing/simulator/src/local_network.rs | 4 ++-- validator_client/src/attestation_service.rs | 8 ++++---- validator_client/src/block_service.rs | 8 ++++---- validator_client/src/duties_service.rs | 8 ++++---- validator_client/src/fork_service.rs | 8 ++++---- validator_client/src/is_synced.rs | 4 ++-- validator_client/src/lib.rs | 8 ++++---- validator_client/src/validator_duty.rs | 4 ++-- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 4072ae15a37..162cdcf149c 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -7,7 +7,7 @@ use beacon_chain::{ }; use discv5::enr::{CombinedKey, EnrBuilder}; use environment::null_logger; -use eth2::{types::*, BeaconNodeClient, Url}; +use eth2::{types::*, BeaconNodeHttpClient, Url}; use eth2_libp2p::{rpc::methods::MetaData, types::EnrBitfield, NetworkGlobals}; use http_api::{Config, Context}; use network::NetworkMessage; @@ -43,7 +43,7 @@ const SKIPPED_SLOTS: &[u64] = &[ struct ApiTester { chain: Arc>>, - client: BeaconNodeClient, + client: BeaconNodeHttpClient, next_block: SignedBeaconBlock, attestations: Vec>, attester_slashing: AttesterSlashing, @@ -167,7 +167,7 @@ impl ApiTester { tokio::spawn(async { server.await }); - let client = BeaconNodeClient::new( + let client = BeaconNodeHttpClient::new( Url::parse(&format!( "http://{}:{}", listening_socket.ip(), diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index f5203b9a986..84429e3b88d 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -53,12 +53,12 @@ impl fmt::Display for Error { /// A wrapper around `reqwest::Client` which provides convenience methods for interfacing with a /// Lighthouse Beacon Node HTTP server (`http_api`). #[derive(Clone)] -pub struct BeaconNodeClient { +pub struct BeaconNodeHttpClient { client: reqwest::Client, server: Url, } -impl BeaconNodeClient { +impl BeaconNodeHttpClient { /// Returns `Err(())` if the URL is invalid. pub fn new(server: Url) -> Self { Self { diff --git a/common/eth2/src/lighthouse.rs b/common/eth2/src/lighthouse.rs index 1a93c02764c..8fbde521376 100644 --- a/common/eth2/src/lighthouse.rs +++ b/common/eth2/src/lighthouse.rs @@ -2,7 +2,7 @@ use crate::{ types::{Epoch, EthSpec, GenericResponse, ValidatorId}, - BeaconNodeClient, Error, + BeaconNodeHttpClient, Error, }; use proto_array::core::ProtoArray; use serde::{Deserialize, Serialize}; @@ -142,7 +142,7 @@ impl Health { } } -impl BeaconNodeClient { +impl BeaconNodeHttpClient { /// `GET lighthouse/health` pub async fn get_lighthouse_health(&self) -> Result, Error> { let mut path = self.server.clone(); diff --git a/testing/node_test_rig/src/lib.rs b/testing/node_test_rig/src/lib.rs index 9b5ae3d18e0..cc30695a33d 100644 --- a/testing/node_test_rig/src/lib.rs +++ b/testing/node_test_rig/src/lib.rs @@ -6,7 +6,7 @@ use beacon_node::ProductionBeaconNode; use environment::RuntimeContext; use eth2::{ reqwest::{ClientBuilder, Url}, - BeaconNodeClient, + BeaconNodeHttpClient, }; use std::path::PathBuf; use std::time::Duration; @@ -60,7 +60,7 @@ impl LocalBeaconNode { impl LocalBeaconNode { /// Returns a `RemoteBeaconNode` that can connect to `self`. Useful for testing the node as if /// it were external this process. - pub fn remote_node(&self) -> Result { + pub fn remote_node(&self) -> Result { let listen_addr = self .client .http_api_listen_addr() @@ -73,7 +73,7 @@ impl LocalBeaconNode { .timeout(HTTP_TIMEOUT) .build() .map_err(|e| format!("Unable to build HTTP client: {:?}", e))?; - Ok(BeaconNodeClient::from_components( + Ok(BeaconNodeHttpClient::from_components( beacon_node_url, beacon_node_http_client, )) diff --git a/testing/simulator/src/local_network.rs b/testing/simulator/src/local_network.rs index bd6fdb3df4a..0dd9b3424b8 100644 --- a/testing/simulator/src/local_network.rs +++ b/testing/simulator/src/local_network.rs @@ -1,6 +1,6 @@ use node_test_rig::{ environment::RuntimeContext, - eth2::{types::StateId, BeaconNodeClient}, + eth2::{types::StateId, BeaconNodeHttpClient}, ClientConfig, LocalBeaconNode, LocalValidatorClient, ValidatorConfig, ValidatorFiles, }; use parking_lot::RwLock; @@ -141,7 +141,7 @@ impl LocalNetwork { } /// For all beacon nodes in `Self`, return a HTTP client to access each nodes HTTP API. - pub fn remote_nodes(&self) -> Result, String> { + pub fn remote_nodes(&self) -> Result, String> { let beacon_nodes = self.beacon_nodes.read(); beacon_nodes diff --git a/validator_client/src/attestation_service.rs b/validator_client/src/attestation_service.rs index 1b3cd96d83d..d675ebda2e8 100644 --- a/validator_client/src/attestation_service.rs +++ b/validator_client/src/attestation_service.rs @@ -3,7 +3,7 @@ use crate::{ validator_store::ValidatorStore, }; use environment::RuntimeContext; -use eth2::BeaconNodeClient; +use eth2::BeaconNodeHttpClient; use futures::StreamExt; use slog::{crit, error, info, trace}; use slot_clock::SlotClock; @@ -22,7 +22,7 @@ pub struct AttestationServiceBuilder { duties_service: Option>, validator_store: Option>, slot_clock: Option, - beacon_node: Option, + beacon_node: Option, context: Option>, } @@ -52,7 +52,7 @@ impl AttestationServiceBuilder { self } - pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self { + pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self { self.beacon_node = Some(beacon_node); self } @@ -90,7 +90,7 @@ pub struct Inner { duties_service: DutiesService, validator_store: ValidatorStore, slot_clock: T, - beacon_node: BeaconNodeClient, + beacon_node: BeaconNodeHttpClient, context: RuntimeContext, } diff --git a/validator_client/src/block_service.rs b/validator_client/src/block_service.rs index 2f6d11ab840..bf52cacfc0b 100644 --- a/validator_client/src/block_service.rs +++ b/validator_client/src/block_service.rs @@ -1,6 +1,6 @@ use crate::validator_store::ValidatorStore; use environment::RuntimeContext; -use eth2::{types::Graffiti, BeaconNodeClient}; +use eth2::{types::Graffiti, BeaconNodeHttpClient}; use futures::channel::mpsc::Receiver; use futures::{StreamExt, TryFutureExt}; use slog::{crit, debug, error, info, trace, warn}; @@ -13,7 +13,7 @@ use types::{EthSpec, PublicKey, Slot}; pub struct BlockServiceBuilder { validator_store: Option>, slot_clock: Option>, - beacon_node: Option, + beacon_node: Option, context: Option>, graffiti: Option, } @@ -39,7 +39,7 @@ impl BlockServiceBuilder { self } - pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self { + pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self { self.beacon_node = Some(beacon_node); self } @@ -79,7 +79,7 @@ impl BlockServiceBuilder { pub struct Inner { validator_store: ValidatorStore, slot_clock: Arc, - beacon_node: BeaconNodeClient, + beacon_node: BeaconNodeHttpClient, context: RuntimeContext, graffiti: Option, } diff --git a/validator_client/src/duties_service.rs b/validator_client/src/duties_service.rs index 963036e3771..cea9451e77a 100644 --- a/validator_client/src/duties_service.rs +++ b/validator_client/src/duties_service.rs @@ -3,7 +3,7 @@ use crate::{ validator_store::ValidatorStore, }; use environment::RuntimeContext; -use eth2::BeaconNodeClient; +use eth2::BeaconNodeHttpClient; use futures::channel::mpsc::Sender; use futures::{SinkExt, StreamExt}; use parking_lot::RwLock; @@ -315,7 +315,7 @@ impl DutiesStore { pub struct DutiesServiceBuilder { validator_store: Option>, slot_clock: Option, - beacon_node: Option, + beacon_node: Option, context: Option>, allow_unsynced_beacon_node: bool, } @@ -341,7 +341,7 @@ impl DutiesServiceBuilder { self } - pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self { + pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self { self.beacon_node = Some(beacon_node); self } @@ -384,7 +384,7 @@ pub struct Inner { store: Arc, validator_store: ValidatorStore, pub(crate) slot_clock: T, - pub(crate) beacon_node: BeaconNodeClient, + pub(crate) beacon_node: BeaconNodeHttpClient, context: RuntimeContext, /// If true, the duties service will poll for duties from the beacon node even if it is not /// synced. diff --git a/validator_client/src/fork_service.rs b/validator_client/src/fork_service.rs index 0dfc4adedf0..e38a4cf3c1b 100644 --- a/validator_client/src/fork_service.rs +++ b/validator_client/src/fork_service.rs @@ -1,5 +1,5 @@ use environment::RuntimeContext; -use eth2::{types::StateId, BeaconNodeClient}; +use eth2::{types::StateId, BeaconNodeHttpClient}; use futures::StreamExt; use parking_lot::RwLock; use slog::{debug, trace}; @@ -16,7 +16,7 @@ const TIME_DELAY_FROM_SLOT: Duration = Duration::from_millis(80); pub struct ForkServiceBuilder { fork: Option, slot_clock: Option, - beacon_node: Option, + beacon_node: Option, context: Option>, } @@ -35,7 +35,7 @@ impl ForkServiceBuilder { self } - pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self { + pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self { self.beacon_node = Some(beacon_node); self } @@ -66,7 +66,7 @@ impl ForkServiceBuilder { /// Helper to minimise `Arc` usage. pub struct Inner { fork: RwLock>, - beacon_node: BeaconNodeClient, + beacon_node: BeaconNodeHttpClient, context: RuntimeContext, slot_clock: T, } diff --git a/validator_client/src/is_synced.rs b/validator_client/src/is_synced.rs index 1bee87e2ae1..f967d629c10 100644 --- a/validator_client/src/is_synced.rs +++ b/validator_client/src/is_synced.rs @@ -1,4 +1,4 @@ -use eth2::BeaconNodeClient; +use eth2::BeaconNodeHttpClient; use slog::{debug, error, warn, Logger}; use slot_clock::SlotClock; @@ -16,7 +16,7 @@ const SYNC_TOLERANCE: u64 = 4; /// The second condition means the even if the beacon node thinks that it's syncing, we'll still /// try to use it if it's close enough to the head. pub async fn is_synced( - beacon_node: &BeaconNodeClient, + beacon_node: &BeaconNodeHttpClient, slot_clock: &T, log_opt: Option<&Logger>, ) -> bool { diff --git a/validator_client/src/lib.rs b/validator_client/src/lib.rs index a319c71312d..5b51bf57b83 100644 --- a/validator_client/src/lib.rs +++ b/validator_client/src/lib.rs @@ -19,7 +19,7 @@ use block_service::{BlockService, BlockServiceBuilder}; use clap::ArgMatches; use duties_service::{DutiesService, DutiesServiceBuilder}; use environment::RuntimeContext; -use eth2::{reqwest::ClientBuilder, BeaconNodeClient, StatusCode, Url}; +use eth2::{reqwest::ClientBuilder, BeaconNodeHttpClient, StatusCode, Url}; use fork_service::{ForkService, ForkServiceBuilder}; use futures::channel::mpsc; use initialized_validators::InitializedValidators; @@ -114,7 +114,7 @@ impl ProductionValidatorClient { .build() .map_err(|e| format!("Unable to build HTTP client: {:?}", e))?; let beacon_node = - BeaconNodeClient::from_components(beacon_node_url, beacon_node_http_client); + BeaconNodeHttpClient::from_components(beacon_node_url, beacon_node_http_client); // Perform some potentially long-running initialization tasks. let (yaml_config, genesis_time, genesis_validators_root) = tokio::select! { @@ -235,7 +235,7 @@ impl ProductionValidatorClient { } async fn init_from_beacon_node( - beacon_node: &BeaconNodeClient, + beacon_node: &BeaconNodeHttpClient, context: &RuntimeContext, ) -> Result<(YamlConfig, u64, Hash256), String> { // Wait for the beacon node to come online. @@ -305,7 +305,7 @@ async fn init_from_beacon_node( /// Request the version from the node, looping back and trying again on failure. Exit once the node /// has been contacted. -async fn wait_for_node(beacon_node: &BeaconNodeClient, log: &Logger) -> Result<(), String> { +async fn wait_for_node(beacon_node: &BeaconNodeHttpClient, log: &Logger) -> Result<(), String> { // Try to get the version string from the node, looping until success is returned. loop { let log = log.clone(); diff --git a/validator_client/src/validator_duty.rs b/validator_client/src/validator_duty.rs index e83b6a84d09..5119188d581 100644 --- a/validator_client/src/validator_duty.rs +++ b/validator_client/src/validator_duty.rs @@ -1,6 +1,6 @@ use eth2::{ types::{BeaconCommitteeSubscription, StateId, ValidatorId}, - BeaconNodeClient, + BeaconNodeHttpClient, }; use serde::{Deserialize, Serialize}; use types::{CommitteeIndex, Epoch, PublicKey, PublicKeyBytes, Slot}; @@ -50,7 +50,7 @@ impl ValidatorDuty { /// /// Will only request proposer duties if `current_epoch == request_epoch`. pub async fn download( - beacon_node: &BeaconNodeClient, + beacon_node: &BeaconNodeHttpClient, current_epoch: Epoch, request_epoch: Epoch, pubkey: PublicKey,