From e9a51431632b3b9a60a70418fbc57593276024c4 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Thu, 23 May 2024 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?app:=20=F0=9F=91=90=20`rpc::router(..)`=20accep?= =?UTF-8?q?ts=20a=20`TendermintProxyService`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### 💭 describe your changes instead of accepting a `url::Url` and constructing specifically the "real" `TendermintProxy`, tweak the signature of the router function so that it accepts a `T: TendermintProxyService`. in the future, this will allow mock consensus test cases to run an rpc endpoint for the view server, without running a Tendermint/CometBFT process. #### 🔖 issue ticket number and link see #3913. #### ✅ checklist before requesting a review - [x] if this code contains consensus-breaking changes, i have added the "consensus-breaking" label. otherwise, i declare my belief that there are not consensus-breaking changes, for the following reason: > this is a like-for-like refactoring, changing a function > signature. --- crates/bin/pd/src/main.rs | 4 ++-- crates/core/app/src/rpc.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/bin/pd/src/main.rs b/crates/bin/pd/src/main.rs index 4a4f73e48f..efa15938d8 100644 --- a/crates/bin/pd/src/main.rs +++ b/crates/bin/pd/src/main.rs @@ -118,8 +118,8 @@ async fn main() -> anyhow::Result<()> { penumbra_app::server::new(storage.clone()).listen_tcp(abci_bind), ); - let grpc_server = - penumbra_app::rpc::router(&storage, cometbft_addr, enable_expensive_rpc)?; + let tm_proxy = penumbra_tendermint_proxy::TendermintProxy::new(cometbft_addr); + let grpc_server = penumbra_app::rpc::router(&storage, tm_proxy, enable_expensive_rpc)?; // Create Axum routes for the frontend app. let frontend = pd::zipserve::router("/app/", pd::MINIFRONT_ARCHIVE_BYTES); diff --git a/crates/core/app/src/rpc.rs b/crates/core/app/src/rpc.rs index 7284acd6f9..43b65c7002 100644 --- a/crates/core/app/src/rpc.rs +++ b/crates/core/app/src/rpc.rs @@ -42,22 +42,22 @@ use { stake::v1::query_service_server::QueryServiceServer as StakeQueryServiceServer, }, }, - util::tendermint_proxy::v1::tendermint_proxy_service_server::TendermintProxyServiceServer, + util::tendermint_proxy::v1::tendermint_proxy_service_server::{ + TendermintProxyService, TendermintProxyServiceServer, + }, }, penumbra_sct::component::rpc::Server as SctServer, penumbra_shielded_pool::component::rpc::Server as ShieldedPoolServer, penumbra_stake::component::rpc::Server as StakeServer, - penumbra_tendermint_proxy::TendermintProxy, penumbra_tower_trace::remote_addr, tonic_web::enable as we, }; pub fn router( storage: &cnidarium::Storage, - cometbft_addr: url::Url, + tm_proxy: impl TendermintProxyService, enable_expensive_rpc: bool, ) -> anyhow::Result { - let tm_proxy = TendermintProxy::new(cometbft_addr); let ibc = penumbra_ibc::component::rpc::IbcQuery::::new(storage.clone()); let mut grpc_server = tonic::transport::server::Server::builder() .trace_fn(|req| match remote_addr(req) { @@ -115,7 +115,7 @@ pub fn router( .add_service(we(ClientQueryServer::new(ibc.clone()))) .add_service(we(ChannelQueryServer::new(ibc.clone()))) .add_service(we(ConnectionQueryServer::new(ibc.clone()))) - .add_service(we(TendermintProxyServiceServer::new(tm_proxy.clone()))) + .add_service(we(TendermintProxyServiceServer::new(tm_proxy))) .add_service(we(tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(penumbra_proto::FILE_DESCRIPTOR_SET) .build()