Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max object size and DSN listen on address arguments to gateway #3157

Merged
merged 2 commits into from
Oct 22, 2024
Merged
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
12 changes: 10 additions & 2 deletions crates/subspace-gateway/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<RPC_DEFAULT_PORT>,
// TODO: maximum object size
}

/// Default run command for gateway
Expand All @@ -56,6 +63,7 @@ pub async fn run(run_options: RunOptions) -> anyhow::Result<()> {
gateway:
GatewayOptions {
dev,
max_size,
mut dsn_options,
rpc_options,
},
Expand Down Expand Up @@ -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?;
Expand Down
8 changes: 8 additions & 0 deletions crates/subspace-gateway/src/commands/run/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Multiaddr>,
}

/// Create a DSN network client with the supplied configuration.
Expand All @@ -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:
Expand Down Expand Up @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-gateway/src/commands/run/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const RPC_DEFAULT_PORT: u16 = 9955;
/// Options for the RPC server.
#[derive(Debug, Parser)]
pub(crate) struct RpcOptions<const DEFAULT_PORT: u16> {
/// 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(
Expand Down
Loading