From 8b09d2279a4d66bd1325ebd36527a313d2e4505d Mon Sep 17 00:00:00 2001 From: peg Date: Tue, 1 Oct 2024 11:33:09 +0200 Subject: [PATCH] Check that we have a non-signing validator before selecting one --- crates/client/src/client.rs | 3 +++ crates/client/src/errors.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 89c49514b..bf2a36ebb 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -116,6 +116,9 @@ pub async fn sign( let message_hash = Hasher::keccak(&message); let validators_info = get_validators_not_signer_for_relay(api, rpc).await?; + if validators_info.is_empty() { + return Err(ClientError::NoNonSigningValidators); + } tracing::debug!("Validators info {:?}", validators_info); let block_number = rpc.chain_get_header(None).await?.ok_or(ClientError::BlockNumber)?.number; diff --git a/crates/client/src/errors.rs b/crates/client/src/errors.rs index 163059b11..24705ae55 100644 --- a/crates/client/src/errors.rs +++ b/crates/client/src/errors.rs @@ -96,8 +96,6 @@ pub enum ClientError { TryFromSlice(#[from] std::array::TryFromSliceError), #[error("User is not registered on-chain")] NotRegistered, - #[error("No synced validators")] - NoSyncedValidators, #[error("Cannot confirm program was created")] CannotConfirmProgramCreated, #[error("Cannot confirm program was removed")] @@ -108,4 +106,6 @@ pub enum ClientError { CannotQuerySynced, #[error("Verifying key has incorrect length")] BadVerifyingKeyLength, + #[error("There are no validators which can act as a relay node for signature requests")] + NoNonSigningValidators, }