Skip to content

Commit 011fe44

Browse files
authored
Merge pull request #3332 from Pana/feat/rpcConfig
add configuration options for espace rpcs
2 parents 3b5e855 + a2fe372 commit 011fe44

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/client/src/rpc/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ pub async fn launch_async_rpc_servers(
421421
.with_ws(apis.clone());
422422

423423
let server_config =
424-
RpcServerConfig::http(ServerBuilder::default())
425-
.with_ws(ServerBuilder::default())
424+
RpcServerConfig::http(conf.jsonrpsee_server_builder())
425+
.with_ws(conf.jsonrpsee_server_builder())
426426
.with_http_address(http_config.address)
427427
.with_ws_address(ws_config.address);
428428
(transport_rpc_module_config, server_config)
@@ -431,15 +431,15 @@ pub async fn launch_async_rpc_servers(
431431
let transport_rpc_module_config =
432432
TransportRpcModuleConfig::set_http(apis.clone());
433433
let server_config =
434-
RpcServerConfig::http(ServerBuilder::default())
434+
RpcServerConfig::http(conf.jsonrpsee_server_builder())
435435
.with_http_address(http_config.address);
436436
(transport_rpc_module_config, server_config)
437437
}
438438
(false, true) => {
439439
let transport_rpc_module_config =
440440
TransportRpcModuleConfig::set_ws(apis.clone());
441441
let server_config =
442-
RpcServerConfig::ws(ServerBuilder::default())
442+
RpcServerConfig::ws(conf.jsonrpsee_server_builder())
443443
.with_ws_address(ws_config.address);
444444
(transport_rpc_module_config, server_config)
445445
}

crates/config/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ db = { workspace = true }
3535
clap = { workspace = true }
3636
kvdb-rocksdb = { workspace = true }
3737
toml = { workspace = true }
38-
jsonrpc-http-server = { workspace = true }
38+
jsonrpc-http-server = { workspace = true }
39+
jsonrpsee = { workspace = true }
40+
tower = { workspace = true }

crates/config/src/configuration.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ use diem_types::term_state::{
5050
pos_state_config::PosStateConfig, IN_QUEUE_LOCKED_VIEWS,
5151
OUT_QUEUE_LOCKED_VIEWS, ROUND_PER_TERM, TERM_ELECTED_SIZE, TERM_MAX_SIZE,
5252
};
53+
use jsonrpsee::server::ServerBuilder;
5354
use metrics::MetricsConfiguration;
5455
use network::DiscoveryConfiguration;
5556
use primitives::block_header::CIP112_TRANSITION_HEIGHT;
57+
use tower::layer::util::Identity;
5658
use txgen::TransactionGeneratorConfig;
5759

5860
use crate::{HttpConfiguration, TcpConfiguration, WsConfiguration};
@@ -222,6 +224,11 @@ build_config! {
222224
(jsonrpc_ws_max_payload_bytes, (usize), 30 * 1024 * 1024)
223225
(jsonrpc_http_eth_port, (Option<u16>), None)
224226
(jsonrpc_ws_eth_port, (Option<u16>), None)
227+
(jsonrpc_max_request_body_size, (u32), 10 * 1024 * 1024)
228+
(jsonrpc_max_response_body_size, (u32), 10 * 1024 * 1024)
229+
(jsonrpc_max_connections, (u32), 100)
230+
(jsonrpc_max_subscriptions_per_connection, (u32), 1024)
231+
(jsonrpc_message_buffer_capacity, (u32), 1024)
225232
// The network_id, if unset, defaults to the chain_id.
226233
// Only override the network_id for local experiments,
227234
// when user would like to keep the existing blockchain data
@@ -1178,6 +1185,25 @@ impl Configuration {
11781185
TcpConfiguration::new(None, self.raw_conf.jsonrpc_tcp_port)
11791186
}
11801187

1188+
pub fn jsonrpsee_server_builder(
1189+
&self,
1190+
) -> ServerBuilder<Identity, Identity> {
1191+
let builder = ServerBuilder::default()
1192+
.max_request_body_size(self.raw_conf.jsonrpc_max_request_body_size)
1193+
.max_response_body_size(
1194+
self.raw_conf.jsonrpc_max_response_body_size,
1195+
)
1196+
.max_connections(self.raw_conf.jsonrpc_max_connections)
1197+
.max_subscriptions_per_connection(
1198+
self.raw_conf.jsonrpc_max_subscriptions_per_connection,
1199+
)
1200+
.set_message_buffer_capacity(
1201+
self.raw_conf.jsonrpc_message_buffer_capacity,
1202+
);
1203+
1204+
builder
1205+
}
1206+
11811207
pub fn local_ws_config(&self) -> WsConfiguration {
11821208
WsConfiguration::new(
11831209
Some((127, 0, 0, 1)),

run/hydra.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ log_conf="log.yaml"
122122
#
123123
# udp_port=32323
124124

125+
# -------------- JSON-RPC Configuration -------------
126+
125127
# `jsonrpc_http_threads` is used to control how many threads to process HTTP rpc requests.
126128
#
127129
# jsonrpc_http_threads=1
@@ -130,6 +132,9 @@ log_conf="log.yaml"
130132
#
131133
# jsonrpc_http_keep_alive=false
132134

135+
# core space max payload size for ws server
136+
# jsonrpc_ws_max_payload_bytes=30 * 1024 * 1024
137+
133138
# `jsonrpc_cors` is used to control the rpc domain validation policies.
134139
# The value should be "none", "all", or a list string split by commas without space.
135140
# If not set, domain validation is disabled.
@@ -175,6 +180,17 @@ jsonrpc_local_http_port=12539
175180
#
176181
# max_estimation_gas_limit = 30_000_000
177182

183+
# Below are espace RPC configurations
184+
# Set the maximum size of a request body in bytes. Default is 10 MiB.
185+
# jsonrpc_max_request_body_size=10 * 1024 * 1024
186+
# Set the maximum size of a response body in bytes. Default is 10 MiB.
187+
# jsonrpc_max_response_body_size=10 * 1024 * 1024
188+
# Set the maximum number of connections allowed. Default is 100.
189+
# jsonrpc_max_connections=100
190+
# Set the maximum number of connections allowed. Default is 1024.
191+
# jsonrpc_max_subscriptions_per_connection=1024
192+
# Number of messages that server is allowed to `buffer` until backpressure kicks in. Default is 1024.
193+
# jsonrpc_message_buffer_capacity=1024
178194
# --------------- Performance-related Network Parameters ----------------------
179195

180196
# Timeout for block-related requests (GetBlock, GetCmpctBlock, GetBlockTxn)

tools/evm-spec-tester/Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)