Skip to content

Commit

Permalink
Added error list to aggregator map reduce (MystenLabs#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxade authored Feb 10, 2022
1 parent 092dd5a commit 488a67e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
29 changes: 24 additions & 5 deletions fastpay_core/src/authority_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ where
signatures: Vec<(AuthorityName, Signature)>,
// A certificate if we manage to make or find one
certificate: Option<CertifiedOrder>,
// The list of errors gathered at any point
errors: Vec<FastPayError>,
// Tally of stake for good vs bad responses.
good_stake: usize,
bad_stake: usize,
Expand All @@ -704,6 +706,7 @@ where
let state = ProcessOrderState {
signatures: vec![],
certificate: None,
errors: vec![],
good_stake: 0,
bad_stake: 0,
};
Expand Down Expand Up @@ -744,16 +747,32 @@ where
});
}
}

// In all other cases we will not be able to use this response
// If we get back an error, then we aggregate and check
// if we have too many errors
// In this case we will not be able to use this response
// to make a certificate. If this happens for more than f
// authorities we just stop, as there is no hope to finish.
_ => {
Err(err) => {
// We have an error here.
// Append to the list off errors
state.errors.push(err);
state.bad_stake += weight; // This is the bad stake counter
if state.bad_stake > validity {
// Too many errors
return Err(FastPayError::QuorumNotReached {
errors: state.errors,
});
}
}
// In case we don't get an error but also don't get a valid value
_ => {
state.errors.push(FastPayError::ErrorWhileProcessingOrder);
state.bad_stake += weight; // This is the bad stake counter
if state.bad_stake > validity {
// Too many errors
return Err(FastPayError::ErrorWhileProcessingTransferOrder);
return Err(FastPayError::QuorumNotReached {
errors: state.errors,
});
}
}
};
Expand All @@ -774,7 +793,7 @@ where
// If we have some certificate return it, or return an error.
state
.certificate
.ok_or(FastPayError::ErrorWhileProcessingTransferOrder)
.ok_or(FastPayError::ErrorWhileProcessingOrder)
}

/// Process a certificate assuming that 2f+1 authorites already are up to date.
Expand Down
4 changes: 2 additions & 2 deletions fastx_types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pub enum FastPayError {
},
#[error("Conflicting order already received: {pending_order:?}")]
ConflictingOrder { pending_order: Order },
#[error("Transfer order was processed but no signature was produced by authority")]
ErrorWhileProcessingTransferOrder,
#[error("Order was processed but no signature was produced by authority")]
ErrorWhileProcessingOrder,
#[error("Transaction order processing failed: {err}")]
ErrorWhileProcessingTransactionOrder { err: String },
#[error("Confirmation order processing failed: {err}")]
Expand Down

0 comments on commit 488a67e

Please sign in to comment.