rpc server: make possible to disable/enable batch requests (#3364)

The rationale behind this, is that it may be useful for some users
actually disable RPC batch requests or limit them by length instead of
the total size bytes of the batch.

This PR adds two new CLI options:

```
--rpc-disable-batch-requests - disable batch requests on the server
--rpc-max-batch-request-len <LEN> - limit batches to LEN on the server.
```
This commit is contained in:
Niklas Adolfsson
2024-02-20 17:16:21 +01:00
committed by GitHub
parent ff40310d87
commit fee810a5ea
14 changed files with 77 additions and 11 deletions
+3
View File
@@ -18,6 +18,7 @@
//! Service configuration.
pub use jsonrpsee::server::BatchRequestConfig as RpcBatchRequestConfig;
use prometheus_endpoint::Registry;
use sc_chain_spec::ChainSpec;
pub use sc_client_db::{BlocksPruning, Database, DatabaseSource, PruningMode};
@@ -103,6 +104,8 @@ pub struct Configuration {
pub rpc_port: u16,
/// The number of messages the JSON-RPC server is allowed to keep in memory.
pub rpc_message_buffer_capacity: u32,
/// JSON-RPC server batch config.
pub rpc_batch_config: RpcBatchRequestConfig,
/// RPC rate limit per minute.
pub rpc_rate_limit: Option<NonZeroU32>,
/// Prometheus endpoint configuration. `None` if disabled.
+1
View File
@@ -393,6 +393,7 @@ where
let server_config = sc_rpc_server::Config {
addrs: [addr, backup_addr],
batch_config: config.rpc_batch_config,
max_connections: config.rpc_max_connections,
max_payload_in_mb: config.rpc_max_request_size,
max_payload_out_mb: config.rpc_max_response_size,