Standard Liveness Endpoint (#4853)

* Changes to use required Endpoint

* Format

* fixed doppleganger service

* minor fix

* efficiency changes

* fixed tests

* remove commented line

---------

Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Gua00va 2023-11-30 12:11:22 +05:30 committed by GitHub
parent 547ed1de63
commit 44aaf13ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 12 deletions

View File

@ -3429,7 +3429,7 @@ impl ApiTester {
let result = self let result = self
.client .client
.post_validator_liveness_epoch(epoch, indices.clone()) .post_validator_liveness_epoch(epoch, &indices)
.await .await
.unwrap() .unwrap()
.data; .data;
@ -3444,7 +3444,7 @@ impl ApiTester {
let result = self let result = self
.client .client
.post_validator_liveness_epoch(epoch, indices.clone()) .post_validator_liveness_epoch(epoch, &indices)
.await .await
.unwrap() .unwrap()
.data; .data;

View File

@ -2145,7 +2145,7 @@ impl BeaconNodeHttpClient {
pub async fn post_validator_liveness_epoch( pub async fn post_validator_liveness_epoch(
&self, &self,
epoch: Epoch, epoch: Epoch,
indices: Vec<u64>, indices: &Vec<u64>,
) -> Result<GenericResponse<Vec<StandardLivenessResponseData>>, Error> { ) -> Result<GenericResponse<Vec<StandardLivenessResponseData>>, Error> {
let mut path = self.eth_path(V1)?; let mut path = self.eth_path(V1)?;
@ -2155,7 +2155,7 @@ impl BeaconNodeHttpClient {
.push("liveness") .push("liveness")
.push(&epoch.to_string()); .push(&epoch.to_string());
self.post_with_timeout_and_response(path, &indices, self.timeouts.liveness) self.post_with_timeout_and_response(path, indices, self.timeouts.liveness)
.await .await
} }

View File

@ -163,8 +163,6 @@ async fn beacon_node_liveness<'a, T: 'static + SlotClock, E: EthSpec>(
current_epoch: Epoch, current_epoch: Epoch,
validator_indices: Vec<u64>, validator_indices: Vec<u64>,
) -> LivenessResponses { ) -> LivenessResponses {
let validator_indices = validator_indices.as_slice();
let previous_epoch = current_epoch.saturating_sub(1_u64); let previous_epoch = current_epoch.saturating_sub(1_u64);
let previous_epoch_responses = if previous_epoch == current_epoch { let previous_epoch_responses = if previous_epoch == current_epoch {
@ -180,12 +178,22 @@ async fn beacon_node_liveness<'a, T: 'static + SlotClock, E: EthSpec>(
.first_success( .first_success(
RequireSynced::Yes, RequireSynced::Yes,
OfflineOnFailure::Yes, OfflineOnFailure::Yes,
|beacon_node| async move { |beacon_node| async {
beacon_node beacon_node
.post_lighthouse_liveness(validator_indices, previous_epoch) .post_validator_liveness_epoch(previous_epoch, &validator_indices)
.await .await
.map_err(|e| format!("Failed query for validator liveness: {:?}", e)) .map_err(|e| format!("Failed query for validator liveness: {:?}", e))
.map(|result| result.data) .map(|result| {
result
.data
.into_iter()
.map(|response| LivenessResponseData {
index: response.index,
epoch: previous_epoch,
is_live: response.is_live,
})
.collect()
})
}, },
) )
.await .await
@ -207,12 +215,22 @@ async fn beacon_node_liveness<'a, T: 'static + SlotClock, E: EthSpec>(
.first_success( .first_success(
RequireSynced::Yes, RequireSynced::Yes,
OfflineOnFailure::Yes, OfflineOnFailure::Yes,
|beacon_node| async move { |beacon_node| async {
beacon_node beacon_node
.post_lighthouse_liveness(validator_indices, current_epoch) .post_validator_liveness_epoch(current_epoch, &validator_indices)
.await .await
.map_err(|e| format!("Failed query for validator liveness: {:?}", e)) .map_err(|e| format!("Failed query for validator liveness: {:?}", e))
.map(|result| result.data) .map(|result| {
result
.data
.into_iter()
.map(|response| LivenessResponseData {
index: response.index,
epoch: current_epoch,
is_live: response.is_live,
})
.collect()
})
}, },
) )
.await .await