Skip to content

Commit

Permalink
Added workaround to tonic::code inconsistencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
adizere committed May 4, 2022
1 parent 64a4531 commit 7fd032b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion relayer/src/chain/cosmos/estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async fn estimate_gas_with_tx(
}

// If there is a chance that the tx will be accepted once actually submitted, we fall
// back on the max gas and will attempt to send it anyway.
// back on the default gas and will attempt to send it anyway.
// See `can_recover_from_simulation_failure` for more info.
Err(e) if can_recover_from_simulation_failure(&e) => {
warn!(
Expand Down
11 changes: 6 additions & 5 deletions relayer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,20 @@ impl Error {

impl GrpcStatusSubdetail {
/// Check whether this gRPC error matches
/// - status: InvalidArgument
/// - message: verification failed: ... failed packet acknowledgement verification for client: client state height < proof height ...
pub fn is_client_state_height_too_low(&self) -> bool {
if self.status.code() != tonic::Code::InvalidArgument {
return false;
}
// Gaia v6.0.1 (SDK 0.44.5) returns code`InvalidArgument`, whereas gaia v6.0.4
// (SDK 0.44.6, and potentially others) returns code `Unknown`.
// Workaround by matching strictly on the status message.
// if self.status.code() != tonic::Code::InvalidArgument
// return false;
// }

let msg = self.status.message();
msg.contains("verification failed") && msg.contains("client state height < proof height")
}

/// Check whether this gRPC error matches
/// - status: InvalidArgument
/// - message: "account sequence mismatch, expected 166791, got 166793: incorrect account sequence: invalid request"
///
/// # Note:
Expand Down

0 comments on commit 7fd032b

Please sign in to comment.