Skip to content

Commit e02c6a6

Browse files
niklasad1bkchrdmitry-markinpepoviola
authored andcommitted
rpc server: break legacy CLI options and remove "backward compatible HTTP server" (paritytech#13384)
* jsonrpsee v0.16 * breaking: remove old CLI configs * remove patch.crates-io * fix bad merge * fix clippy * fix bad merge * fix grumbles * Update client/service/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * revert block_in_place * add issue link in todo * Update client/cli/src/config.rs Co-authored-by: Dmitry Markin <[email protected]> * grumbles: add ipv6 loopback address * Revert "grumbles: add ipv6 loopback address" This reverts commit 3a0b1ec. * remove nits * bump zombienet version * adress grumbles: provide structopt default_val_t * remove duplicate from structopt * bump zombienet v1.3.47 * bump zombienet version --------- Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Dmitry Markin <[email protected]> Co-authored-by: Javier Viola <[email protected]>
1 parent 070dfa2 commit e02c6a6

File tree

11 files changed

+150
-394
lines changed

11 files changed

+150
-394
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ variables:
6161

6262
NEXTEST_FAILURE_OUTPUT: immediate-final
6363
NEXTEST_SUCCESS_OUTPUT: final
64-
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.43"
64+
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.48"
6565

6666
default:
6767
retry:

bin/node/cli/benches/block_production.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,14 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
8484
offchain_worker: execution_strategy,
8585
other: execution_strategy,
8686
},
87-
rpc_http: None,
88-
rpc_ws: None,
89-
rpc_ipc: None,
90-
rpc_ws_max_connections: None,
87+
rpc_addr: None,
88+
rpc_max_connections: Default::default(),
9189
rpc_cors: None,
9290
rpc_methods: Default::default(),
93-
rpc_max_payload: None,
94-
rpc_max_request_size: None,
95-
rpc_max_response_size: None,
96-
rpc_id_provider: None,
97-
rpc_max_subs_per_conn: None,
98-
ws_max_out_buffer_capacity: None,
91+
rpc_max_request_size: Default::default(),
92+
rpc_max_response_size: Default::default(),
93+
rpc_id_provider: Default::default(),
94+
rpc_max_subs_per_conn: Default::default(),
9995
prometheus_config: None,
10096
telemetry_endpoints: None,
10197
default_heap_pages: None,

bin/node/cli/benches/transaction_pool.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,14 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
7878
offchain_worker: sc_client_api::ExecutionStrategy::NativeWhenPossible,
7979
other: sc_client_api::ExecutionStrategy::NativeWhenPossible,
8080
},
81-
rpc_http: None,
82-
rpc_ws: None,
83-
rpc_ipc: None,
84-
rpc_ws_max_connections: None,
81+
rpc_addr: None,
82+
rpc_max_connections: Default::default(),
8583
rpc_cors: None,
8684
rpc_methods: Default::default(),
87-
rpc_max_payload: None,
88-
rpc_max_request_size: None,
89-
rpc_max_response_size: None,
90-
rpc_id_provider: None,
91-
rpc_max_subs_per_conn: None,
92-
ws_max_out_buffer_capacity: None,
85+
rpc_max_request_size: Default::default(),
86+
rpc_max_response_size: Default::default(),
87+
rpc_id_provider: Default::default(),
88+
rpc_max_subs_per_conn: Default::default(),
9389
prometheus_config: None,
9490
telemetry_endpoints: None,
9591
default_heap_pages: None,

client/cli/src/commands/run_cmd.rs

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub struct RunCmd {
6565
/// RPC methods to expose.
6666
/// - `unsafe`: Exposes every RPC method.
6767
/// - `safe`: Exposes only a safe subset of RPC methods, denying unsafe RPC methods.
68-
/// - `auto`: Acts as `safe` if RPC is served externally, e.g. when `--{rpc,ws}-external` is
68+
/// - `auto`: Acts as `safe` if RPC is served externally, e.g. when `--rpc--external` is
6969
/// passed, otherwise acts as `unsafe`.
7070
#[arg(
7171
long,
@@ -77,58 +77,25 @@ pub struct RunCmd {
7777
)]
7878
pub rpc_methods: RpcMethods,
7979

80-
/// Listen to all Websocket interfaces.
81-
/// Default is local. Note: not all RPC methods are safe to be exposed publicly. Use an RPC
82-
/// proxy server to filter out dangerous methods. More details:
83-
/// <https://docs.substrate.io/main-docs/build/custom-rpc/#public-rpcs>.
84-
/// Use `--unsafe-ws-external` to suppress the warning if you understand the risks.
85-
#[arg(long)]
86-
pub ws_external: bool,
87-
88-
/// Listen to all Websocket interfaces.
89-
/// Same as `--ws-external` but doesn't warn you about it.
90-
#[arg(long)]
91-
pub unsafe_ws_external: bool,
92-
93-
/// DEPRECATED, this has no affect anymore. Use `rpc_max_request_size` or
94-
/// `rpc_max_response_size` instead.
95-
#[arg(long)]
96-
pub rpc_max_payload: Option<usize>,
97-
9880
/// Set the the maximum RPC request payload size for both HTTP and WS in megabytes.
99-
/// Default is 15MiB.
100-
#[arg(long)]
101-
pub rpc_max_request_size: Option<usize>,
81+
#[arg(long, default_value_t = 15)]
82+
pub rpc_max_request_size: u32,
10283

10384
/// Set the the maximum RPC response payload size for both HTTP and WS in megabytes.
104-
/// Default is 15MiB.
105-
#[arg(long)]
106-
pub rpc_max_response_size: Option<usize>,
85+
#[arg(long, default_value_t = 15)]
86+
pub rpc_max_response_size: u32,
10787

10888
/// Set the the maximum concurrent subscriptions per connection.
109-
/// Default is 1024.
110-
#[arg(long)]
111-
pub rpc_max_subscriptions_per_connection: Option<usize>,
89+
#[arg(long, default_value_t = 1024)]
90+
pub rpc_max_subscriptions_per_connection: u32,
11291

113-
/// DEPRECATED, IPC support has been removed.
114-
#[arg(long, value_name = "PATH")]
115-
pub ipc_path: Option<String>,
92+
/// Specify JSON-RPC server TCP port.
93+
#[arg(long, value_name = "PORT", default_value_t = 9944)]
94+
pub rpc_port: u16,
11695

117-
/// Specify HTTP RPC server TCP port.
118-
#[arg(long, value_name = "PORT")]
119-
pub rpc_port: Option<u16>,
120-
121-
/// Specify WebSockets RPC server TCP port.
122-
#[arg(long, value_name = "PORT")]
123-
pub ws_port: Option<u16>,
124-
125-
/// Maximum number of WS RPC server connections.
126-
#[arg(long, value_name = "COUNT")]
127-
pub ws_max_connections: Option<usize>,
128-
129-
/// DEPRECATED, this has no affect anymore. Use `rpc_max_response_size` instead.
130-
#[arg(long)]
131-
pub ws_max_out_buffer_capacity: Option<usize>,
96+
/// Maximum number of RPC server connections.
97+
#[arg(long, value_name = "COUNT", default_value_t = 100)]
98+
pub rpc_max_connections: u32,
13299

133100
/// Specify browser Origins allowed to access the HTTP & WS RPC servers.
134101
/// A comma-separated list of origins (protocol://domain or special `null`
@@ -344,8 +311,8 @@ impl CliConfiguration for RunCmd {
344311
Ok(self.no_grandpa)
345312
}
346313

347-
fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
348-
Ok(self.ws_max_connections)
314+
fn rpc_max_connections(&self) -> Result<u32> {
315+
Ok(self.rpc_max_connections)
349316
}
350317

351318
fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
@@ -369,56 +336,33 @@ impl CliConfiguration for RunCmd {
369336
.into())
370337
}
371338

372-
fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
339+
fn rpc_addr(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
373340
let interface = rpc_interface(
374341
self.rpc_external,
375342
self.unsafe_rpc_external,
376343
self.rpc_methods,
377344
self.validator,
378345
)?;
379346

380-
Ok(Some(SocketAddr::new(interface, self.rpc_port.unwrap_or(default_listen_port))))
381-
}
382-
383-
fn rpc_ipc(&self) -> Result<Option<String>> {
384-
Ok(self.ipc_path.clone())
385-
}
386-
387-
fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
388-
let interface = rpc_interface(
389-
self.ws_external,
390-
self.unsafe_ws_external,
391-
self.rpc_methods,
392-
self.validator,
393-
)?;
394-
395-
Ok(Some(SocketAddr::new(interface, self.ws_port.unwrap_or(default_listen_port))))
347+
Ok(Some(SocketAddr::new(interface, self.rpc_port)))
396348
}
397349

398350
fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
399351
Ok(self.rpc_methods.into())
400352
}
401353

402-
fn rpc_max_payload(&self) -> Result<Option<usize>> {
403-
Ok(self.rpc_max_payload)
404-
}
405-
406-
fn rpc_max_request_size(&self) -> Result<Option<usize>> {
354+
fn rpc_max_request_size(&self) -> Result<u32> {
407355
Ok(self.rpc_max_request_size)
408356
}
409357

410-
fn rpc_max_response_size(&self) -> Result<Option<usize>> {
358+
fn rpc_max_response_size(&self) -> Result<u32> {
411359
Ok(self.rpc_max_response_size)
412360
}
413361

414-
fn rpc_max_subscriptions_per_connection(&self) -> Result<Option<usize>> {
362+
fn rpc_max_subscriptions_per_connection(&self) -> Result<u32> {
415363
Ok(self.rpc_max_subscriptions_per_connection)
416364
}
417365

418-
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
419-
Ok(self.ws_max_out_buffer_capacity)
420-
}
421-
422366
fn transaction_pool(&self, is_dev: bool) -> Result<TransactionPoolOptions> {
423367
Ok(self.pool_config.transaction_pool(is_dev))
424368
}
@@ -475,7 +419,7 @@ fn rpc_interface(
475419
) -> Result<IpAddr> {
476420
if is_external && is_validator && rpc_methods != RpcMethods::Unsafe {
477421
return Err(Error::Input(
478-
"--rpc-external and --ws-external options shouldn't be used if the node is running as \
422+
"--rpc-external option shouldn't be used if the node is running as \
479423
a validator. Use `--unsafe-rpc-external` or `--rpc-methods=unsafe` if you understand \
480424
the risks. See the options description for more information."
481425
.to_owned(),

client/cli/src/config.rs

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,13 @@ pub trait DefaultConfigurationValues {
5757
30333
5858
}
5959

60-
/// The port Substrate should listen on for websocket connections.
60+
/// The port Substrate should listen on for JSON-RPC connections.
6161
///
6262
/// By default this is `9944`.
63-
fn rpc_ws_listen_port() -> u16 {
63+
fn rpc_listen_port() -> u16 {
6464
9944
6565
}
6666

67-
/// The port Substrate should listen on for http connections.
68-
///
69-
/// By default this is `9933`.
70-
fn rpc_http_listen_port() -> u16 {
71-
9933
72-
}
73-
7467
/// The port Substrate should listen on for prometheus connections.
7568
///
7669
/// By default this is `9615`.
@@ -302,24 +295,8 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
302295
.unwrap_or_default())
303296
}
304297

305-
/// Get the RPC HTTP address (`None` if disabled).
306-
///
307-
/// By default this is `None`.
308-
fn rpc_http(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
309-
Ok(None)
310-
}
311-
312-
/// Get the RPC IPC path (`None` if disabled).
313-
///
314-
/// By default this is `None`.
315-
fn rpc_ipc(&self) -> Result<Option<String>> {
316-
Ok(None)
317-
}
318-
319-
/// Get the RPC websocket address (`None` if disabled).
320-
///
321-
/// By default this is `None`.
322-
fn rpc_ws(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
298+
/// Get the RPC address.
299+
fn rpc_addr(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
323300
Ok(None)
324301
}
325302

@@ -331,11 +308,9 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
331308
Ok(Default::default())
332309
}
333310

334-
/// Get the RPC websockets maximum connections (`None` if unlimited).
335-
///
336-
/// By default this is `None`.
337-
fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
338-
Ok(None)
311+
/// Get the maximum number of RPC server connections.
312+
fn rpc_max_connections(&self) -> Result<u32> {
313+
Ok(Default::default())
339314
}
340315

341316
/// Get the RPC cors (`None` if disabled)
@@ -345,29 +320,19 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
345320
Ok(Some(Vec::new()))
346321
}
347322

348-
/// Get maximum RPC payload.
349-
fn rpc_max_payload(&self) -> Result<Option<usize>> {
350-
Ok(None)
351-
}
352-
353323
/// Get maximum RPC request payload size.
354-
fn rpc_max_request_size(&self) -> Result<Option<usize>> {
355-
Ok(None)
324+
fn rpc_max_request_size(&self) -> Result<u32> {
325+
Ok(Default::default())
356326
}
357327

358328
/// Get maximum RPC response payload size.
359-
fn rpc_max_response_size(&self) -> Result<Option<usize>> {
360-
Ok(None)
329+
fn rpc_max_response_size(&self) -> Result<u32> {
330+
Ok(Default::default())
361331
}
362332

363333
/// Get maximum number of subscriptions per connection.
364-
fn rpc_max_subscriptions_per_connection(&self) -> Result<Option<usize>> {
365-
Ok(None)
366-
}
367-
368-
/// Get maximum WS output buffer capacity.
369-
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
370-
Ok(None)
334+
fn rpc_max_subscriptions_per_connection(&self) -> Result<u32> {
335+
Ok(Default::default())
371336
}
372337

373338
/// Get the prometheus configuration (`None` if disabled)
@@ -532,18 +497,14 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
532497
wasm_method: self.wasm_method()?,
533498
wasm_runtime_overrides: self.wasm_runtime_overrides(),
534499
execution_strategies: self.execution_strategies(is_dev, is_validator)?,
535-
rpc_http: self.rpc_http(DCV::rpc_http_listen_port())?,
536-
rpc_ws: self.rpc_ws(DCV::rpc_ws_listen_port())?,
537-
rpc_ipc: self.rpc_ipc()?,
500+
rpc_addr: self.rpc_addr(DCV::rpc_listen_port())?,
538501
rpc_methods: self.rpc_methods()?,
539-
rpc_ws_max_connections: self.rpc_ws_max_connections()?,
502+
rpc_max_connections: self.rpc_max_connections()?,
540503
rpc_cors: self.rpc_cors(is_dev)?,
541-
rpc_max_payload: self.rpc_max_payload()?,
542504
rpc_max_request_size: self.rpc_max_request_size()?,
543505
rpc_max_response_size: self.rpc_max_response_size()?,
544506
rpc_id_provider: None,
545507
rpc_max_subs_per_conn: self.rpc_max_subscriptions_per_connection()?,
546-
ws_max_out_buffer_capacity: self.ws_max_out_buffer_capacity()?,
547508
prometheus_config: self
548509
.prometheus_config(DCV::prometheus_listen_port(), &chain_spec)?,
549510
telemetry_endpoints,

client/cli/src/runner.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,14 @@ mod tests {
287287
wasm_method: Default::default(),
288288
wasm_runtime_overrides: None,
289289
execution_strategies: Default::default(),
290-
rpc_http: None,
291-
rpc_ws: None,
292-
rpc_ipc: None,
293-
rpc_ws_max_connections: None,
290+
rpc_addr: None,
291+
rpc_max_connections: Default::default(),
294292
rpc_cors: None,
295293
rpc_methods: Default::default(),
296-
rpc_max_payload: None,
297-
rpc_max_request_size: None,
298-
rpc_max_response_size: None,
299-
rpc_id_provider: None,
300-
rpc_max_subs_per_conn: None,
301-
ws_max_out_buffer_capacity: None,
294+
rpc_max_request_size: Default::default(),
295+
rpc_max_response_size: Default::default(),
296+
rpc_id_provider: Default::default(),
297+
rpc_max_subs_per_conn: Default::default(),
302298
prometheus_config: None,
303299
telemetry_endpoints: None,
304300
default_heap_pages: None,

0 commit comments

Comments
 (0)