Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridges: Remove obsolete relayer CLI args: host, port, path, secure #7549

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 1 addition & 15 deletions bridges/relays/client-substrate/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,7 @@ impl<C: Chain> RpcClient<C> {
params: &ConnectionParams,
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<WsClient>)> {
let tokio = tokio::runtime::Runtime::new()?;
let uri = match params.uri {
Some(ref uri) => uri.clone(),
None => {
format!(
"{}://{}:{}{}",
if params.secure { "wss" } else { "ws" },
params.host,
params.port,
match params.path {
Some(ref path) => format!("/{}", path),
None => String::new(),
},
)
},
};
let uri = params.uri.clone();
log::info!(target: "bridge", "Connecting to {} node at {}", C::NAME, uri);

let client = tokio
Expand Down
19 changes: 3 additions & 16 deletions bridges/relays/client-substrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,16 @@ pub use bp_runtime::{
/// Substrate-over-websocket connection params.
#[derive(Debug, Clone)]
pub struct ConnectionParams {
/// Websocket endpoint URL. Overrides all other URL components (`host`, `port`, `path` and
/// `secure`).
pub uri: Option<String>,
/// Websocket server host name.
pub host: String,
/// Websocket server TCP port.
pub port: u16,
/// Websocket endpoint path at server.
pub path: Option<String>,
/// Use secure websocket connection.
pub secure: bool,
/// Websocket endpoint URL.
pub uri: String,
/// Defined chain runtime version
pub chain_runtime_version: ChainRuntimeVersion,
}

impl Default for ConnectionParams {
fn default() -> Self {
ConnectionParams {
uri: None,
host: "localhost".into(),
port: 9944,
path: None,
secure: false,
uri: "ws://localhost:9944".into(),
chain_runtime_version: ChainRuntimeVersion::Auto,
}
}
Expand Down
20 changes: 2 additions & 18 deletions bridges/relays/lib-substrate-relay/src/cli/chain_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,9 @@ macro_rules! declare_chain_connection_params_cli_schema {
#[doc = $chain " connection params."]
#[derive(StructOpt, Debug, PartialEq, Eq, Clone)]
pub struct [<$chain ConnectionParams>] {
#[doc = "WS endpoint of " $chain ": full URI. Overrides all other connection string components (host, port, path, secure)."]
#[doc = "WS endpoint of " $chain ": full URI."]
#[structopt(long)]
pub [<$chain_prefix _uri>]: Option<String>,
#[doc = "WS endpoint of " $chain ": host component."]
#[structopt(long, default_value = "127.0.0.1")]
pub [<$chain_prefix _host>]: String,
#[doc = "WS endpoint of " $chain ": port component."]
#[structopt(long, default_value = "9944")]
pub [<$chain_prefix _port>]: u16,
#[doc = "WS endpoint of " $chain ": path component."]
#[structopt(long)]
pub [<$chain_prefix _path>]: Option<String>,
#[doc = "Use secure websocket connection."]
#[structopt(long)]
pub [<$chain_prefix _secure>]: bool,
pub [<$chain_prefix _uri>]: String,
#[doc = "Custom runtime version"]
#[structopt(flatten)]
pub [<$chain_prefix _runtime_version>]: [<$chain RuntimeVersionParams>],
Expand All @@ -129,10 +117,6 @@ macro_rules! declare_chain_connection_params_cli_schema {
.into_runtime_version(Chain::RUNTIME_VERSION)?;
Ok(relay_substrate_client::new(relay_substrate_client::ConnectionParams {
uri: self.[<$chain_prefix _uri>],
host: self.[<$chain_prefix _host>],
port: self.[<$chain_prefix _port>],
path: self.[<$chain_prefix _path>],
secure: self.[<$chain_prefix _secure>],
chain_runtime_version,
})
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,7 @@ mod tests {
},
},
left: BridgeHubKusamaConnectionParams {
bridge_hub_kusama_uri: None,
bridge_hub_kusama_host: "bridge-hub-kusama-node-collator1".into(),
bridge_hub_kusama_port: 9944,
bridge_hub_kusama_path: None,
bridge_hub_kusama_secure: false,
bridge_hub_kusama_uri: "ws://bridge-hub-kusama-node-collator1:9944".into(),
bridge_hub_kusama_runtime_version: BridgeHubKusamaRuntimeVersionParams {
bridge_hub_kusama_version_mode: RuntimeVersionType::Bundle,
bridge_hub_kusama_spec_version: None,
Expand All @@ -486,23 +482,15 @@ mod tests {
bridge_hub_kusama_transactions_mortality: Some(64),
},
left_relay: KusamaConnectionParams {
kusama_uri: None,
kusama_host: "kusama-alice".into(),
kusama_port: 9944,
kusama_path: None,
kusama_secure: false,
kusama_uri: "ws://kusama-alice:9944".into(),
kusama_runtime_version: KusamaRuntimeVersionParams {
kusama_version_mode: RuntimeVersionType::Bundle,
kusama_spec_version: None,
kusama_transaction_version: None,
},
},
right: BridgeHubPolkadotConnectionParams {
bridge_hub_polkadot_uri: None,
bridge_hub_polkadot_host: "bridge-hub-polkadot-collator1".into(),
bridge_hub_polkadot_port: 9944,
bridge_hub_polkadot_path: None,
bridge_hub_polkadot_secure: false,
bridge_hub_polkadot_uri: "ws://bridge-hub-polkadot-collator1:9944".into(),
bridge_hub_polkadot_runtime_version: BridgeHubPolkadotRuntimeVersionParams {
bridge_hub_polkadot_version_mode: RuntimeVersionType::Bundle,
bridge_hub_polkadot_spec_version: None,
Expand All @@ -517,11 +505,7 @@ mod tests {
bridge_hub_polkadot_transactions_mortality: Some(64),
},
right_relay: PolkadotConnectionParams {
polkadot_uri: None,
polkadot_host: "polkadot-alice".into(),
polkadot_port: 9944,
polkadot_path: None,
polkadot_secure: false,
polkadot_uri: "ws://polkadot-alice:9944".into(),
polkadot_runtime_version: PolkadotRuntimeVersionParams {
polkadot_version_mode: RuntimeVersionType::Bundle,
polkadot_spec_version: None,
Expand Down
Loading