Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
"crates/core/transaction",
"crates/core/app",
"crates/custody",
"crates/grpc-server",
"crates/wallet",
"crates/view",
"crates/util/auto-https",
Expand Down Expand Up @@ -170,6 +171,7 @@ penumbra-fee = { default-features = false, path = "crates/co
penumbra-funding = { default-features = false, path = "crates/core/component/funding" }
penumbra-governance = { default-features = false, path = "crates/core/component/governance" }
penumbra-genesis = { path = "crates/core/genesis" }
penumbra-grpc-server = { path = "crates/grpc-server" }
penumbra-ibc = { default-features = false, path = "crates/core/component/ibc" }
penumbra-keys = { default-features = false, path = "crates/core/keys" }
penumbra-mock-client = { path = "crates/test/mock-client" }
Expand All @@ -182,6 +184,7 @@ penumbra-sct = { default-features = false, path = "crates/co
penumbra-shielded-pool = { default-features = false, path = "crates/core/component/shielded-pool" }
penumbra-stake = { default-features = false, path = "crates/core/component/stake" }
penumbra-tct = { default-features = false, path = "crates/crypto/tct" }
penumbra-tower-trace = { path = "crates/util/tower-trace" }
penumbra-transaction = { default-features = false, path = "crates/core/transaction" }
penumbra-txhash = { default-features = false, path = "crates/core/txhash" }
penumbra-view = { path = "crates/view" }
Expand Down
13 changes: 2 additions & 11 deletions crates/bin/pd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@ penumbra-stake = {workspace = true, features = [
"parallel",
], default-features = true}
penumbra-sct = {workspace = true, default-features = true}
penumbra-fee = {workspace = true, default-features = true}
penumbra-dex = {workspace = true, features = ["parallel"], default-features = true}
penumbra-governance = {workspace = true, features = [
"parallel",
], default-features = true}
penumbra-governance = {workspace = true, features = ["parallel"], default-features = true}
penumbra-ibc = {workspace = true, features = ["rpc"], default-features = true}
penumbra-compact-block = {workspace = true, default-features = true}
penumbra-transaction = {workspace = true, default-features = true}
penumbra-app = {workspace = true}
penumbra-custody = {workspace = true}
penumbra-tower-trace = { path = "../../util/tower-trace" }
penumbra-tendermint-proxy = { path = "../../util/tendermint-proxy" }
penumbra-auto-https = { path = "../../util/auto-https" }
penumbra-genesis = {workspace = true}
Expand All @@ -65,9 +60,6 @@ tendermint-proto = {workspace = true}
tendermint = {workspace = true}
tendermint-light-client-verifier = {workspace = true}
ibc-types = {workspace = true, default-features = true}
ibc-proto = {workspace = true, default-features = false, features = [
"server",
]}
prost = {workspace = true}
toml = {workspace = true}
ics23 = {workspace = true}
Expand All @@ -92,9 +84,7 @@ regex = {workspace = true}
reqwest = { version = "0.11", features = ["json"] }
prost-types = {workspace = true}
pbjson-types = {workspace = true}
tonic = {workspace = true}
tonic-web = {workspace = true}
tonic-reflection = {workspace = true}
tracing-subscriber = {workspace = true, features = ["env-filter", "ansi"]}
url = {workspace = true}
pin-project = {workspace = true}
Expand Down Expand Up @@ -129,6 +119,7 @@ axum-server = {workspace = true, features = ["tls-rustls"]}
zip = "0.6"
mime_guess = "2"
axum = "0.6"
penumbra-grpc-server = { workspace = true }

[dev-dependencies]
penumbra-proof-params = {workspace = true, features = [
Expand Down
109 changes: 7 additions & 102 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(clippy::clone_on_copy)]
#![deny(clippy::unwrap_used)]
#![recursion_limit = "512"]

use std::error::Error;
use std::io::IsTerminal as _;

Expand All @@ -10,9 +11,6 @@ use metrics_util::layers::Stack;

use anyhow::Context;
use cnidarium::{StateDelta, Storage};
use ibc_proto::ibc::core::channel::v1::query_server::QueryServer as ChannelQueryServer;
use ibc_proto::ibc::core::client::v1::query_server::QueryServer as ClientQueryServer;
use ibc_proto::ibc::core::connection::v1::query_server::QueryServer as ConnectionQueryServer;
use metrics_exporter_prometheus::PrometheusBuilder;
use pd::{
cli::{Opt, RootCommand, TestnetCommand},
Expand All @@ -23,16 +21,13 @@ use pd::{
join::testnet_join,
},
};
use penumbra_app::{PenumbraHost, SUBSTORE_PREFIXES};
use penumbra_app::SUBSTORE_PREFIXES;
use penumbra_proto::core::component::dex::v1::simulation_service_server::SimulationServiceServer;
use penumbra_proto::util::tendermint_proxy::v1::tendermint_proxy_service_server::TendermintProxyServiceServer;
use penumbra_tendermint_proxy::TendermintProxy;
use penumbra_tower_trace::remote_addr;
use rand::Rng;
use rand_core::OsRng;
use tendermint_config::net::Address as TendermintAddress;
use tokio::runtime;
use tonic::transport::Server;
use tower_http::cors::CorsLayer;
use tracing_subscriber::{prelude::*, EnvFilter};
use url::Url;
Expand Down Expand Up @@ -134,102 +129,12 @@ async fn main() -> anyhow::Result<()> {
.spawn(penumbra_app::server::new(storage.clone()).listen_tcp(abci_bind))
.expect("failed to spawn abci server");

let ibc = penumbra_ibc::component::rpc::IbcQuery::<PenumbraHost>::new(storage.clone());

// TODO: Once we migrate to Tonic 0.10.0, we'll be able to use the
// `Routes` structure to have each component define a method that
// returns a `Routes` with all of its query services bundled inside.
//
// This means we won't have to import all this shit and recite every
// single service -- we can e.g., have the app crate assemble all of
// its components' query services into a single `Routes` and then
// just add that to the gRPC server.

use cnidarium::rpc::proto::v1::query_service_server::QueryServiceServer as StorageQueryServiceServer;
use penumbra_proto::core::{
app::v1::query_service_server::QueryServiceServer as AppQueryServiceServer,
component::{
compact_block::v1::query_service_server::QueryServiceServer as CompactBlockQueryServiceServer,
dex::v1::query_service_server::QueryServiceServer as DexQueryServiceServer,
fee::v1::query_service_server::QueryServiceServer as FeeQueryServiceServer,
governance::v1::query_service_server::QueryServiceServer as GovernanceQueryServiceServer,
sct::v1::query_service_server::QueryServiceServer as SctQueryServiceServer,
shielded_pool::v1::query_service_server::QueryServiceServer as ShieldedPoolQueryServiceServer,
stake::v1::query_service_server::QueryServiceServer as StakeQueryServiceServer,
},
};
use tonic_web::enable as we;

use cnidarium::rpc::Server as StorageServer;
use penumbra_app::rpc::Server as AppServer;
use penumbra_compact_block::component::rpc::Server as CompactBlockServer;
use penumbra_dex::component::rpc::Server as DexServer;
use penumbra_fee::component::rpc::Server as FeeServer;
use penumbra_governance::component::rpc::Server as GovernanceServer;
use penumbra_sct::component::rpc::Server as SctServer;
use penumbra_shielded_pool::component::rpc::Server as ShieldedPoolServer;
use penumbra_stake::component::rpc::Server as StakeServer;

let mut grpc_server = Server::builder()
.trace_fn(|req| match remote_addr(req) {
Some(remote_addr) => {
tracing::error_span!("grpc", ?remote_addr)
}
None => tracing::error_span!("grpc"),
})
// Allow HTTP/1, which will be used by grpc-web connections.
// This is particularly important when running locally, as gRPC
// typically uses HTTP/2, which requires HTTPS. Accepting HTTP/2
// allows local applications such as web browsers to talk to pd.
.accept_http1(true)
// As part of #2932, we are disabling all timeouts until we circle back to our
// performance story.
// Sets a timeout for all gRPC requests, but note that in the case of streaming
// requests, the timeout is only applied to the initial request. This means that
// this does not prevent long lived streams, for example to allow clients to obtain
// new blocks.
// .timeout(std::time::Duration::from_secs(7))
// Wrap each of the gRPC services in a tonic-web proxy:
.add_service(we(StorageQueryServiceServer::new(StorageServer::new(
storage.clone(),
))))
.add_service(we(AppQueryServiceServer::new(AppServer::new(
storage.clone(),
))))
.add_service(we(CompactBlockQueryServiceServer::new(
CompactBlockServer::new(storage.clone()),
)))
.add_service(we(DexQueryServiceServer::new(DexServer::new(
storage.clone(),
))))
.add_service(we(FeeQueryServiceServer::new(FeeServer::new(
storage.clone(),
))))
.add_service(we(GovernanceQueryServiceServer::new(
GovernanceServer::new(storage.clone()),
)))
.add_service(we(SctQueryServiceServer::new(SctServer::new(
storage.clone(),
))))
.add_service(we(ShieldedPoolQueryServiceServer::new(
ShieldedPoolServer::new(storage.clone()),
)))
.add_service(we(StakeQueryServiceServer::new(StakeServer::new(
storage.clone(),
))))
.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(tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(penumbra_proto::FILE_DESCRIPTOR_SET)
.build()
.with_context(|| "could not configure grpc reflection service")?));

let mut grpc_server = penumbra_grpc_server::new(&storage, &tm_proxy)?;
if enable_expensive_rpc {
grpc_server = grpc_server.add_service(we(SimulationServiceServer::new(
DexServer::new(storage.clone()),
)));
use penumbra_dex::component::rpc::Server as DexServer;
grpc_server = grpc_server.add_service(tonic_web::enable(
SimulationServiceServer::new(DexServer::new(storage.clone())),
));
}

// Create Axum routes for the frontend app.
Expand Down
3 changes: 3 additions & 0 deletions crates/core/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ tower-service = { workspace = true }
tracing = { workspace = true }

[dev-dependencies]
camino = { workspace = true }
ed25519-consensus = { workspace = true }
penumbra-mock-consensus = { workspace = true }
penumbra-mock-client = { workspace = true }
penumbra-view = { workspace = true }
rand = { workspace = true }
rand_core = { workspace = true }
rand_chacha = { workspace = true }
tap = { workspace = true }
tracing-subscriber = { workspace = true }
url = { workspace = true }

# Enable the feature flags to get proving keys when running tests.
[dev-dependencies.penumbra-proof-params]
Expand Down
33 changes: 33 additions & 0 deletions crates/core/app/tests/mock_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// Note: these should eventually replace the existing test cases. mock consensus tests are placed
// here while the engine is still in development. See #3588.

use penumbra_proto::view::v1::view_service_server::ViewServiceServer;
use tempfile::tempdir;

mod common;

use {
Expand Down Expand Up @@ -204,3 +207,33 @@ async fn mock_consensus_can_spend_notes_and_detect_outputs() -> anyhow::Result<(

Ok(())
}

#[tokio::test]
// #[ignore = "this test is not currently expected to pass"] /*TODO(kate)*/
async fn mock_consensus_view_server_test() -> anyhow::Result<()> {
// Install a test logger, acquire some temporary storage, and start the test node.
let guard = common::set_tracing_subscriber();
let tempdir = tempdir()?;
let storage = TempStorage::new().await?;
let _test_node = common::start_test_node(&storage).await?;

// Spawn the server-side view server...
let _ = {};

// Spawn the client-side view server...
let view = {
let url = "http:127.0.0.1:8080".parse::<url::Url>()?; /*TODO(kate)*/
penumbra_view::ViewServer::load_or_initialize(
None::<&camino::Utf8Path>,
&*test_keys::FULL_VIEWING_KEY,
url,
)
.await
.map(ViewServiceServer::new)?
};

drop(view);
drop(tempdir);
drop(guard);
Ok(())
}
Loading