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

Commit

Permalink
companion for #13384 (#2417)
Browse files Browse the repository at this point in the history
* companion for #13384

* update rpc cli

* fix missed stuff

* update parachain rpc commands

* update polkadot and substrate deps

* update substrate & polkadot

---------

Co-authored-by: parity-processbot <>
Co-authored-by: muharem <ismailov.m.h@gmail.com>
  • Loading branch information
niklasad1 and muharem committed May 4, 2023
1 parent aa1b87c commit 053f670
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 346 deletions.
514 changes: 257 additions & 257 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 7 additions & 23 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,50 +387,34 @@ impl sc_cli::CliConfiguration for NormalizedRunCmd {
self.base.disable_grandpa()
}

fn rpc_ws_max_connections(&self) -> sc_cli::Result<Option<usize>> {
self.base.rpc_ws_max_connections()
fn rpc_max_connections(&self) -> sc_cli::Result<u32> {
self.base.rpc_max_connections()
}

fn rpc_cors(&self, is_dev: bool) -> sc_cli::Result<Option<Vec<String>>> {
self.base.rpc_cors(is_dev)
}

fn rpc_http(&self, default_listen_port: u16) -> sc_cli::Result<Option<SocketAddr>> {
self.base.rpc_http(default_listen_port)
}

fn rpc_ipc(&self) -> sc_cli::Result<Option<String>> {
self.base.rpc_ipc()
}

fn rpc_ws(&self, default_listen_port: u16) -> sc_cli::Result<Option<SocketAddr>> {
self.base.rpc_ws(default_listen_port)
fn rpc_addr(&self, default_listen_port: u16) -> sc_cli::Result<Option<SocketAddr>> {
self.base.rpc_addr(default_listen_port)
}

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

fn rpc_max_payload(&self) -> sc_cli::Result<Option<usize>> {
self.base.rpc_max_payload()
}

fn rpc_max_request_size(&self) -> sc_cli::Result<Option<usize>> {
fn rpc_max_request_size(&self) -> sc_cli::Result<u32> {
Ok(self.base.rpc_max_request_size)
}

fn rpc_max_response_size(&self) -> sc_cli::Result<Option<usize>> {
fn rpc_max_response_size(&self) -> sc_cli::Result<u32> {
Ok(self.base.rpc_max_response_size)
}

fn rpc_max_subscriptions_per_connection(&self) -> sc_cli::Result<Option<usize>> {
fn rpc_max_subscriptions_per_connection(&self) -> sc_cli::Result<u32> {
Ok(self.base.rpc_max_subscriptions_per_connection)
}

fn ws_max_out_buffer_capacity(&self) -> sc_cli::Result<Option<usize>> {
self.base.ws_max_out_buffer_capacity()
}

fn transaction_pool(&self, is_dev: bool) -> sc_cli::Result<TransactionPoolOptions> {
self.base.transaction_pool(is_dev)
}
Expand Down
22 changes: 5 additions & 17 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,10 @@ impl DefaultConfigurationValues for RelayChainCli {
30334
}

fn rpc_ws_listen_port() -> u16 {
fn rpc_listen_port() -> u16 {
9945
}

fn rpc_http_listen_port() -> u16 {
9934
}

fn prometheus_listen_port() -> u16 {
9616
}
Expand Down Expand Up @@ -362,16 +358,8 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_http(default_listen_port)
}

fn rpc_ipc(&self) -> Result<Option<String>> {
self.base.base.rpc_ipc()
}

fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_ws(default_listen_port)
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_addr(default_listen_port)
}

fn prometheus_config(
Expand Down Expand Up @@ -417,8 +405,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_methods()
}

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

fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
Expand Down
22 changes: 5 additions & 17 deletions polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,14 +976,10 @@ impl DefaultConfigurationValues for RelayChainCli {
30334
}

fn rpc_ws_listen_port() -> u16 {
fn rpc_listen_port() -> u16 {
9945
}

fn rpc_http_listen_port() -> u16 {
9934
}

fn prometheus_listen_port() -> u16 {
9616
}
Expand Down Expand Up @@ -1013,16 +1009,8 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_http(default_listen_port)
}

fn rpc_ipc(&self) -> Result<Option<String>> {
self.base.base.rpc_ipc()
}

fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_ws(default_listen_port)
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
self.base.base.rpc_addr(default_listen_port)
}

fn prometheus_config(
Expand Down Expand Up @@ -1068,8 +1056,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_methods()
}

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

fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
Expand Down
6 changes: 3 additions & 3 deletions polkadot-parachain/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl DerefMut for KillChildOnDrop {
}
}

/// Read the WS address from the output.
/// Read the RPC server address from the output.
///
/// This is hack to get the actual bound sockaddr because
/// substrate assigns a random port if the specified port was already bound.
Expand All @@ -120,7 +120,7 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, 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 All @@ -129,7 +129,7 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) {
})
.unwrap_or_else(|| {
eprintln!("Output:\n{}", data);
panic!("We should get a WebSocket address")
panic!("We should get an address")
});

(ws_url, data)
Expand Down
22 changes: 5 additions & 17 deletions test/service/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,8 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| self.base_path.clone().map(Into::into)))
}

fn rpc_http(&self, default_listen_port: u16) -> CliResult<Option<SocketAddr>> {
self.base.base.rpc_http(default_listen_port)
}

fn rpc_ipc(&self) -> CliResult<Option<String>> {
self.base.base.rpc_ipc()
}

fn rpc_ws(&self, default_listen_port: u16) -> CliResult<Option<SocketAddr>> {
self.base.base.rpc_ws(default_listen_port)
fn rpc_addr(&self, default_listen_port: u16) -> CliResult<Option<SocketAddr>> {
self.base.base.rpc_addr(default_listen_port)
}

fn prometheus_config(
Expand Down Expand Up @@ -204,8 +196,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_methods()
}

fn rpc_ws_max_connections(&self) -> CliResult<Option<usize>> {
self.base.base.rpc_ws_max_connections()
fn rpc_max_connections(&self) -> CliResult<u32> {
self.base.base.rpc_max_connections()
}

fn rpc_cors(&self, is_dev: bool) -> CliResult<Option<Vec<String>>> {
Expand Down Expand Up @@ -249,14 +241,10 @@ impl DefaultConfigurationValues for RelayChainCli {
30334
}

fn rpc_ws_listen_port() -> u16 {
fn rpc_listen_port() -> u16 {
9945
}

fn rpc_http_listen_port() -> u16 {
9934
}

fn prometheus_listen_port() -> u16 {
9616
}
Expand Down
20 changes: 8 additions & 12 deletions test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,18 +745,14 @@ pub fn node_config(
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: Default::default(),
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
rpc_max_request_size: None,
rpc_max_response_size: None,
rpc_max_request_size: Default::default(),
rpc_max_response_size: Default::default(),
rpc_id_provider: None,
rpc_max_subs_per_conn: None,
ws_max_out_buffer_capacity: None,
rpc_max_subs_per_conn: Default::default(),
prometheus_config: None,
telemetry_endpoints: None,
default_heap_pages: None,
Expand Down Expand Up @@ -871,7 +867,7 @@ pub fn run_relay_chain_validator_node(
key: Sr25519Keyring,
storage_update_func: impl Fn(),
boot_nodes: Vec<MultiaddrWithPeerId>,
websocket_port: Option<u16>,
port: Option<u16>,
) -> polkadot_test_service::PolkadotTestNode {
let mut config = polkadot_test_service::node_config(
storage_update_func,
Expand All @@ -881,8 +877,8 @@ pub fn run_relay_chain_validator_node(
true,
);

if let Some(port) = websocket_port {
config.rpc_ws = Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port));
if let Some(port) = port {
config.rpc_addr = Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port));
}

polkadot_test_service::run_validator_node(
Expand Down

0 comments on commit 053f670

Please sign in to comment.