Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

rpc server: break legacy CLI options and remove "backward compatible HTTP server" #13384

Merged
merged 29 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8c9d435
jsonrpsee v0.16
niklasad1 Nov 9, 2022
7c01e06
breaking: remove old CLI configs
niklasad1 Nov 9, 2022
08a957d
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Jan 3, 2023
2078002
remove patch.crates-io
niklasad1 Jan 3, 2023
bff77f4
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Feb 14, 2023
17e90a7
fix bad merge
niklasad1 Feb 14, 2023
10d60cc
fix clippy
niklasad1 Feb 14, 2023
1912055
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Mar 20, 2023
fb0ac35
fix bad merge
niklasad1 Mar 20, 2023
160e492
fix grumbles
niklasad1 Mar 30, 2023
e3c4d29
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Mar 30, 2023
ecace8e
Update client/service/src/lib.rs
niklasad1 Mar 30, 2023
0d6760a
revert block_in_place
niklasad1 Mar 30, 2023
226a8ea
add issue link in todo
niklasad1 Mar 31, 2023
ecdedf3
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Mar 31, 2023
064e52e
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Apr 12, 2023
c6934d1
Update client/cli/src/config.rs
niklasad1 Apr 12, 2023
3a0b1ec
grumbles: add ipv6 loopback address
niklasad1 Apr 12, 2023
7856c92
Revert "grumbles: add ipv6 loopback address"
niklasad1 Apr 12, 2023
be0485c
remove nits
niklasad1 Apr 12, 2023
e0f1880
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 Apr 26, 2023
964f146
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 May 2, 2023
cdc97de
bump zombienet version
pepoviola May 2, 2023
c2a9a0d
adress grumbles: provide structopt default_val_t
niklasad1 May 2, 2023
b7347e1
Merge remote-tracking branch 'origin/na-rpc-cli-break-everything' int…
niklasad1 May 2, 2023
cee7789
remove duplicate from structopt
niklasad1 May 2, 2023
1d0a3b9
Merge remote-tracking branch 'origin/master' into na-rpc-cli-break-ev…
niklasad1 May 2, 2023
5b62603
bump zombienet v1.3.47
niklasad1 May 3, 2023
9f1e259
bump zombienet version
pepoviola May 3, 2023
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
8 changes: 2 additions & 6 deletions bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,14 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
offchain_worker: execution_strategy,
other: execution_strategy,
},
rpc_http: None,
rpc_ws: None,
rpc_ipc: None,
rpc_ws_max_connections: None,
rpc_addr: None,
rpc_max_connections: None,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_max_request_size: None,
rpc_max_response_size: None,
rpc_id_provider: None,
rpc_max_subs_per_conn: None,
ws_max_out_buffer_capacity: None,
prometheus_config: None,
telemetry_endpoints: None,
default_heap_pages: None,
Expand Down
8 changes: 2 additions & 6 deletions bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,14 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
offchain_worker: sc_client_api::ExecutionStrategy::NativeWhenPossible,
other: sc_client_api::ExecutionStrategy::NativeWhenPossible,
},
rpc_http: None,
rpc_ws: None,
rpc_ipc: None,
rpc_ws_max_connections: None,
rpc_addr: None,
rpc_max_connections: None,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_max_request_size: None,
rpc_max_response_size: None,
rpc_id_provider: None,
rpc_max_subs_per_conn: None,
ws_max_out_buffer_capacity: None,
prometheus_config: None,
telemetry_endpoints: None,
default_heap_pages: None,
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn extract_info_from_output(read: impl Read + Send) -> (NodeInfo, String) {
data.push_str("\n");

// does the line contain our port (we expect this specific output from substrate).
let sock_addr = match line.split_once("Running JSON-RPC WS server: addr=") {
let sock_addr = match line.split_once("Running JSON-RPC server: addr=") {
None => return None,
Some((_, after)) => after.split_once(",").unwrap().0,
};
Expand Down
65 changes: 5 additions & 60 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,6 @@ pub struct RunCmd {
)]
pub rpc_methods: RpcMethods,

/// Listen to all Websocket interfaces.
///
/// Default is local. Note: not all RPC methods are safe to be exposed publicly. Use an RPC
/// proxy server to filter out dangerous methods. More details:
/// <https://docs.substrate.io/main-docs/build/custom-rpc/#public-rpcs>.
/// Use `--unsafe-ws-external` to suppress the warning if you understand the risks.
#[arg(long)]
pub ws_external: bool,

/// Listen to all Websocket interfaces.
///
/// Same as `--ws-external` but doesn't warn you about it.
#[arg(long)]
pub unsafe_ws_external: bool,

/// DEPRECATED, this has no affect anymore. Use `rpc_max_request_size` or
/// `rpc_max_response_size` instead.
#[arg(long)]
pub rpc_max_payload: Option<usize>,

/// Set the the maximum RPC request payload size for both HTTP and WS in megabytes.
/// Default is 15MiB.
#[arg(long)]
Expand All @@ -122,25 +102,13 @@ pub struct RunCmd {
#[arg(long)]
pub prometheus_external: bool,

/// DEPRECATED, IPC support has been removed.
#[arg(long, value_name = "PATH")]
pub ipc_path: Option<String>,

/// Specify HTTP RPC server TCP port.
/// Specify JSON-RPC server TCP port.
#[arg(long, value_name = "PORT")]
pub rpc_port: Option<u16>,

/// Specify WebSockets RPC server TCP port.
#[arg(long, value_name = "PORT")]
pub ws_port: Option<u16>,

/// Maximum number of WS RPC server connections.
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
#[arg(long, value_name = "COUNT")]
pub ws_max_connections: Option<usize>,

/// DEPRECATED, this has no affect anymore. Use `rpc_max_response_size` instead.
#[arg(long)]
pub ws_max_out_buffer_capacity: Option<usize>,
pub rpc_max_connections: Option<usize>,

/// Specify browser Origins allowed to access the HTTP & WS RPC servers.
///
Expand Down Expand Up @@ -394,8 +362,8 @@ impl CliConfiguration for RunCmd {
Ok(self.no_grandpa)
}

fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
Ok(self.ws_max_connections)
fn rpc_max_connections(&self) -> Result<Option<usize>> {
Ok(self.rpc_max_connections)
}

fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
Expand All @@ -419,7 +387,7 @@ impl CliConfiguration for RunCmd {
.into())
}

fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
let interface = rpc_interface(
self.rpc_external,
self.unsafe_rpc_external,
Expand All @@ -430,29 +398,10 @@ impl CliConfiguration for RunCmd {
Ok(Some(SocketAddr::new(interface, self.rpc_port.unwrap_or(default_listen_port))))
}

fn rpc_ipc(&self) -> Result<Option<String>> {
Ok(self.ipc_path.clone())
}

fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
let interface = rpc_interface(
self.ws_external,
self.unsafe_ws_external,
self.rpc_methods,
self.validator,
)?;

Ok(Some(SocketAddr::new(interface, self.ws_port.unwrap_or(default_listen_port))))
}

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

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

fn rpc_max_request_size(&self) -> Result<Option<usize>> {
Ok(self.rpc_max_request_size)
}
Expand All @@ -465,10 +414,6 @@ impl CliConfiguration for RunCmd {
Ok(self.rpc_max_subscriptions_per_connection)
}

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

fn transaction_pool(&self, is_dev: bool) -> Result<TransactionPoolOptions> {
Ok(self.pool_config.transaction_pool(is_dev))
}
Expand Down
49 changes: 7 additions & 42 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,13 @@ pub trait DefaultConfigurationValues {
30333
}

/// The port Substrate should listen on for websocket connections.
/// The port Substrate should listen on for JSON-RPC connections.
///
/// By default this is `9944`.
fn rpc_ws_listen_port() -> u16 {
fn rpc_listen_port() -> u16 {
9944
}

/// The port Substrate should listen on for http connections.
///
/// By default this is `9933`.
fn rpc_http_listen_port() -> u16 {
9933
}

/// The port Substrate should listen on for prometheus connections.
///
/// By default this is `9615`.
Expand Down Expand Up @@ -302,24 +295,10 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
.unwrap_or_default())
}

/// Get the RPC HTTP address (`None` if disabled).
///
/// By default this is `None`.
fn rpc_http(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
Ok(None)
}

/// Get the RPC IPC path (`None` if disabled).
/// Get the RPC address (`None` if disabled).
///
/// By default this is `None`.
fn rpc_ipc(&self) -> Result<Option<String>> {
Ok(None)
}

/// Get the RPC websocket address (`None` if disabled).
///
/// By default this is `None`.
fn rpc_ws(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
fn rpc_addr(&self, _default_listen_port: u16) -> Result<Option<SocketAddr>> {
Ok(None)
}

Expand All @@ -334,7 +313,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
/// Get the RPC websockets maximum connections (`None` if unlimited).
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
///
/// By default this is `None`.
fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
fn rpc_max_connections(&self) -> Result<Option<usize>> {
Ok(None)
}

Expand All @@ -345,11 +324,6 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(Some(Vec::new()))
}

/// Get maximum RPC payload.
fn rpc_max_payload(&self) -> Result<Option<usize>> {
Ok(None)
}

/// Get maximum RPC request payload size.
fn rpc_max_request_size(&self) -> Result<Option<usize>> {
Ok(None)
Expand All @@ -365,11 +339,6 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(None)
}

/// Get maximum WS output buffer capacity.
fn ws_max_out_buffer_capacity(&self) -> Result<Option<usize>> {
Ok(None)
}

/// Get the prometheus configuration (`None` if disabled)
///
/// By default this is `None`.
Expand Down Expand Up @@ -533,18 +502,14 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
wasm_method: self.wasm_method()?,
wasm_runtime_overrides: self.wasm_runtime_overrides(),
execution_strategies: self.execution_strategies(is_dev, is_validator)?,
rpc_http: self.rpc_http(DCV::rpc_http_listen_port())?,
rpc_ws: self.rpc_ws(DCV::rpc_ws_listen_port())?,
rpc_ipc: self.rpc_ipc()?,
rpc_addr: self.rpc_addr(DCV::rpc_listen_port())?,
rpc_methods: self.rpc_methods()?,
rpc_ws_max_connections: self.rpc_ws_max_connections()?,
rpc_max_connections: self.rpc_max_connections()?,
rpc_cors: self.rpc_cors(is_dev)?,
rpc_max_payload: self.rpc_max_payload()?,
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: 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)?,
telemetry_endpoints,
Expand Down
8 changes: 2 additions & 6 deletions client/cli/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,14 @@ mod tests {
wasm_method: Default::default(),
wasm_runtime_overrides: None,
execution_strategies: Default::default(),
rpc_http: None,
rpc_ws: None,
rpc_ipc: None,
rpc_ws_max_connections: None,
rpc_addr: None,
rpc_max_connections: None,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_max_request_size: None,
rpc_max_response_size: None,
rpc_id_provider: None,
rpc_max_subs_per_conn: None,
ws_max_out_buffer_capacity: None,
prometheus_config: None,
telemetry_endpoints: None,
default_heap_pages: None,
Expand Down
Loading