Skip to content

Commit

Permalink
Add more detail for 404s
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Mar 30, 2023
1 parent 709131e commit b1a1cbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion validator_client/src/http_api/create_signed_voluntary_exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ pub async fn create_signed_voluntary_exit<T: 'static + SlotClock + Clone, E: Eth
};

let pubkey_bytes = PublicKeyBytes::from(pubkey);
if !validator_store.has_validator(&pubkey_bytes) {
return Err(warp_utils::reject::custom_not_found(format!(
"{} is disabled or not mangaged by this validator client",
pubkey_bytes.as_hex_string()
)));
}

let validator_index = validator_store
.validator_index(&pubkey_bytes)
.ok_or_else(|| {
warp_utils::reject::custom_not_found(format!(
"Unable to find validator with public key: {}",
"The validator index for {} is not known. The validator client \
may still be initializing or the validator has not yet had a \
deposit processed.",
pubkey_bytes.as_hex_string()
))
})?;
Expand Down
8 changes: 8 additions & 0 deletions validator_client/src/validator_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
self.validators.clone()
}

/// Indicates if the `voting_public_key` exists in self and is enabled.
pub fn has_validator(&self, voting_public_key: &PublicKeyBytes) -> bool {
self.validators
.read()
.validator(voting_public_key)
.is_some()
}

/// Insert a new validator to `self`, where the validator is represented by an EIP-2335
/// keystore on the filesystem.
#[allow(clippy::too_many_arguments)]
Expand Down

0 comments on commit b1a1cbf

Please sign in to comment.