Skip to content

Commit

Permalink
Relayer: Ignore confirmations with invalid signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Nov 1, 2023
1 parent c22987f commit 4b98c90
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions orchestrator/cosmos_gravity/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cmp::Ordering;

use clarity::Signature;
use deep_space::address::Address;
use ethers::types::Address as EthAddress;
use gravity_proto::gravity::query_client::QueryClient as GravityQueryClient;
Expand Down Expand Up @@ -66,6 +67,13 @@ pub async fn get_all_valset_confirms(
let confirms = request.into_inner().signatures;
let mut parsed_confirms = Vec::new();
for item in confirms {
if let Err(e) = Signature::from_bytes(&item.signature)?.error_check() {
warn!("ignoring valset confirmation with invalid signature from {}", item.ethereum_signer);
debug!("reason given for invalid signature: {e:?}");

continue;
}

parsed_confirms.push(ValsetConfirmResponse::from_proto(item)?)
}
Ok(parsed_confirms)
Expand Down Expand Up @@ -132,6 +140,13 @@ pub async fn get_transaction_batch_signatures(
let batch_confirms = request.into_inner().signatures;
let mut out = Vec::new();
for confirm in batch_confirms {
if let Err(e) = Signature::from_bytes(&confirm.signature)?.error_check() {
warn!("ignoring batch confirmation with invalid signature from {}", confirm.ethereum_signer);
debug!("reason given for invalid signature: {e:?}");

continue;
}

out.push(BatchConfirmResponse::from_proto(confirm)?)
}
Ok(out)
Expand Down Expand Up @@ -187,6 +202,13 @@ pub async fn get_logic_call_signatures(
let call_confirms = request.into_inner().signatures;
let mut out = Vec::new();
for confirm in call_confirms {
if let Err(e) = Signature::from_bytes(&confirm.signature)?.error_check() {
warn!("ignoring logic call confirmation with invalid signature from {}", confirm.ethereum_signer);
debug!("reason given for invalid signature: {e:?}");

continue;
}

out.push(LogicCallConfirmResponse::from_proto(confirm)?)
}
Ok(out)
Expand Down

0 comments on commit 4b98c90

Please sign in to comment.