Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ pub struct RunCmd {
#[clap(long)]
pub rpc_max_response_size: Option<usize>,

/// Set the the maximum concurrent subscriptions per connection.
/// Default is 1024.
#[clap(long)]
pub rpc_max_subscriptions_per_connection: Option<usize>,

/// Expose Prometheus exporter on all interfaces.
///
/// Default is local.
Expand Down Expand Up @@ -459,6 +464,18 @@ impl CliConfiguration for RunCmd {
Ok(self.rpc_max_payload)
}

fn rpc_max_request_size(&self) -> Result<Option<usize>> {
Ok(self.rpc_max_request_size)
}

fn rpc_max_response_size(&self) -> Result<Option<usize>> {
Ok(self.rpc_max_response_size)
}

fn rpc_max_subscriptions_per_connection(&self) -> Result<Option<usize>> {
Ok(self.rpc_max_subscriptions_per_connection)
}

fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a deprecation eprintln! here too? And/or docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/paritytech/substrate/blob/8392760e00162cd01d95e4534a1996963b3d8e92/client/service/src/lib.rs#L482-#L526

Added it ☝️ here because it's annoying to print if one doesn't has applied that CLI option

Ok(self.ws_max_out_buffer_capacity)
}
Expand Down
7 changes: 6 additions & 1 deletion client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(None)
}

/// Get maximum number of subscriptions per connection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does Ok(None) mean here? That it's using the default? If yes, maybe worth mentioning in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a default imp for that CliConfiguration trait I just did the same as the other rpc options but clearly a footgun for
folks like me :(

fn rpc_max_subscriptions_per_connection(&self) -> Result<Option<usize>> {
Ok(None)
}

/// Get maximum WS output buffer capacity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be marked as deprecated maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
Ok(None)
Expand Down Expand Up @@ -539,7 +544,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
rpc_max_request_size: self.rpc_max_request_size()?,
rpc_max_response_size: self.rpc_max_response_size()?,
rpc_id_provider: None,
rpc_max_subs_per_conn: None,
rpc_max_subs_per_conn: self.rpc_max_subscriptions_per_connection()?,
ws_max_out_buffer_capacity: self.ws_max_out_buffer_capacity()?,
prometheus_config: self
.prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?,
Expand Down
28 changes: 18 additions & 10 deletions client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ where
fn import(&self, transaction: B::Extrinsic) -> TransactionImportFuture {
if !self.imports_external_transactions {
debug!("Transaction rejected");
return Box::pin(futures::future::ready(TransactionImport::None))
return Box::pin(futures::future::ready(TransactionImport::None));
}

let encoded = transaction.encode();
let uxt = match Decode::decode(&mut &encoded[..]) {
Ok(uxt) => uxt,
Err(e) => {
debug!("Transaction invalid: {:?}", e);
return Box::pin(futures::future::ready(TransactionImport::Bad))
return Box::pin(futures::future::ready(TransactionImport::Bad));
},
};

Expand All @@ -450,8 +450,9 @@ where
match import_future.await {
Ok(_) => TransactionImport::NewGood,
Err(e) => match e.into_pool_error() {
Ok(sc_transaction_pool_api::error::Error::AlreadyImported(_)) =>
TransactionImport::KnownGood,
Ok(sc_transaction_pool_api::error::Error::AlreadyImported(_)) => {
TransactionImport::KnownGood
},
Ok(e) => {
debug!("Error adding transaction to the pool: {:?}", e);
TransactionImport::Bad
Expand Down Expand Up @@ -480,11 +481,18 @@ where
}

fn legacy_cli_parsing(config: &Configuration) -> (Option<usize>, Option<usize>, Option<usize>) {
let ws_max_response_size = config.ws_max_out_buffer_capacity.map(|max| {
eprintln!("DEPRECATED: `--ws_max_out_buffer_capacity` has been removed use `rpc-max-response-size or rpc-max-request-size` instead");
eprintln!("Setting WS `rpc-max-response-size` to `max(ws_max_out_buffer_capacity, rpc_max_response_size)`");
std::cmp::max(max, config.rpc_max_response_size.unwrap_or(0))
});
let ws_max_response_size = match (
config.ws_max_out_buffer_capacity,
config.rpc_max_response_size,
) {
(Some(legacy_max), max) => {
eprintln!("DEPRECATED: `--ws_max_out_buffer_capacity` has been removed use `rpc-max-response-size or rpc-max-request-size` instead");
eprintln!("Setting WS `rpc-max-response-size` to `max(ws_max_out_buffer_capacity, rpc_max_response_size)`");
Some(std::cmp::max(legacy_max, max.unwrap_or(0)))
},
(None, Some(m)) => Some(m),
(None, None) => None,
};

let max_request_size = match (config.rpc_max_payload, config.rpc_max_request_size) {
(Some(legacy_max), max) => {
Expand All @@ -498,7 +506,7 @@ fn legacy_cli_parsing(config: &Configuration) -> (Option<usize>, Option<usize>,
(None, None) => None,
};

let http_max_response_size = match (config.rpc_max_payload, config.rpc_max_request_size) {
let http_max_response_size = match (config.rpc_max_payload, config.rpc_max_response_size) {
(Some(legacy_max), max) => {
eprintln!("DEPRECATED: `--rpc_max_payload` has been removed use `rpc-max-response-size or rpc-max-request-size` instead");
eprintln!(
Expand Down