Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into na-sgx-hello-world
Browse files Browse the repository at this point in the history
* master:
  Ensure the listen addresses are consistent with the transport (#6436)
  client/network/service: Add primary dimension to connection metrics (#6472)
  `pallet-scheduler`: Check that `when` is not in the past (#6480)
  bound some missing bound for elevated trait (#6487)
  Fix the browser node and ensure it doesn't colour the informant output (#6457)
  Fix `sp-api` handling of multiple arguments (#6484)
  impl Debug for sc_service::Configuration (#6400)
  Remove lingering runtime upgrades (#6476)
  Optimize offchain worker api by re-using http-client (#6454)
  Implement nested storage transactions (#6269)
  Avoid panic on dropping a `sc_network::service::out_events::Receiver`. (#6458)
  network: remove unused variable (#6460)
  [CI] Don't tag PRs on companion job cancels (#6470)
  update collective events docs to be consistent with changes (#6463)
  `pallet-staking`: Expose missing consts (#6456)
  Fix issues with `Operational` transactions validity and prioritization. (#6435)
  pallet-atomic-swap: generialized swap action (#6421)
  node: spawn block authoring and grandpa voter as blocking tasks (#6446)
  change everything to transaction (#6440)
  • Loading branch information
dvdplm committed Jun 23, 2020
2 parents 2e8f570 + d59281f commit 47b794b
Show file tree
Hide file tree
Showing 63 changed files with 2,346 additions and 1,041 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/polkadot-companion-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Monitor the status of the gitlab-check-companion-build job
uses: s3krit/await-status-action@4528ebbdf6e29bbec77c41caad1b2dec148ba894
uses: s3krit/await-status-action@v1.0.1
id: 'check-companion-status'
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha }}
contexts: 'continuous-integration/gitlab-check-polkadot-companion-build'
timeout: 1800
notPresentTimeout: 3600 # It can take quite a while before the job starts...
failedStates: failure
interruptedStates: error # Error = job was probably cancelled. We don't want to label the PR in that case
- name: Label success
uses: andymckay/labeler@master
if: steps.check-companion-status.outputs.result == 'success'
Expand Down
31 changes: 22 additions & 9 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr

// the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it.
service.spawn_essential_task("aura", aura);
service.spawn_essential_task_handle().spawn_blocking("aura", aura);
}

// if the node isn't actively participating in consensus then it doesn't
Expand Down Expand Up @@ -184,7 +184,7 @@ pub fn new_full(config: Configuration) -> Result<impl AbstractService, ServiceEr

// the GRANDPA voter task is considered infallible, i.e.
// if it fails we take down the service with it.
service.spawn_essential_task(
service.spawn_essential_task_handle().spawn_blocking(
"grandpa-voter",
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?
);
Expand Down
6 changes: 3 additions & 3 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ macro_rules! new_full {
};

let babe = sc_consensus_babe::start_babe(babe_config)?;
service.spawn_essential_task("babe-proposer", babe);
service.spawn_essential_task_handle().spawn_blocking("babe-proposer", babe);
}

// Spawn authority discovery module.
Expand Down Expand Up @@ -250,7 +250,7 @@ macro_rules! new_full {
service.prometheus_registry(),
);

service.spawn_task("authority-discovery", authority_discovery);
service.spawn_task_handle().spawn("authority-discovery", authority_discovery);
}

// if the node isn't actively participating in consensus then it doesn't
Expand Down Expand Up @@ -292,7 +292,7 @@ macro_rules! new_full {

// the GRANDPA voter task is considered infallible, i.e.
// if it fails we take down the service with it.
service.spawn_essential_task(
service.spawn_essential_task_handle().spawn_blocking(
"grandpa-voter",
grandpa::run_grandpa_voter(grandpa_config)?
);
Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 253,
spec_version: 254,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
6 changes: 6 additions & 0 deletions client/chain-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,9 @@ pub trait ChainSpec: BuildStorage + Send {
/// This will be used as storage at genesis.
fn set_storage(&mut self, storage: Storage);
}

impl std::fmt::Debug for dyn ChainSpec {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "ChainSpec(name = {:?}, id = {:?})", self.name(), self.id())
}
}
10 changes: 4 additions & 6 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ use names::{Generator, Name};
use sc_client_api::execution_extensions::ExecutionStrategies;
use sc_service::config::{
BasePath, Configuration, DatabaseConfig, ExtTransport, KeystoreConfig, NetworkConfiguration,
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods, TaskType,
TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods,
TaskExecutor, TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
};
use sc_service::{ChainSpec, TracingReceiver};
use std::future::Future;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::pin::Pin;
use std::sync::Arc;

/// The maximum number of characters for a node name.
pub(crate) const NODE_NAME_MAX_LENGTH: usize = 32;
Expand Down Expand Up @@ -409,7 +406,7 @@ pub trait CliConfiguration: Sized {
fn create_configuration<C: SubstrateCli>(
&self,
cli: &C,
task_executor: Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>, TaskType) + Send + Sync>,
task_executor: TaskExecutor,
) -> Result<Configuration> {
let is_dev = self.is_dev()?;
let chain_id = self.chain_id(is_dev)?;
Expand Down Expand Up @@ -477,6 +474,7 @@ pub trait CliConfiguration: Sized {
announce_block: self.announce_block()?,
role,
base_path: Some(base_path),
informant_output_format: Default::default(),
})
}

Expand Down
7 changes: 2 additions & 5 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ use log::info;
pub use params::*;
use regex::Regex;
pub use runner::*;
use sc_service::{ChainSpec, Configuration, TaskType};
use std::future::Future;
use sc_service::{ChainSpec, Configuration, TaskExecutor};
use std::io::Write;
use std::pin::Pin;
use std::sync::Arc;
pub use structopt;
use structopt::{
clap::{self, AppSettings},
Expand Down Expand Up @@ -199,7 +196,7 @@ pub trait SubstrateCli: Sized {
fn create_configuration<T: CliConfiguration>(
&self,
command: &T,
task_executor: Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>, TaskType) + Send + Sync>,
task_executor: TaskExecutor,
) -> error::Result<Configuration> {
command.create_configuration(self, task_executor)
}
Expand Down
26 changes: 12 additions & 14 deletions client/cli/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sc_service::{AbstractService, Configuration, Role, ServiceBuilderCommand, Ta
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sp_utils::metrics::{TOKIO_THREADS_ALIVE, TOKIO_THREADS_TOTAL};
use sp_version::RuntimeVersion;
use std::{fmt::Debug, marker::PhantomData, str::FromStr, sync::Arc};
use std::{fmt::Debug, marker::PhantomData, str::FromStr};

#[cfg(target_family = "unix")]
async fn main<F, E>(func: F) -> std::result::Result<(), Box<dyn std::error::Error>>
Expand Down Expand Up @@ -119,23 +119,21 @@ impl<C: SubstrateCli> Runner<C> {
let tokio_runtime = build_runtime()?;
let runtime_handle = tokio_runtime.handle().clone();

let task_executor = Arc::new(
move |fut, task_type| {
match task_type {
TaskType::Async => { runtime_handle.spawn(fut); }
TaskType::Blocking => {
runtime_handle.spawn( async move {
// `spawn_blocking` is looking for the current runtime, and as such has to be called
// from within `spawn`.
tokio::task::spawn_blocking(move || futures::executor::block_on(fut))
});
}
let task_executor = move |fut, task_type| {
match task_type {
TaskType::Async => { runtime_handle.spawn(fut); }
TaskType::Blocking => {
runtime_handle.spawn(async move {
// `spawn_blocking` is looking for the current runtime, and as such has to
// be called from within `spawn`.
tokio::task::spawn_blocking(move || futures::executor::block_on(fut))
});
}
}
);
};

Ok(Runner {
config: command.create_configuration(cli, task_executor)?,
config: command.create_configuration(cli, task_executor.into())?,
tokio_runtime,
phantom: PhantomData,
})
Expand Down
2 changes: 1 addition & 1 deletion client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub struct DatabaseSettings {
}

/// Where to find the database..
#[derive(Clone)]
#[derive(Debug, Clone)]
pub enum DatabaseSettingsSrc {
/// Load a RocksDB database from a given path. Recommended for most uses.
RocksDb {
Expand Down
29 changes: 26 additions & 3 deletions client/informant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,37 @@ use parking_lot::Mutex;
mod display;

/// The format to print telemetry output in.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct OutputFormat {
/// Enable color output in logs.
/// Enable color output in logs. True by default.
pub enable_color: bool,
/// Add a prefix before every log line
/// Defines the informant's prefix for the logs. An empty string by default.
///
/// By default substrate will show logs without a prefix. Example:
///
/// ```text
/// 2020-05-28 15:11:06 ✨ Imported #2 (0xc21c…2ca8)
/// 2020-05-28 15:11:07 💤 Idle (0 peers), best: #2 (0xc21c…2ca8), finalized #0 (0x7299…e6df), ⬇ 0 ⬆ 0
/// ```
///
/// But you can define a prefix by setting this string. This will output:
///
/// ```text
/// 2020-05-28 15:11:06 ✨ [Prefix] Imported #2 (0xc21c…2ca8)
/// 2020-05-28 15:11:07 💤 [Prefix] Idle (0 peers), best: #2 (0xc21c…2ca8), finalized #0 (0x7299…e6df), ⬇ 0 ⬆ 0
/// ```
pub prefix: String,
}

impl Default for OutputFormat {
fn default() -> Self {
Self {
enable_color: true,
prefix: String::new(),
}
}
}

/// Marker trait for a type that implements `TransactionPool` and `MallocSizeOf` on `not(target_os = "unknown")`.
#[cfg(target_os = "unknown")]
pub trait TransactionPoolAndMaybeMallogSizeOf: TransactionPool {}
Expand Down
15 changes: 14 additions & 1 deletion client/network/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

//! Substrate network possible errors.

use crate::config::TransportConfig;
use libp2p::{PeerId, Multiaddr};

use std::fmt;
Expand Down Expand Up @@ -48,7 +49,18 @@ pub enum Error {
second_id: PeerId,
},
/// Prometheus metrics error.
Prometheus(prometheus_endpoint::PrometheusError)
Prometheus(prometheus_endpoint::PrometheusError),
/// The network addresses are invalid because they don't match the transport.
#[display(
fmt = "The following addresses are invalid because they don't match the transport: {:?}",
addresses,
)]
AddressesForAnotherTransport {
/// Transport used.
transport: TransportConfig,
/// The invalid addresses.
addresses: Vec<Multiaddr>,
},
}

// Make `Debug` use the `Display` implementation.
Expand All @@ -65,6 +77,7 @@ impl std::error::Error for Error {
Error::Client(ref err) => Some(err),
Error::DuplicateBootnode { .. } => None,
Error::Prometheus(ref err) => Some(err),
Error::AddressesForAnotherTransport { .. } => None,
}
}
}
Loading

0 comments on commit 47b794b

Please sign in to comment.