Skip to content

Commit

Permalink
fix: add explicit root tls
Browse files Browse the repository at this point in the history
  • Loading branch information
allthatjazzleo committed Aug 24, 2024
1 parent 0d3b57c commit bca7eb7
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 127 deletions.
3 changes: 2 additions & 1 deletion crates/chain-registry/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use tendermint_rpc::HttpClientUrl;
use tracing::{debug, info};

use ibc_proto::cosmos::bank::v1beta1::query_client::QueryClient;
use ibc_relayer::util::create_grpc_client;
use ibc_relayer::HERMES_VERSION;
use tendermint_rpc::{Client, Url};

Expand Down Expand Up @@ -159,7 +160,7 @@ impl QueryContext for GrpcHealthCheckQuerier {

info!("Querying gRPC server at {tendermint_url}");

QueryClient::connect(uri)
create_grpc_client(uri, QueryClient::new)
.await
.map_err(|_| RegistryError::unable_to_connect_with_grpc())?;

Expand Down
154 changes: 60 additions & 94 deletions crates/relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ use crate::light_client::tendermint::LightClient as TmLightClient;
use crate::light_client::{LightClient, Verified};
use crate::misbehaviour::MisbehaviourEvidence;
use crate::util::compat_mode::compat_mode_from_version;
use crate::util::create_grpc_client;
use crate::util::pretty::PrettySlice;
use crate::util::pretty::{
PrettyIdentifiedChannel, PrettyIdentifiedClientState, PrettyIdentifiedConnection,
Expand Down Expand Up @@ -374,13 +375,10 @@ impl CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_ccv_consumer_chain_params");

let mut client = self
.block_on(
ibc_proto::interchain_security::ccv::consumer::v1::query_client::QueryClient::connect(
self.grpc_addr.clone()
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::interchain_security::ccv::consumer::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -411,13 +409,10 @@ impl CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_staking_params");

let mut client = self
.block_on(
ibc_proto::cosmos::staking::v1beta1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::cosmos::staking::v1beta1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1301,13 +1296,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_clients");

let mut client = self
.block_on(
ibc_proto::ibc::core::client::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::client::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1492,13 +1484,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_client_connections");

let mut client = self
.block_on(
ibc_proto::ibc::core::connection::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::connection::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1538,13 +1527,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_connections");

let mut client = self
.block_on(
ibc_proto::ibc::core::connection::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::connection::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1596,10 +1582,11 @@ impl ChainEndpoint for CosmosSdkChain {
use ibc_proto::ibc::core::connection::v1 as connection;
use tonic::IntoRequest;

let mut client =
connection::query_client::QueryClient::connect(chain.grpc_addr.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(
chain.grpc_addr.clone(),
connection::query_client::QueryClient::new,
)
.await?;

client = client.max_decoding_message_size(
chain.config().max_grpc_decoding_size.get_bytes() as usize,
Expand Down Expand Up @@ -1677,13 +1664,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_connection_channels");

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1749,13 +1733,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_channels");

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1873,13 +1854,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_channel_client_state");

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -1944,17 +1922,15 @@ impl ChainEndpoint for CosmosSdkChain {
crate::telemetry!(query, self.id(), "query_packet_commitments");

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))
.map(|client| {
client.max_decoding_message_size(
self.config().max_grpc_decoding_size.get_bytes() as usize
)
})
.map_err(Error::grpc_transport)?;
})?;

if request.pagination.is_enabled() {
let mut results = Vec::new();
Expand Down Expand Up @@ -2106,13 +2082,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_unreceived_packets");

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -2182,17 +2155,15 @@ impl ChainEndpoint for CosmosSdkChain {
}

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))
.map(|client| {
client.max_decoding_message_size(
self.config().max_grpc_decoding_size.get_bytes() as usize
)
})
.map_err(Error::grpc_transport)?;
})?;

if request.pagination.is_enabled() {
let mut results = Vec::new();
Expand Down Expand Up @@ -2302,13 +2273,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_unreceived_acknowledgements");

let mut client = self
.block_on(
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::ibc::core::channel::v1::query_client::QueryClient::new,
))?;

client = client
.max_decoding_message_size(self.config().max_grpc_decoding_size.get_bytes() as usize);
Expand Down Expand Up @@ -2643,12 +2611,10 @@ impl ChainEndpoint for CosmosSdkChain {
);
crate::telemetry!(query, self.id(), "query_consumer_chains");

let mut client = self.block_on(
ibc_proto::interchain_security::ccv::provider::v1::query_client::QueryClient::connect(
self.grpc_addr.clone(),
),
)
.map_err(Error::grpc_transport)?;
let mut client = self.block_on(create_grpc_client(
self.grpc_addr.clone(),
ibc_proto::interchain_security::ccv::provider::v1::query_client::QueryClient::new,
))?;

let request = tonic::Request::new(
ibc_proto::interchain_security::ccv::provider::v1::QueryConsumerChainsRequest {},
Expand Down
5 changes: 2 additions & 3 deletions crates/relayer/src/chain/cosmos/query/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use tracing::info;
use crate::chain::cosmos::types::account::Account;
use crate::config::default::max_grpc_decoding_size;
use crate::error::Error;
use crate::util::create_grpc_client;

/// Get a `&mut Account` from an `&mut Option<Account>` if it is `Some(Account)`.
/// Otherwise query for the account information, update the `Option` to `Some`,
Expand Down Expand Up @@ -54,9 +55,7 @@ pub async fn query_account(
grpc_address: &Uri,
account_address: &str,
) -> Result<BaseAccount, Error> {
let mut client = QueryClient::connect(grpc_address.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
9 changes: 3 additions & 6 deletions crates/relayer/src/chain/cosmos/query/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ use ibc_proto::cosmos::bank::v1beta1::{
use crate::account::Balance;
use crate::config::default::max_grpc_decoding_size;
use crate::error::Error;
use crate::util::create_grpc_client;

/// Uses the GRPC client to retrieve the account balance for a specific denom
pub async fn query_balance(
grpc_address: &Uri,
account_address: &str,
denom: &str,
) -> Result<Balance, Error> {
let mut client = QueryClient::connect(grpc_address.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down Expand Up @@ -47,9 +46,7 @@ pub async fn query_all_balances(
grpc_address: &Uri,
account_address: &str,
) -> Result<Vec<Balance>, Error> {
let mut client = QueryClient::connect(grpc_address.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
5 changes: 2 additions & 3 deletions crates/relayer/src/chain/cosmos/query/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ use ibc_proto::ibc::core::connection::v1::QueryConnectionParamsRequest;

use crate::config::default::max_grpc_decoding_size;
use crate::error::Error;
use crate::util::create_grpc_client;

/// Uses the GRPC client to retrieve the connection params
pub async fn query_connection_params(grpc_address: &Uri) -> Result<Params, Error> {
let mut client = QueryClient::connect(grpc_address.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(grpc_address.clone(), QueryClient::new).await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
19 changes: 11 additions & 8 deletions crates/relayer/src/chain/cosmos/query/consensus_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::chain::requests::{QueryConsensusStateHeightsRequest, QueryConsensusSt
use crate::config::default::max_grpc_decoding_size;
use crate::consensus_state::AnyConsensusStateWithHeight;
use crate::error::Error;
use crate::util::create_grpc_client;
use crate::util::pretty::{PrettyConsensusStateWithHeight, PrettyHeight};

/// Performs a `QueryConsensusStateHeightsRequest` gRPC query to fetch all the consensus state
Expand Down Expand Up @@ -36,10 +37,11 @@ pub async fn query_consensus_state_heights(
.contains("unknown method ConsensusStateHeights")
}

let mut client =
ibc_proto::ibc::core::client::v1::query_client::QueryClient::connect(grpc_addr.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(
grpc_addr.clone(),
ibc_proto::ibc::core::client::v1::query_client::QueryClient::new,
)
.await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down Expand Up @@ -105,10 +107,11 @@ pub async fn query_consensus_states(
}
);

let mut client =
ibc_proto::ibc::core::client::v1::query_client::QueryClient::connect(grpc_addr.clone())
.await
.map_err(Error::grpc_transport)?;
let mut client = create_grpc_client(
grpc_addr.clone(),
ibc_proto::ibc::core::client::v1::query_client::QueryClient::new,
)
.await?;

client = client.max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize);

Expand Down
Loading

0 comments on commit bca7eb7

Please sign in to comment.