From c4e907de9f531c8bd18d9547515c1918a5e2b0e1 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Fri, 22 Sep 2023 02:33:11 +0000 Subject: [PATCH] Update the voluntary exit endpoint to comply with the key manager specification (#4679) ## Issue Addressed #4635 ## Proposed Changes Wrap the `SignedVoluntaryExit` object in a `GenericResponse` container, adding an additional `data` layer, to ensure compliance with the key manager API specification. The new response would look like this: ```json {"data":{"message":{"epoch":"196868","validator_index":"505597"},"signature":"0xhexsig"}} ``` This is a backward incompatible change and will affect Siren as well. --- common/eth2/src/lighthouse_vc/http_client.rs | 2 +- .../src/http_api/create_signed_voluntary_exit.rs | 5 +++-- validator_client/src/http_api/tests.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/eth2/src/lighthouse_vc/http_client.rs b/common/eth2/src/lighthouse_vc/http_client.rs index 7bf4cf5b19a..b2d53c5e08d 100644 --- a/common/eth2/src/lighthouse_vc/http_client.rs +++ b/common/eth2/src/lighthouse_vc/http_client.rs @@ -666,7 +666,7 @@ impl ValidatorClientHttpClient { &self, pubkey: &PublicKeyBytes, epoch: Option, - ) -> Result { + ) -> Result, Error> { let mut path = self.server.full.clone(); path.path_segments_mut() diff --git a/validator_client/src/http_api/create_signed_voluntary_exit.rs b/validator_client/src/http_api/create_signed_voluntary_exit.rs index b777d158064..a9586da57ec 100644 --- a/validator_client/src/http_api/create_signed_voluntary_exit.rs +++ b/validator_client/src/http_api/create_signed_voluntary_exit.rs @@ -1,5 +1,6 @@ use crate::validator_store::ValidatorStore; use bls::{PublicKey, PublicKeyBytes}; +use eth2::types::GenericResponse; use slog::{info, Logger}; use slot_clock::SlotClock; use std::sync::Arc; @@ -11,7 +12,7 @@ pub async fn create_signed_voluntary_exit>, slot_clock: T, log: Logger, -) -> Result { +) -> Result, warp::Rejection> { let epoch = match maybe_epoch { Some(epoch) => epoch, None => get_current_epoch::(slot_clock).ok_or_else(|| { @@ -60,7 +61,7 @@ pub async fn create_signed_voluntary_exit