diff --git a/tests/beacon_chain_sim/src/main.rs b/tests/beacon_chain_sim/src/main.rs index f7dfddedc3..0860416fa1 100644 --- a/tests/beacon_chain_sim/src/main.rs +++ b/tests/beacon_chain_sim/src/main.rs @@ -108,13 +108,12 @@ fn new_validator_client( ) -> LocalValidatorClient { let mut config = base_config; - let (grpc_endpoint, grpc_port) = beacon_node + let socket_addr = beacon_node .client - .grpc_listen_addr() - .expect("Must have gRPC started"); + .http_listen_addr() + .expect("Must have http started"); - config.server = grpc_endpoint; - config.server_grpc_port = grpc_port; + config.http_server = format!("http://{}:{}", socket_addr.ip(), socket_addr.port()); LocalValidatorClient::production_with_insecure_keypairs(context, config, keypair_indices) } diff --git a/validator_client/src/duties_service.rs b/validator_client/src/duties_service.rs index 3d63b80f47..1ccfe8100a 100644 --- a/validator_client/src/duties_service.rs +++ b/validator_client/src/duties_service.rs @@ -21,6 +21,7 @@ const PRUNE_DEPTH: u64 = 4; type BaseHashMap = HashMap>; +/// The outcome of inserting some `ValidatorDuty` into the `DutiesStore`. enum InsertOutcome { /// The duties were previously unknown and have been stored. New, @@ -92,8 +93,6 @@ impl DutiesStore { "Store is exclusively locked and this path is guarded to ensure the key exists.", ); - // TODO: validate that the slots in the duties are all in the given epoch. - if validator_map.contains_key(&epoch) { let known_duties = validator_map.get_mut(&epoch).expect( "Validator map is exclusively mutable and this path is guarded to ensure the key exists.", @@ -190,6 +189,7 @@ impl DutiesServiceBuilder { } } +/// Helper to minimise `Arc` usage. pub struct Inner { store: Arc, validator_store: ValidatorStore, @@ -198,6 +198,10 @@ pub struct Inner { context: RuntimeContext, } +/// Maintains a store of the duties for all voting validators in the `validator_store`. +/// +/// Polls the beacon node at the start of each epoch, collecting duties for the current and next +/// epoch. pub struct DutiesService { inner: Arc>, } @@ -234,6 +238,7 @@ impl DutiesService { self.store.attesters(slot, E::slots_per_epoch()) } + /// Start the service that periodically polls the beacon node for validator duties. pub fn start_update_service(&self, spec: &ChainSpec) -> Result { let log = self.context.log.clone(); @@ -279,6 +284,7 @@ impl DutiesService { Ok(exit_signal) } + /// Attempt to download the duties of all managed validators for this epoch and the next. fn do_update(&self) -> impl Future { let service_1 = self.clone(); let service_2 = self.clone(); @@ -334,6 +340,7 @@ impl DutiesService { .map(|_| ()) } + /// Attempt to download the duties of all managed validators for the given `epoch`. fn update_epoch(self, epoch: Epoch) -> impl Future { let service_1 = self.clone(); let service_2 = self.clone();