mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 09:51:10 +00:00
Some relayer improvments (#2902)
* added CLI arguments: full WS URI + separate for WS path URI component + additional log * URI -> URL? * added TODO * fmt
This commit is contained in:
committed by
Bastian Köcher
parent
30a0338717
commit
018d6d8d1a
@@ -264,12 +264,22 @@ impl<C: Chain> Client<C> {
|
|||||||
params: &ConnectionParams,
|
params: &ConnectionParams,
|
||||||
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<RpcClient>)> {
|
) -> Result<(Arc<tokio::runtime::Runtime>, Arc<RpcClient>)> {
|
||||||
let tokio = tokio::runtime::Runtime::new()?;
|
let tokio = tokio::runtime::Runtime::new()?;
|
||||||
let uri = format!(
|
|
||||||
"{}://{}:{}",
|
let uri = match params.uri {
|
||||||
if params.secure { "wss" } else { "ws" },
|
Some(ref uri) => uri.clone(),
|
||||||
params.host,
|
None => {
|
||||||
params.port,
|
format!(
|
||||||
);
|
"{}://{}:{}{}",
|
||||||
|
if params.secure { "wss" } else { "ws" },
|
||||||
|
params.host,
|
||||||
|
params.port,
|
||||||
|
match params.path {
|
||||||
|
Some(ref path) => format!("/{}", path),
|
||||||
|
None => String::new(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
};
|
||||||
log::info!(target: "bridge", "Connecting to {} node at {}", C::NAME, uri);
|
log::info!(target: "bridge", "Connecting to {} node at {}", C::NAME, uri);
|
||||||
|
|
||||||
let client = tokio
|
let client = tokio
|
||||||
|
|||||||
@@ -57,10 +57,15 @@ pub use bp_runtime::{
|
|||||||
/// Substrate-over-websocket connection params.
|
/// Substrate-over-websocket connection params.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ConnectionParams {
|
pub struct ConnectionParams {
|
||||||
|
/// Websocket endpoint URL. Overrides all other URL components (`host`, `port`, `path` and
|
||||||
|
/// `secure`).
|
||||||
|
pub uri: Option<String>,
|
||||||
/// Websocket server host name.
|
/// Websocket server host name.
|
||||||
pub host: String,
|
pub host: String,
|
||||||
/// Websocket server TCP port.
|
/// Websocket server TCP port.
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
|
/// Websocket endpoint path at server.
|
||||||
|
pub path: Option<String>,
|
||||||
/// Use secure websocket connection.
|
/// Use secure websocket connection.
|
||||||
pub secure: bool,
|
pub secure: bool,
|
||||||
/// Defined chain runtime version
|
/// Defined chain runtime version
|
||||||
@@ -70,8 +75,10 @@ pub struct ConnectionParams {
|
|||||||
impl Default for ConnectionParams {
|
impl Default for ConnectionParams {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ConnectionParams {
|
ConnectionParams {
|
||||||
|
uri: None,
|
||||||
host: "localhost".into(),
|
host: "localhost".into(),
|
||||||
port: 9944,
|
port: 9944,
|
||||||
|
path: None,
|
||||||
secure: false,
|
secure: false,
|
||||||
chain_runtime_version: ChainRuntimeVersion::Auto,
|
chain_runtime_version: ChainRuntimeVersion::Auto,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,15 +92,24 @@ macro_rules! declare_chain_runtime_version_params_cli_schema {
|
|||||||
macro_rules! declare_chain_connection_params_cli_schema {
|
macro_rules! declare_chain_connection_params_cli_schema {
|
||||||
($chain:ident, $chain_prefix:ident) => {
|
($chain:ident, $chain_prefix:ident) => {
|
||||||
bp_runtime::paste::item! {
|
bp_runtime::paste::item! {
|
||||||
|
// TODO: https://github.com/paritytech/parity-bridges-common/issues/2909
|
||||||
|
// remove all obsolete arguments (separate URI components)
|
||||||
|
|
||||||
#[doc = $chain " connection params."]
|
#[doc = $chain " connection params."]
|
||||||
#[derive(StructOpt, Debug, PartialEq, Eq, Clone)]
|
#[derive(StructOpt, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct [<$chain ConnectionParams>] {
|
pub struct [<$chain ConnectionParams>] {
|
||||||
#[doc = "Connect to " $chain " node at given host."]
|
#[doc = "WS endpoint of " $chain ": full URI. Overrides all other connection string components (host, port, path, secure)."]
|
||||||
|
#[structopt(long)]
|
||||||
|
pub [<$chain_prefix _uri>]: Option<String>,
|
||||||
|
#[doc = "WS endpoint of " $chain ": host component."]
|
||||||
#[structopt(long, default_value = "127.0.0.1")]
|
#[structopt(long, default_value = "127.0.0.1")]
|
||||||
pub [<$chain_prefix _host>]: String,
|
pub [<$chain_prefix _host>]: String,
|
||||||
#[doc = "Connect to " $chain " node websocket server at given port."]
|
#[doc = "WS endpoint of " $chain ": port component."]
|
||||||
#[structopt(long, default_value = "9944")]
|
#[structopt(long, default_value = "9944")]
|
||||||
pub [<$chain_prefix _port>]: u16,
|
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."]
|
#[doc = "Use secure websocket connection."]
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
pub [<$chain_prefix _secure>]: bool,
|
pub [<$chain_prefix _secure>]: bool,
|
||||||
@@ -119,8 +128,10 @@ macro_rules! declare_chain_connection_params_cli_schema {
|
|||||||
.[<$chain_prefix _runtime_version>]
|
.[<$chain_prefix _runtime_version>]
|
||||||
.into_runtime_version(Chain::RUNTIME_VERSION)?;
|
.into_runtime_version(Chain::RUNTIME_VERSION)?;
|
||||||
Ok(relay_substrate_client::Client::new(relay_substrate_client::ConnectionParams {
|
Ok(relay_substrate_client::Client::new(relay_substrate_client::ConnectionParams {
|
||||||
|
uri: self.[<$chain_prefix _uri>],
|
||||||
host: self.[<$chain_prefix _host>],
|
host: self.[<$chain_prefix _host>],
|
||||||
port: self.[<$chain_prefix _port>],
|
port: self.[<$chain_prefix _port>],
|
||||||
|
path: self.[<$chain_prefix _path>],
|
||||||
secure: self.[<$chain_prefix _secure>],
|
secure: self.[<$chain_prefix _secure>],
|
||||||
chain_runtime_version,
|
chain_runtime_version,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -425,8 +425,10 @@ mod tests {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
left: BridgeHubKusamaConnectionParams {
|
left: BridgeHubKusamaConnectionParams {
|
||||||
|
bridge_hub_kusama_uri: None,
|
||||||
bridge_hub_kusama_host: "bridge-hub-kusama-node-collator1".into(),
|
bridge_hub_kusama_host: "bridge-hub-kusama-node-collator1".into(),
|
||||||
bridge_hub_kusama_port: 9944,
|
bridge_hub_kusama_port: 9944,
|
||||||
|
bridge_hub_kusama_path: None,
|
||||||
bridge_hub_kusama_secure: false,
|
bridge_hub_kusama_secure: false,
|
||||||
bridge_hub_kusama_runtime_version: BridgeHubKusamaRuntimeVersionParams {
|
bridge_hub_kusama_runtime_version: BridgeHubKusamaRuntimeVersionParams {
|
||||||
bridge_hub_kusama_version_mode: RuntimeVersionType::Bundle,
|
bridge_hub_kusama_version_mode: RuntimeVersionType::Bundle,
|
||||||
@@ -442,8 +444,10 @@ mod tests {
|
|||||||
bridge_hub_kusama_transactions_mortality: Some(64),
|
bridge_hub_kusama_transactions_mortality: Some(64),
|
||||||
},
|
},
|
||||||
left_relay: KusamaConnectionParams {
|
left_relay: KusamaConnectionParams {
|
||||||
|
kusama_uri: None,
|
||||||
kusama_host: "kusama-alice".into(),
|
kusama_host: "kusama-alice".into(),
|
||||||
kusama_port: 9944,
|
kusama_port: 9944,
|
||||||
|
kusama_path: None,
|
||||||
kusama_secure: false,
|
kusama_secure: false,
|
||||||
kusama_runtime_version: KusamaRuntimeVersionParams {
|
kusama_runtime_version: KusamaRuntimeVersionParams {
|
||||||
kusama_version_mode: RuntimeVersionType::Bundle,
|
kusama_version_mode: RuntimeVersionType::Bundle,
|
||||||
@@ -452,8 +456,10 @@ mod tests {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
right: BridgeHubPolkadotConnectionParams {
|
right: BridgeHubPolkadotConnectionParams {
|
||||||
|
bridge_hub_polkadot_uri: None,
|
||||||
bridge_hub_polkadot_host: "bridge-hub-polkadot-collator1".into(),
|
bridge_hub_polkadot_host: "bridge-hub-polkadot-collator1".into(),
|
||||||
bridge_hub_polkadot_port: 9944,
|
bridge_hub_polkadot_port: 9944,
|
||||||
|
bridge_hub_polkadot_path: None,
|
||||||
bridge_hub_polkadot_secure: false,
|
bridge_hub_polkadot_secure: false,
|
||||||
bridge_hub_polkadot_runtime_version: BridgeHubPolkadotRuntimeVersionParams {
|
bridge_hub_polkadot_runtime_version: BridgeHubPolkadotRuntimeVersionParams {
|
||||||
bridge_hub_polkadot_version_mode: RuntimeVersionType::Bundle,
|
bridge_hub_polkadot_version_mode: RuntimeVersionType::Bundle,
|
||||||
@@ -469,8 +475,10 @@ mod tests {
|
|||||||
bridge_hub_polkadot_transactions_mortality: Some(64),
|
bridge_hub_polkadot_transactions_mortality: Some(64),
|
||||||
},
|
},
|
||||||
right_relay: PolkadotConnectionParams {
|
right_relay: PolkadotConnectionParams {
|
||||||
|
polkadot_uri: None,
|
||||||
polkadot_host: "polkadot-alice".into(),
|
polkadot_host: "polkadot-alice".into(),
|
||||||
polkadot_port: 9944,
|
polkadot_port: 9944,
|
||||||
|
polkadot_path: None,
|
||||||
polkadot_secure: false,
|
polkadot_secure: false,
|
||||||
polkadot_runtime_version: PolkadotRuntimeVersionParams {
|
polkadot_runtime_version: PolkadotRuntimeVersionParams {
|
||||||
polkadot_version_mode: RuntimeVersionType::Bundle,
|
polkadot_version_mode: RuntimeVersionType::Bundle,
|
||||||
|
|||||||
@@ -106,6 +106,13 @@ where
|
|||||||
// parachain head - we simply return `Unavailable`
|
// parachain head - we simply return `Unavailable`
|
||||||
let best_block_number = self.client.best_finalized_header_number().await?;
|
let best_block_number = self.client.best_finalized_header_number().await?;
|
||||||
if is_ancient_block(at_block.number(), best_block_number) {
|
if is_ancient_block(at_block.number(), best_block_number) {
|
||||||
|
log::trace!(
|
||||||
|
target: "bridge",
|
||||||
|
"{} block {:?} is ancient. Cannot prove the {} header there",
|
||||||
|
P::SourceRelayChain::NAME,
|
||||||
|
at_block,
|
||||||
|
P::SourceParachain::NAME,
|
||||||
|
);
|
||||||
return Ok(AvailableHeader::Unavailable)
|
return Ok(AvailableHeader::Unavailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user