Skip to content

Commit

Permalink
Check that we have a non-signing validator before selecting one
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Oct 1, 2024
1 parent 61c77d4 commit 8b09d22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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,
}

0 comments on commit 8b09d22

Please sign in to comment.