Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fastx client] Better Error Handling & Messaging - Part 1 #256

Merged
merged 10 commits into from
Jan 26, 2022
Prev Previous commit
Next Next commit
address PR comments
  • Loading branch information
patrickkuo committed Jan 26, 2022
commit 9ca309f4c80d10116dbcabc5f7a1e9bbd0e1cb8a
5 changes: 4 additions & 1 deletion fastpay_core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ impl AuthorityState {
let object = object.ok_or(FastPayError::ObjectNotFound { object_id })?;
fp_ensure!(
object.digest() == object_digest,
FastPayError::InvalidObjectDigest { object_id }
FastPayError::InvalidObjectDigest {
object_id,
expected_digest: object_digest
}
);

// Check that the seq number is the same
Expand Down
3 changes: 0 additions & 3 deletions fastpay_core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ where
F: Fn(AuthorityName, &'a mut A) -> AsyncResult<'a, V, FastPayError> + Clone,
{
let committee = &self.committee;
let number_of_authorities = self.authority_clients.len();
let authority_clients = &mut self.authority_clients;
let mut responses: futures::stream::FuturesUnordered<_> = authority_clients
.iter_mut()
Expand Down Expand Up @@ -414,15 +413,13 @@ where
// At least one honest node returned this error.
// No quorum can be reached, so return early.
return Err(FastPayError::QuorumNotReachedError {
num_of_authorities: number_of_authorities,
errors: error_scores.into_keys().collect(),
});
}
}
}
}
Err(FastPayError::QuorumNotReachedError {
num_of_authorities: number_of_authorities,
errors: error_scores.into_keys().collect(),
})
}
Expand Down
20 changes: 10 additions & 10 deletions fastx_types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ pub enum FastPayError {
#[error("Signatures in a certificate must form a quorum")]
CertificateRequiresQuorum,
#[error(
"The given sequence ({received_sequence:?}) number must match the next expected sequence ({expected_sequence:?}) number of the account"
"The given sequence number must match the next expected sequence ({expected_sequence:?}) number of the object ({object_id:?})"
)]
UnexpectedSequenceNumber {
object_id: ObjectID,
expected_sequence: SequenceNumber,
received_sequence: SequenceNumber,
},
#[error("Conflicting order already received: {pending_confirmation:?}")]
ConflictingOrder { pending_confirmation: Order },
Expand Down Expand Up @@ -95,8 +94,13 @@ pub enum FastPayError {
InvalidAuthenticator,
#[error("Invalid transaction digest.")]
InvalidTransactionDigest,
#[error("Invalid Object digest for object {object_id:?}.")]
InvalidObjectDigest { object_id: ObjectID },
#[error(
"Invalid Object digest for object {object_id:?}. Expected digest : {expected_digest:?}."
)]
InvalidObjectDigest {
object_id: ObjectID,
expected_digest: ObjectDigest,
},
#[error("Cannot deserialize.")]
InvalidDecoding,
#[error("Unexpected message.")]
Expand Down Expand Up @@ -161,14 +165,10 @@ pub enum FastPayError {
StorageError(#[from] typed_store::rocks::TypedStoreError),

#[error(
"Failed to achieve quorum between {} authorities, cause by : {:#?}",
num_of_authorities,
"Failed to achieve quorum between authorities, cause by : {:#?}",
errors.iter().map(| e | e.to_string()).collect::<Vec<String>>()
)]
QuorumNotReachedError {
num_of_authorities: usize,
errors: Vec<FastPayError>,
},
QuorumNotReachedError { errors: Vec<FastPayError> },
// Client side error
#[error("Client state has a different pending transfer.")]
ConcurrentTransferError,
Expand Down