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

Merged
merged 10 commits into from
Feb 18, 2025
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 @@ -422,30 +422,22 @@ mod tests {

let res = BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages::from_iter(vec![
"bridge-hub-kusama-bridge-hub-polkadot-headers-and-messages",
"--bridge-hub-kusama-host",
"bridge-hub-kusama-node-collator1",
"--bridge-hub-kusama-port",
"9944",
"--bridge-hub-kusama-uri",
"ws://bridge-hub-kusama-node-collator1:9944",
"--bridge-hub-kusama-signer",
"//Iden",
"--bridge-hub-kusama-transactions-mortality",
"64",
"--kusama-host",
"kusama-alice",
"--kusama-port",
"9944",
"--bridge-hub-polkadot-host",
"bridge-hub-polkadot-collator1",
"--bridge-hub-polkadot-port",
"9944",
"--kusama-uri",
"ws://kusama-alice:9944",
"--bridge-hub-polkadot-uri",
"ws://bridge-hub-polkadot-collator1:9944",
"--bridge-hub-polkadot-signer",
"//George",
"--bridge-hub-polkadot-transactions-mortality",
"64",
"--polkadot-host",
"polkadot-alice",
"--polkadot-port",
"9944",
"--polkadot-uri",
"ws://polkadot-alice:9944",
"--lane",
"0000000000000000000000000000000000000000000000000000000000000000",
"--prometheus-host",
Expand All @@ -467,11 +459,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 +474,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 +497,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
Original file line number Diff line number Diff line change
Expand Up @@ -131,53 +131,25 @@ function init_ro_wnd() {

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path init-bridge rococo-to-bridge-hub-westend \
--source-host localhost \
--source-port 9942 \
--source-version-mode Auto \
--target-host localhost \
--target-port 8945 \
--target-version-mode Auto \
--target-signer //Bob
--source-uri ws://localhost:9942 \
--source-version-mode Auto \
--target-uri ws://localhost:8945 \
--target-version-mode Auto \
--target-signer //Bob
}

function init_wnd_ro() {
local relayer_path=$(ensure_relayer)

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path init-bridge westend-to-bridge-hub-rococo \
--source-host localhost \
--source-port 9945 \
--source-uri ws://localhost:9945 \
--source-version-mode Auto \
--target-host localhost \
--target-port 8943 \
--target-uri ws://localhost:8943 \
--target-version-mode Auto \
--target-signer //Bob
}

function run_relay() {
local relayer_path=$(ensure_relayer)

RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
$relayer_path relay-headers-and-messages bridge-hub-rococo-bridge-hub-westend \
--rococo-host localhost \
--rococo-port 9942 \
--rococo-version-mode Auto \
--bridge-hub-rococo-host localhost \
--bridge-hub-rococo-port 8943 \
--bridge-hub-rococo-version-mode Auto \
--bridge-hub-rococo-signer //Charlie \
--bridge-hub-rococo-transactions-mortality 4 \
--westend-host localhost \
--westend-port 9945 \
--westend-version-mode Auto \
--bridge-hub-westend-host localhost \
--bridge-hub-westend-port 8945 \
--bridge-hub-westend-version-mode Auto \
--bridge-hub-westend-signer //Charlie \
--bridge-hub-westend-transactions-mortality 4 \
--lane "${LANE_ID}"
}

function run_finality_relay() {
local relayer_path=$(ensure_relayer)

Expand Down
7 changes: 0 additions & 7 deletions bridges/testing/scripts/start-relayer.sh

This file was deleted.

Loading