From 995e1cd9a0f28de70a3122d0b7f1c6e62e249f6d Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 22 Oct 2024 08:01:07 +1000 Subject: [PATCH 1/2] Add DSN listen on addresses for debugging --- crates/subspace-gateway/src/commands/run/network.rs | 8 ++++++++ crates/subspace-gateway/src/commands/run/rpc.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/subspace-gateway/src/commands/run/network.rs b/crates/subspace-gateway/src/commands/run/network.rs index d61f01502b..c4d9db73c6 100644 --- a/crates/subspace-gateway/src/commands/run/network.rs +++ b/crates/subspace-gateway/src/commands/run/network.rs @@ -40,6 +40,12 @@ pub(crate) struct NetworkArgs { /// Maximum pending outgoing swarm connection limit. #[arg(long, default_value_t = 100)] pending_out_connections: u32, + + /// Multiaddrs to listen on for DSN connections, multiple are supported. + /// + /// This is mainly for debugging. + #[arg(long)] + listen_on: Vec, } /// Create a DSN network client with the supplied configuration. @@ -54,6 +60,7 @@ pub async fn configure_network( allow_private_ips, out_connections, pending_out_connections, + listen_on, }: NetworkArgs, ) -> anyhow::Result<(Node, NodeRunner<()>, RpcNodeClient)> { // TODO: @@ -92,6 +99,7 @@ pub async fn configure_network( max_established_outgoing_connections: out_connections, max_pending_outgoing_connections: pending_out_connections, kademlia_mode: KademliaMode::Static(Mode::Client), + listen_on, ..default_config }; diff --git a/crates/subspace-gateway/src/commands/run/rpc.rs b/crates/subspace-gateway/src/commands/run/rpc.rs index d5a65131cd..a7e58bb234 100644 --- a/crates/subspace-gateway/src/commands/run/rpc.rs +++ b/crates/subspace-gateway/src/commands/run/rpc.rs @@ -12,7 +12,7 @@ pub const RPC_DEFAULT_PORT: u16 = 9955; /// Options for the RPC server. #[derive(Debug, Parser)] pub(crate) struct RpcOptions { - /// IP and port (TCP) on which to listen for RPC requests. + /// IP and port (TCP) to listen for RPC requests. /// /// This RPC method is not safe to be exposed on a public IP address. #[arg(long, default_value_t = SocketAddr::new( From ff7afd1889c72032373d2bd7c74cbea02497e224 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 22 Oct 2024 08:17:45 +1000 Subject: [PATCH 2/2] Add a --max-size argument to the gateway --- crates/subspace-gateway/src/commands/run.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/subspace-gateway/src/commands/run.rs b/crates/subspace-gateway/src/commands/run.rs index fab26671e4..ace0f5333b 100644 --- a/crates/subspace-gateway/src/commands/run.rs +++ b/crates/subspace-gateway/src/commands/run.rs @@ -22,6 +22,9 @@ use subspace_gateway_rpc::{SubspaceGatewayRpc, SubspaceGatewayRpcConfig}; use subspace_kzg::Kzg; use tracing::info; +/// The default size limit, based on the maximum block size in some domains. +pub const DEFAULT_MAX_SIZE: usize = 5 * 1024 * 1024; + /// Options for running a node #[derive(Debug, Parser)] pub(crate) struct RunOptions { @@ -39,13 +42,17 @@ pub(crate) struct GatewayOptions { #[arg(long, verbatim_doc_comment)] dev: bool, + /// The maximum object size to fetch. + /// Larger objects will return an error. + #[arg(long, default_value_t = DEFAULT_MAX_SIZE)] + max_size: usize, + #[clap(flatten)] dsn_options: NetworkArgs, /// Options for RPC #[clap(flatten)] rpc_options: RpcOptions, - // TODO: maximum object size } /// Default run command for gateway @@ -56,6 +63,7 @@ pub async fn run(run_options: RunOptions) -> anyhow::Result<()> { gateway: GatewayOptions { dev, + max_size, mut dsn_options, rpc_options, }, @@ -87,7 +95,7 @@ pub async fn run(run_options: RunOptions) -> anyhow::Result<()> { dsn_node.clone(), SegmentCommitmentPieceValidator::new(dsn_node, node_client, kzg), ); - let object_fetcher = ObjectFetcher::new(piece_getter, erasure_coding, None); + let object_fetcher = ObjectFetcher::new(piece_getter, erasure_coding, Some(max_size)); let rpc_api = SubspaceGatewayRpc::new(SubspaceGatewayRpcConfig { object_fetcher }); let rpc_handle = launch_rpc_server(rpc_api, rpc_options).await?;