Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard Liveness Endpoint #4853

Merged
merged 8 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions beacon_node/http_api/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3429,7 +3429,7 @@ impl ApiTester {

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

let result = self
.client
.post_validator_liveness_epoch(epoch, indices.clone())
.post_validator_liveness_epoch(epoch, &indices)
.await
.unwrap()
.data;
Expand Down
4 changes: 2 additions & 2 deletions common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ impl BeaconNodeHttpClient {
pub async fn post_validator_liveness_epoch(
&self,
epoch: Epoch,
indices: Vec<u64>,
indices: &Vec<u64>,
) -> Result<GenericResponse<Vec<StandardLivenessResponseData>>, Error> {
let mut path = self.eth_path(V1)?;

Expand All @@ -2155,7 +2155,7 @@ impl BeaconNodeHttpClient {
.push("liveness")
.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
}

Expand Down
34 changes: 26 additions & 8 deletions validator_client/src/doppelganger_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ async fn beacon_node_liveness<'a, T: 'static + SlotClock, E: EthSpec>(
current_epoch: Epoch,
validator_indices: Vec<u64>,
) -> LivenessResponses {
let validator_indices = validator_indices.as_slice();

let previous_epoch = current_epoch.saturating_sub(1_u64);

let previous_epoch_responses = if previous_epoch == current_epoch {
Expand All @@ -180,12 +178,22 @@ async fn beacon_node_liveness<'a, T: 'static + SlotClock, E: EthSpec>(
.first_success(
RequireSynced::Yes,
OfflineOnFailure::Yes,
|beacon_node| async move {
|beacon_node| async {
beacon_node
.post_lighthouse_liveness(validator_indices, previous_epoch)
.post_validator_liveness_epoch(previous_epoch, &validator_indices)
.await
.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
Expand All @@ -207,12 +215,22 @@ async fn beacon_node_liveness<'a, T: 'static + SlotClock, E: EthSpec>(
.first_success(
RequireSynced::Yes,
OfflineOnFailure::Yes,
|beacon_node| async move {
|beacon_node| async {
beacon_node
.post_lighthouse_liveness(validator_indices, current_epoch)
.post_validator_liveness_epoch(current_epoch, &validator_indices)
.await
.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
Expand Down