Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Lederstrumpf committed Apr 25, 2023
2 parents f9b0da0 + 6f0f5a9 commit 758a169
Show file tree
Hide file tree
Showing 63 changed files with 1,631 additions and 1,061 deletions.
22 changes: 2 additions & 20 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ variables:
DOCKER_OS: "debian:stretch"
ARCH: "x86_64"
CI_IMAGE: "paritytech/ci-linux:production"
BUILDAH_IMAGE: "quay.io/buildah/stable:v1.27"
BUILDAH_IMAGE: "quay.io/buildah/stable:v1.29"
BUILDAH_COMMAND: "buildah --storage-driver overlay2"
RELENG_SCRIPTS_BRANCH: "master"
RUSTY_CACHIER_SINGLE_BRANCH: master
RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true"
Expand Down Expand Up @@ -215,11 +216,6 @@ default:
.zombienet-refs:
extends: .build-refs

.nightly-pipeline:
rules:
# this job runs only on nightly pipeline with the mentioned variable, against `master` branch
- if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "nightly"

.crates-publishing-variables:
variables:
CRATESIO_CRATES_OWNER: parity-crate-owner
Expand Down Expand Up @@ -251,20 +247,6 @@ default:

#### stage: .pre

skip-if-draft:
extends: .kubernetes-env
variables:
CI_IMAGE: "paritytech/tools:latest"
stage: .pre
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
script:
- echo "Commit message is ${CI_COMMIT_MESSAGE}"
- echo "Ref is ${CI_COMMIT_REF_NAME}"
- echo "pipeline source is ${CI_PIPELINE_SOURCE}"
- ./scripts/ci/gitlab/skip_if_draft.sh
allow_failure: true

check-crates-publishing-pipeline:
stage: .pre
extends:
Expand Down
47 changes: 41 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ serde = "1.0.136"
serde_json = "1.0.85"
derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
kvdb = "0.13.0"
kvdb-rocksdb = "0.17.0"
kvdb-rocksdb = "0.18.0"
sp-trie = { version = "7.0.0", path = "../../../primitives/trie" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
Expand Down
121 changes: 26 additions & 95 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
ImportParams, KeystoreParams, NetworkParams, OffchainWorkerParams, SharedParams,
TransactionPoolParams,
},
CliConfiguration,
CliConfiguration, PrometheusParams, RuntimeParams, TelemetryParams,
};
use clap::Parser;
use regex::Regex;
Expand Down Expand Up @@ -116,12 +116,6 @@ pub struct RunCmd {
#[arg(long)]
pub rpc_max_subscriptions_per_connection: Option<usize>,

/// Expose Prometheus exporter on all interfaces.
///
/// Default is local.
#[arg(long)]
pub prometheus_external: bool,

/// DEPRECATED, IPC support has been removed.
#[arg(long, value_name = "PATH")]
pub ipc_path: Option<String>,
Expand Down Expand Up @@ -151,36 +145,23 @@ pub struct RunCmd {
#[arg(long, value_name = "ORIGINS", value_parser = parse_cors)]
pub rpc_cors: Option<Cors>,

/// Specify Prometheus exporter TCP Port.
#[arg(long, value_name = "PORT")]
pub prometheus_port: Option<u16>,

/// Do not expose a Prometheus exporter endpoint.
///
/// Prometheus metric endpoint is enabled by default.
#[arg(long)]
pub no_prometheus: bool,

/// The human-readable name for this node.
///
/// The node name will be reported to the telemetry server, if enabled.
/// It's used as network node name.
#[arg(long, value_name = "NAME")]
pub name: Option<String>,

/// Disable connecting to the Substrate telemetry server.
///
/// Telemetry is on by default on global chains.
#[arg(long)]
pub no_telemetry: bool,
#[allow(missing_docs)]
#[clap(flatten)]
pub telemetry_params: TelemetryParams,

/// The URL of the telemetry server to connect to.
///
/// This flag can be passed multiple times as a means to specify multiple
/// telemetry endpoints. Verbosity levels range from 0-9, with 0 denoting
/// the least verbosity.
/// Expected format is 'URL VERBOSITY', e.g. `--telemetry-url 'wss://foo/bar 0'`.
#[arg(long = "telemetry-url", value_name = "URL VERBOSITY", value_parser = parse_telemetry_endpoints)]
pub telemetry_endpoints: Vec<(String, u8)>,
#[allow(missing_docs)]
#[clap(flatten)]
pub prometheus_params: PrometheusParams,

#[allow(missing_docs)]
#[clap(flatten)]
pub runtime_params: RuntimeParams,

#[allow(missing_docs)]
#[clap(flatten)]
Expand All @@ -202,6 +183,10 @@ pub struct RunCmd {
#[clap(flatten)]
pub pool_config: TransactionPoolParams,

#[allow(missing_docs)]
#[clap(flatten)]
pub keystore_params: KeystoreParams,

/// Shortcut for `--name Alice --validator` with session keys for `Alice` added to keystore.
#[arg(long, conflicts_with_all = &["bob", "charlie", "dave", "eve", "ferdie", "one", "two"])]
pub alice: bool,
Expand Down Expand Up @@ -239,20 +224,6 @@ pub struct RunCmd {
#[arg(long)]
pub force_authoring: bool,

#[allow(missing_docs)]
#[clap(flatten)]
pub keystore_params: KeystoreParams,

/// The size of the instances cache for each runtime.
///
/// The default value is 8 and the values higher than 256 are ignored.
#[arg(long)]
pub max_runtime_instances: Option<usize>,

/// Maximum number of different runtimes that can be cached.
#[arg(long, default_value_t = 2)]
pub runtime_cache_size: u8,

/// Run a temporary node.
///
/// A temporary directory will be created to store the configuration and will be deleted
Expand Down Expand Up @@ -345,11 +316,12 @@ impl CliConfiguration for RunCmd {
&self,
chain_spec: &Box<dyn ChainSpec>,
) -> Result<Option<TelemetryEndpoints>> {
Ok(if self.no_telemetry {
let params = &self.telemetry_params;
Ok(if params.no_telemetry {
None
} else if !self.telemetry_endpoints.is_empty() {
} else if !params.telemetry_endpoints.is_empty() {
Some(
TelemetryEndpoints::new(self.telemetry_endpoints.clone())
TelemetryEndpoints::new(params.telemetry_endpoints.clone())
.map_err(|e| e.to_string())?,
)
} else {
Expand All @@ -361,7 +333,7 @@ impl CliConfiguration for RunCmd {
let keyring = self.get_keyring();
let is_authority = self.validator || is_dev || keyring.is_some();

Ok(if is_authority { sc_service::Role::Authority } else { sc_service::Role::Full })
Ok(if is_authority { Role::Authority } else { Role::Full })
}

fn force_authoring(&self) -> Result<bool> {
Expand All @@ -374,20 +346,9 @@ impl CliConfiguration for RunCmd {
default_listen_port: u16,
chain_spec: &Box<dyn ChainSpec>,
) -> Result<Option<PrometheusConfig>> {
Ok(if self.no_prometheus {
None
} else {
let interface =
if self.prometheus_external { Ipv4Addr::UNSPECIFIED } else { Ipv4Addr::LOCALHOST };

Some(PrometheusConfig::new_with_default_registry(
SocketAddr::new(
interface.into(),
self.prometheus_port.unwrap_or(default_listen_port),
),
chain_spec.id().into(),
))
})
Ok(self
.prometheus_params
.prometheus_config(default_listen_port, chain_spec.id().to_string()))
}

fn disable_grandpa(&self) -> Result<bool> {
Expand Down Expand Up @@ -474,11 +435,11 @@ impl CliConfiguration for RunCmd {
}

fn max_runtime_instances(&self) -> Result<Option<usize>> {
Ok(self.max_runtime_instances.map(|x| x.min(256)))
Ok(Some(self.runtime_params.max_runtime_instances))
}

fn runtime_cache_size(&self) -> Result<u8> {
Ok(self.runtime_cache_size)
Ok(self.runtime_params.runtime_cache_size)
}

fn base_path(&self) -> Result<Option<BasePath>> {
Expand Down Expand Up @@ -546,36 +507,6 @@ fn rpc_interface(
}
}

#[derive(Debug)]
enum TelemetryParsingError {
MissingVerbosity,
VerbosityParsingError(std::num::ParseIntError),
}

impl std::error::Error for TelemetryParsingError {}

impl std::fmt::Display for TelemetryParsingError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TelemetryParsingError::MissingVerbosity => write!(f, "Verbosity level missing"),
TelemetryParsingError::VerbosityParsingError(e) => write!(f, "{}", e),
}
}
}

fn parse_telemetry_endpoints(s: &str) -> std::result::Result<(String, u8), TelemetryParsingError> {
let pos = s.find(' ');
match pos {
None => Err(TelemetryParsingError::MissingVerbosity),
Some(pos_) => {
let url = s[..pos_].to_string();
let verbosity =
s[pos_ + 1..].parse().map_err(TelemetryParsingError::VerbosityParsingError)?;
Ok((url, verbosity))
},
}
}

/// CORS setting
///
/// The type is introduced to overcome `Option<Option<T>>` handling of `clap`.
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/params/keystore_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct KeystoreParams {
pub password_filename: Option<PathBuf>,
}

/// Parse a sercret string, returning a displayable error.
/// Parse a secret string, returning a displayable error.
pub fn secret_string_from_str(s: &str) -> std::result::Result<SecretString, String> {
std::str::FromStr::from_str(s).map_err(|_| "Could not get SecretString".to_string())
}
Expand Down
5 changes: 2 additions & 3 deletions client/cli/src/params/message_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
use crate::error::Error;
use array_bytes::{hex2bytes, hex_bytes2hex_str};
use clap::Parser;
use clap::Args;
use std::io::BufRead;

/// Params to configure how a message should be passed into a command.
#[derive(Parser, Debug, Clone)]
#[derive(Debug, Clone, Args)]
pub struct MessageParams {
/// Message to process. Will be read from STDIN otherwise.
///
/// The message is assumed to be raw bytes per default. Use `--hex` for hex input. Can
/// optionally be prefixed with `0x` in the hex case.
#[arg(long)]
Expand Down
Loading

0 comments on commit 758a169

Please sign in to comment.