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.
This commit is contained in:
Jimmy Chen 2023-09-22 02:33:11 +00:00
parent c5588eb66e
commit c4e907de9f
3 changed files with 5 additions and 4 deletions

View File

@ -666,7 +666,7 @@ impl ValidatorClientHttpClient {
&self, &self,
pubkey: &PublicKeyBytes, pubkey: &PublicKeyBytes,
epoch: Option<Epoch>, epoch: Option<Epoch>,
) -> Result<SignedVoluntaryExit, Error> { ) -> Result<GenericResponse<SignedVoluntaryExit>, Error> {
let mut path = self.server.full.clone(); let mut path = self.server.full.clone();
path.path_segments_mut() path.path_segments_mut()

View File

@ -1,5 +1,6 @@
use crate::validator_store::ValidatorStore; use crate::validator_store::ValidatorStore;
use bls::{PublicKey, PublicKeyBytes}; use bls::{PublicKey, PublicKeyBytes};
use eth2::types::GenericResponse;
use slog::{info, Logger}; use slog::{info, Logger};
use slot_clock::SlotClock; use slot_clock::SlotClock;
use std::sync::Arc; use std::sync::Arc;
@ -11,7 +12,7 @@ pub async fn create_signed_voluntary_exit<T: 'static + SlotClock + Clone, E: Eth
validator_store: Arc<ValidatorStore<T, E>>, validator_store: Arc<ValidatorStore<T, E>>,
slot_clock: T, slot_clock: T,
log: Logger, log: Logger,
) -> Result<SignedVoluntaryExit, warp::Rejection> { ) -> Result<GenericResponse<SignedVoluntaryExit>, warp::Rejection> {
let epoch = match maybe_epoch { let epoch = match maybe_epoch {
Some(epoch) => epoch, Some(epoch) => epoch,
None => get_current_epoch::<T, E>(slot_clock).ok_or_else(|| { None => get_current_epoch::<T, E>(slot_clock).ok_or_else(|| {
@ -60,7 +61,7 @@ pub async fn create_signed_voluntary_exit<T: 'static + SlotClock + Clone, E: Eth
)) ))
})?; })?;
Ok(signed_voluntary_exit) Ok(GenericResponse::from(signed_voluntary_exit))
} }
/// Calculates the current epoch from the genesis time and current time. /// Calculates the current epoch from the genesis time and current time.

View File

@ -502,7 +502,7 @@ impl ApiTester {
.await; .await;
assert!(resp.is_ok()); assert!(resp.is_ok());
assert_eq!(resp.unwrap().message.epoch, expected_exit_epoch); assert_eq!(resp.unwrap().data.message.epoch, expected_exit_epoch);
self self
} }