-
Notifications
You must be signed in to change notification settings - Fork 808
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
rpc server: make possible to disable/enable batch requests #3364
Changes from all commits
d8b3f4c
b24393f
3d7dda8
ac97ca3
0597563
1830e89
ba3c2d9
6f1f09c
02fa005
de97320
55869f6
5ecce99
e120482
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
||
title: rpc server expose batch request configuration | ||
|
||
doc: | ||
- audience: Node Operator | ||
description: | | ||
Add functionality to limit RPC batch requests by two new CLI options: | ||
--rpc-disable-batch-request - disable batch requests on the server | ||
--rpc-max-batch-request-len - limit batches to LEN on the server | ||
crates: [ ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ use crate::{ | |
use clap::Parser; | ||
use regex::Regex; | ||
use sc_service::{ | ||
config::{BasePath, PrometheusConfig, TransactionPoolOptions}, | ||
config::{BasePath, PrometheusConfig, RpcBatchRequestConfig, TransactionPoolOptions}, | ||
ChainSpec, Role, | ||
}; | ||
use sc_telemetry::TelemetryEndpoints; | ||
|
@@ -125,6 +125,14 @@ pub struct RunCmd { | |
#[arg(long, default_value_t = RPC_DEFAULT_MESSAGE_CAPACITY_PER_CONN)] | ||
pub rpc_message_buffer_capacity_per_connection: u32, | ||
|
||
/// Disable RPC batch requests | ||
#[arg(long, alias = "rpc_no_batch_requests", conflicts_with_all = &["rpc_max_batch_request_len"])] | ||
pub rpc_disable_batch_requests: bool, | ||
|
||
/// Limit the max length per RPC batch request | ||
#[arg(long, conflicts_with_all = &["rpc_disable_batch_requests"], value_name = "LEN")] | ||
pub rpc_max_batch_request_len: Option<u32>, | ||
|
||
/// Specify browser *origins* allowed to access the HTTP & WS RPC servers. | ||
/// | ||
/// A comma-separated list of origins (protocol://domain or special `null` | ||
|
@@ -411,6 +419,22 @@ impl CliConfiguration for RunCmd { | |
Ok(self.rpc_max_subscriptions_per_connection) | ||
} | ||
|
||
fn rpc_buffer_capacity_per_connection(&self) -> Result<u32> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR but I noticed that this was missing and only the default value will be used regardless whether someone is using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh this is the line I missed when I was looking at the PR and only noticed the batch config bits :) |
||
Ok(self.rpc_message_buffer_capacity_per_connection) | ||
} | ||
|
||
fn rpc_batch_config(&self) -> Result<RpcBatchRequestConfig> { | ||
let cfg = if self.rpc_disable_batch_requests { | ||
RpcBatchRequestConfig::Disabled | ||
} else if let Some(l) = self.rpc_max_batch_request_len { | ||
RpcBatchRequestConfig::Limit(l) | ||
} else { | ||
RpcBatchRequestConfig::Unlimited | ||
}; | ||
|
||
Ok(cfg) | ||
} | ||
|
||
fn rpc_rate_limit(&self) -> Result<Option<NonZeroU32>> { | ||
Ok(self.rpc_rate_limit) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"CI fix" to allow the job to fail