diff --git a/clients/runner/src/error.rs b/clients/runner/src/error.rs index b6c0d9780..1b7645a6b 100644 --- a/clients/runner/src/error.rs +++ b/clients/runner/src/error.rs @@ -11,39 +11,39 @@ use url::ParseError as UrlParseError; #[derive(Error, Debug)] pub enum Error { - #[error("CodecError: {0}")] - CodecError(#[from] CodecError), - #[error("System I/O error: {0}")] - IoError(#[from] IoError), - #[error("System command error: {0}")] - OsError(#[from] OsError), - #[error("HTTP request error: {0}")] - HttpError(#[from] ReqwestError), - #[error("UrlParseError: {0}")] - UrlParseError(#[from] UrlParseError), - #[error("SubxtError: {0}")] - SubxtError(#[from] SubxtError), - #[error("Integer conversion error")] - IntegerConversionError, - #[error("A client release has not been downloaded")] - NoDownloadedRelease, - #[error("A child process is already running")] - ChildProcessExists, - #[error("Failed to terminate child process")] - ProcessTerminationFailure, - #[error("Failed to parse the client-type CLI argument")] - ClientTypeParsingError, - #[error("Failed to derive the release name of the vault")] - ClientNameDerivationError, - #[error("Incorrect Checksum")] - IncorrectChecksum, + #[error("CodecError: {0}")] + CodecError(#[from] CodecError), + #[error("System I/O error: {0}")] + IoError(#[from] IoError), + #[error("System command error: {0}")] + OsError(#[from] OsError), + #[error("HTTP request error: {0}")] + HttpError(#[from] ReqwestError), + #[error("UrlParseError: {0}")] + UrlParseError(#[from] UrlParseError), + #[error("SubxtError: {0}")] + SubxtError(#[from] SubxtError), + #[error("Integer conversion error")] + IntegerConversionError, + #[error("A client release has not been downloaded")] + NoDownloadedRelease, + #[error("A child process is already running")] + ChildProcessExists, + #[error("Failed to terminate child process")] + ProcessTerminationFailure, + #[error("Failed to parse the client-type CLI argument")] + ClientTypeParsingError, + #[error("Failed to derive the release name of the vault")] + ClientNameDerivationError, + #[error("Incorrect Checksum")] + IncorrectChecksum, } impl + Sized> From> for Error { - fn from(e: BackoffError) -> Self { - match e { - BackoffError::Permanent(err) => err.into(), - BackoffError::Transient(err) => err.into(), - } - } + fn from(e: BackoffError) -> Self { + match e { + BackoffError::Permanent(err) => err.into(), + BackoffError::Transient(err) => err.into(), + } + } } diff --git a/clients/runner/src/main.rs b/clients/runner/src/main.rs index 2a31ad7a8..163a84ea1 100644 --- a/clients/runner/src/main.rs +++ b/clients/runner/src/main.rs @@ -16,37 +16,38 @@ use crate::runner::{retry_with_log_async, subxt_api, Runner}; #[derive(Parser, Debug, Clone)] #[clap(version, author, about, trailing_var_arg = true)] pub struct Opts { - /// Client to run, one of: vault, oracle, faucet. Default is `vault`. - #[clap(long, default_value = "vault")] - pub client_type: ClientType, + /// Client to run, one of: vault, oracle, faucet. Default is `vault`. + #[clap(long, default_value = "vault")] + pub client_type: ClientType, - /// Parachain websocket URL. - #[clap(long)] - pub parachain_ws: String, + /// Parachain websocket URL. + #[clap(long)] + pub parachain_ws: String, - /// Download path for the client executable. - #[clap(long, default_value = ".")] - pub download_path: PathBuf, + /// Download path for the client executable. + #[clap(long, default_value = ".")] + pub download_path: PathBuf, - /// CLI arguments to pass to the client executable. - pub client_args: Vec, + /// CLI arguments to pass to the client executable. + pub client_args: Vec, } #[tokio::main] async fn main() -> Result<(), Error> { - env_logger::init_from_env( - env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, log::LevelFilter::Info.as_str()), - ); - let opts: Opts = Opts::parse(); - let rpc_client = retry_with_log_async( - || subxt_api(&opts.parachain_ws).into_future().boxed(), - "Error fetching executable".to_string(), - ) - .await?; - log::info!("Connected to the parachain"); - - let runner = Runner::new(rpc_client, opts); - let shutdown_signals = Signals::new([SIGHUP, SIGTERM, SIGINT, SIGQUIT])?; - Runner::run(Box::new(runner), shutdown_signals).await?; - Ok(()) + env_logger::init_from_env( + env_logger::Env::default() + .filter_or(env_logger::DEFAULT_FILTER_ENV, log::LevelFilter::Info.as_str()), + ); + let opts: Opts = Opts::parse(); + let rpc_client = retry_with_log_async( + || subxt_api(&opts.parachain_ws).into_future().boxed(), + "Error fetching executable".to_string(), + ) + .await?; + log::info!("Connected to the parachain"); + + let runner = Runner::new(rpc_client, opts); + let shutdown_signals = Signals::new([SIGHUP, SIGTERM, SIGINT, SIGQUIT])?; + Runner::run(Box::new(runner), shutdown_signals).await?; + Ok(()) } diff --git a/clients/runner/src/runner.rs b/clients/runner/src/runner.rs index 3a3348b75..44caef35d 100644 --- a/clients/runner/src/runner.rs +++ b/clients/runner/src/runner.rs @@ -31,7 +31,7 @@ use async_trait::async_trait; /// Also used as the name of the downloaded executable. #[derive(Debug, Clone)] pub enum ClientType { - Vault + Vault, } impl FromStr for ClientType { @@ -175,10 +175,7 @@ impl Runner { Ok(downloaded_release) } - async fn do_download_binary( - bin_path: PathBuf, - release: ClientRelease, - ) -> Result<(), Error> { + async fn do_download_binary(bin_path: PathBuf, release: ClientRelease) -> Result<(), Error> { let mut file = OpenOptions::new() .read(true) .write(true) @@ -707,7 +704,7 @@ mod tests { } } - //Before running this test, ensure uri and checksum of the test file match! + //Before running this test, ensure uri and checksum of the test file match! #[tokio::test] async fn test_runner_download_binary() { let mut runner = MockRunner::default(); @@ -758,7 +755,6 @@ mod tests { // (`700`). fs::Permissions::from_mode(0o0100700) ); - } #[tokio::test] @@ -792,10 +788,10 @@ mod tests { runner.expect_download_path().return_const(mock_path.clone()); runner.expect_client_type().return_const(client.clone()); let (bin_name, bin_path) = Runner::get_bin_path( - &runner, - "https://downloads.pendulumchain.tech/spacewalk/vault-rococo", - ) - .unwrap(); + &runner, + "https://downloads.pendulumchain.tech/spacewalk/vault-rococo", + ) + .unwrap(); assert_eq!(bin_name, "vault-rococo"); assert_eq!(bin_path, mock_path.join(bin_name)); } @@ -874,7 +870,6 @@ mod tests { .iter() .map(|s| s.to_string()) .collect(); - let mock_downloaded_release = DownloadedRelease { checksum: H256::default(), diff --git a/testchain/runtime/src/lib.rs b/testchain/runtime/src/lib.rs index 15ec78ece..c8c80ad80 100644 --- a/testchain/runtime/src/lib.rs +++ b/testchain/runtime/src/lib.rs @@ -10,7 +10,7 @@ use codec::Encode; pub use dia_oracle::dia::*; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU128, ConstU64, ConstU32, ConstU8, Contains}, + traits::{ConstU128, ConstU32, ConstU64, ConstU8, Contains}, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, IdentityFee, Weight}, PalletId, }; @@ -561,10 +561,10 @@ impl nomination::Config for Runtime { } impl clients_info::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = clients_info::SubstrateWeight; - type MaxNameLength = ConstU32<255>; - type MaxUriLength = ConstU32<255>; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = clients_info::SubstrateWeight; + type MaxNameLength = ConstU32<255>; + type MaxUriLength = ConstU32<255>; } construct_runtime! {