Skip to content

Commit

Permalink
app: 👐 rpc::router(..) accepts a TendermintProxyService
Browse files Browse the repository at this point in the history
 #### 💭 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.
  • Loading branch information
cratelyn committed May 24, 2024
1 parent a9d5c7b commit e9a5143
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions crates/core/app/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<tonic::transport::server::Router> {
let tm_proxy = TendermintProxy::new(cometbft_addr);
let ibc = penumbra_ibc::component::rpc::IbcQuery::<PenumbraHost>::new(storage.clone());
let mut grpc_server = tonic::transport::server::Server::builder()
.trace_fn(|req| match remote_addr(req) {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e9a5143

Please sign in to comment.