Skip to content

Commit

Permalink
app(rpc): expose simtrade service by default (#4697)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor authored Jul 5, 2024
1 parent 44aa2be commit 9311258
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
5 changes: 1 addition & 4 deletions crates/bin/pd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ pub enum RootCommand {
alias = "tendermint-addr",
)]
cometbft_addr: Url,
/// Enable expensive RPCs, such as the trade simulation service.
/// The trade simulation service allows clients to simulate trades without submitting them.
/// This is useful for approximating the cost of a trade before submitting it.
/// But, it is a potential DoS vector, so it is disabled by default.
/// Enable expensive RPCs, currently a no-op.
#[clap(short, long, display_order = 500)]
enable_expensive_rpc: bool,
},
Expand Down
18 changes: 6 additions & 12 deletions crates/core/app/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use {
},
penumbra_auction::component::rpc::Server as AuctionServer,
penumbra_compact_block::component::rpc::Server as CompactBlockServer,
penumbra_dex::component::rpc::{stub::SimulationsDisabled, Server as DexServer},
penumbra_dex::component::rpc::Server as DexServer,
penumbra_fee::component::rpc::Server as FeeServer,
penumbra_governance::component::rpc::Server as GovernanceServer,
penumbra_proto::{
Expand Down Expand Up @@ -57,10 +57,10 @@ use {
pub fn router(
storage: &cnidarium::Storage,
tm_proxy: impl TendermintProxyService,
enable_expensive_rpc: bool,
_enable_expensive_rpc: bool,
) -> anyhow::Result<tonic::transport::server::Router> {
let ibc = penumbra_ibc::component::rpc::IbcQuery::<PenumbraHost>::new(storage.clone());
let mut grpc_server = tonic::transport::server::Server::builder()
let grpc_server = tonic::transport::server::Server::builder()
.trace_fn(|req| match remote_addr(req) {
Some(remote_addr) => {
tracing::error_span!("grpc", ?remote_addr)
Expand Down Expand Up @@ -120,19 +120,13 @@ pub fn router(
.add_service(we(ChannelQueryServer::new(ibc.clone())))
.add_service(we(ConnectionQueryServer::new(ibc.clone())))
.add_service(we(TendermintProxyServiceServer::new(tm_proxy)))
.add_service(we(SimulationServiceServer::new(DexServer::new(
storage.clone(),
))))
.add_service(we(tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(penumbra_proto::FILE_DESCRIPTOR_SET)
.build()
.with_context(|| "could not configure grpc reflection service")?));

if enable_expensive_rpc {
grpc_server = grpc_server.add_service(we(SimulationServiceServer::new(DexServer::new(
storage.clone(),
))));
} else {
grpc_server =
grpc_server.add_service(we(SimulationServiceServer::new(SimulationsDisabled)));
}

Ok(grpc_server)
}

0 comments on commit 9311258

Please sign in to comment.