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 ao-approval-distribution-impl
Browse files Browse the repository at this point in the history
* master:
  Companion for sub/7040 (#1719)
  Companion PR for paritytech/substrate#7463 (#1948)
  Bump serde from 1.0.119 to 1.0.120 (#2292)
  • Loading branch information
ordian committed Jan 21, 2021
2 parents 35f622d + 8387af2 commit f42874d
Show file tree
Hide file tree
Showing 24 changed files with 342 additions and 373 deletions.
394 changes: 171 additions & 223 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions cli/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use log::info;
use wasm_bindgen::prelude::*;
use browser_utils::{
Client,
browser_configuration, set_console_error_panic_hook, init_console_log,
browser_configuration, init_logging_and_telemetry, set_console_error_panic_hook,
};

/// Starts the client.
Expand All @@ -29,13 +29,14 @@ pub async fn start_client(chain_spec: String, log_level: String) -> Result<Clien
.map_err(|err| JsValue::from_str(&err.to_string()))
}

async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Box<dyn std::error::Error>> {
async fn start_inner(chain_spec: String, log_directives: String) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
init_console_log(log_level.parse()?)?;
let telemetry_worker = init_logging_and_telemetry(&log_directives)?;

let chain_spec = service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
.map_err(|e| format!("{:?}", e))?;
let config = browser_configuration(chain_spec).await?;
let telemetry_handle = telemetry_worker.handle();
let config = browser_configuration(chain_spec, Some(telemetry_handle)).await?;

info!("Polkadot browser node");
info!(" version {}", config.impl_version);
Expand All @@ -45,7 +46,9 @@ async fn start_inner(chain_spec: String, log_level: String) -> Result<Client, Bo
info!("👤 Role: {}", config.display_role());

// Create the service. This is the most heavy initialization step.
let (task_manager, rpc_handlers) = service::build_light(config).map_err(|e| format!("{:?}", e))?;
let (task_manager, rpc_handlers, _) = service::build_light(config).map_err(|e| format!("{:?}", e))?;

task_manager.spawn_handle().spawn("telemetry", telemetry_worker.run());

Ok(browser_utils::start_client(task_manager, rpc_handlers))
}
14 changes: 4 additions & 10 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn run() -> Result<()> {
let role = config.role.clone();

let task_manager = match role {
Role::Light => service::build_light(config).map(|(task_manager, _)| task_manager),
Role::Light => service::build_light(config).map(|(task_manager, _, _)| task_manager),
_ => service::build_full(
config,
service::IsCollator::No,
Expand Down Expand Up @@ -249,15 +249,9 @@ pub fn run() -> Result<()> {
})?)
},
Some(Subcommand::ValidationWorker(cmd)) => {
let _ = sc_cli::init_logger(
sc_cli::InitLoggerParams {
pattern: "".into(),
tracing_receiver: Default::default(),
tracing_targets: None,
disable_log_reloading: false,
disable_log_color: true,
},
);
let mut builder = sc_cli::GlobalLoggerBuilder::new("");
builder.with_colors(false);
let _ = builder.init();

if cfg!(feature = "browser") || cfg!(target_os = "android") {
Err(sc_cli::Error::Input("Cannot run validation worker in browser".into()).into())
Expand Down
2 changes: 1 addition & 1 deletion node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ futures = "0.3.12"
hex-literal = "0.3.1"
tracing = "0.1.22"
tracing-futures = "0.2.4"
serde = { version = "1.0.119", features = ["derive"] }
serde = { version = "1.0.120", features = ["derive"] }
thiserror = "1.0.23"

# Polkadot
Expand Down
36 changes: 22 additions & 14 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use std::sync::Arc;
use prometheus_endpoint::Registry;
use sc_executor::native_executor_instance;
use service::RpcHandlers;
use telemetry::TelemetryConnectionNotifier;

pub use self::client::{AbstractClient, Client, ClientHandle, ExecuteWithClient, RuntimeApiCollection};
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
Expand Down Expand Up @@ -215,6 +216,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, jaeger_agent: O
babe::BabeLink<Block>
),
grandpa::SharedVoterState,
Option<telemetry::TelemetrySpan>,
)
>,
Error
Expand All @@ -230,7 +232,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, jaeger_agent: O

let inherent_data_providers = inherents::InherentDataProviders::new();

let (client, backend, keystore_container, task_manager) =
let (client, backend, keystore_container, task_manager, telemetry_span) =
service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
let client = Arc::new(client);

Expand Down Expand Up @@ -332,7 +334,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration, jaeger_agent: O
import_queue,
transaction_pool,
inherent_data_providers,
other: (rpc_extensions_builder, import_setup, rpc_setup)
other: (rpc_extensions_builder, import_setup, rpc_setup, telemetry_span)
})
}

Expand Down Expand Up @@ -562,7 +564,7 @@ pub fn new_full<RuntimeApi, Executor>(
import_queue,
transaction_pool,
inherent_data_providers,
other: (rpc_extensions_builder, import_setup, rpc_setup)
other: (rpc_extensions_builder, import_setup, rpc_setup, telemetry_span)
} = new_partial::<RuntimeApi, Executor>(&mut config, jaeger_agent)?;

let prometheus_registry = config.prometheus_registry().cloned();
Expand Down Expand Up @@ -608,11 +610,9 @@ pub fn new_full<RuntimeApi, Executor>(
);
}

let telemetry_connection_sinks = service::TelemetryConnectionSinks::default();

let availability_config = config.database.clone().try_into().map_err(Error::Availability)?;

let rpc_handlers = service::spawn_tasks(service::SpawnTasksParams {
let (rpc_handlers, telemetry_connection_notifier) = service::spawn_tasks(service::SpawnTasksParams {
config,
backend: backend.clone(),
client: client.clone(),
Expand All @@ -623,9 +623,9 @@ pub fn new_full<RuntimeApi, Executor>(
task_manager: &mut task_manager,
on_demand: None,
remote_blockchain: None,
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
network_status_sinks: network_status_sinks.clone(),
system_rpc_tx,
telemetry_span,
})?;

let (block_import, link_half, babe_link) = import_setup;
Expand Down Expand Up @@ -798,7 +798,7 @@ pub fn new_full<RuntimeApi, Executor>(
config,
link: link_half,
network: network.clone(),
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
voting_rule,
prometheus_registry: prometheus_registry.clone(),
shared_voter_state,
Expand All @@ -824,7 +824,11 @@ pub fn new_full<RuntimeApi, Executor>(
}

/// Builds a new service for a light client.
fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManager, RpcHandlers), Error>
fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(
TaskManager,
RpcHandlers,
Option<TelemetryConnectionNotifier>,
), Error>
where
Runtime: 'static + Send + Sync + ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>,
<Runtime as ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>>::RuntimeApi:
Expand All @@ -834,7 +838,7 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
set_prometheus_registry(&mut config)?;
use sc_client_api::backend::RemoteBackend;

let (client, backend, keystore_container, mut task_manager, on_demand) =
let (client, backend, keystore_container, mut task_manager, on_demand, telemetry_span) =
service::new_light_parts::<Block, Runtime, Dispatch>(&config)?;

let select_chain = sc_consensus::LongestChain::new(backend.clone());
Expand Down Expand Up @@ -905,12 +909,11 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage

let rpc_extensions = polkadot_rpc::create_light(light_deps);

let rpc_handlers = service::spawn_tasks(service::SpawnTasksParams {
let (rpc_handlers, telemetry_connection_notifier) = service::spawn_tasks(service::SpawnTasksParams {
on_demand: Some(on_demand),
remote_blockchain: Some(backend.remote_blockchain()),
rpc_extensions_builder: Box::new(service::NoopRpcExtensionBuilder(rpc_extensions)),
task_manager: &mut task_manager,
telemetry_connection_sinks: service::TelemetryConnectionSinks::default(),
config,
keystore: keystore_container.sync_keystore(),
backend,
Expand All @@ -919,11 +922,12 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
network,
network_status_sinks,
system_rpc_tx,
telemetry_span,
})?;

network_starter.start_network();

Ok((task_manager, rpc_handlers))
Ok((task_manager, rpc_handlers, telemetry_connection_notifier))
}

/// Builds a new object suitable for chain operations.
Expand Down Expand Up @@ -959,7 +963,11 @@ pub fn new_chain_ops(mut config: &mut Configuration, jaeger_agent: Option<std::n
}

/// Build a new light node.
pub fn build_light(config: Configuration) -> Result<(TaskManager, RpcHandlers), Error> {
pub fn build_light(config: Configuration) -> Result<(
TaskManager,
RpcHandlers,
Option<TelemetryConnectionNotifier>,
), Error> {
if config.chain_spec.is_rococo() {
new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
} else if config.chain_spec.is_kusama() {
Expand Down
1 change: 1 addition & 0 deletions node/test/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
3 changes: 2 additions & 1 deletion node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub type Client = FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExec
pub use polkadot_service::FullBackend;

/// Create a new full node.
#[sc_cli::prefix_logs_with(config.network.node_name.as_str())]
#[sc_tracing::logging::prefix_logs_with(config.network.node_name.as_str())]
pub fn new_full(
config: Configuration,
is_collator: IsCollator,
Expand Down Expand Up @@ -198,6 +198,7 @@ pub fn node_config(
base_path: Some(base_path),
informant_output_format: Default::default(),
disable_log_reloading: false,
telemetry_handle: None,
}
}

Expand Down
12 changes: 3 additions & 9 deletions node/test/service/tests/build-blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ use sp_keyring::Sr25519Keyring;

#[substrate_test_utils::test]
async fn ensure_test_service_build_blocks(task_executor: TaskExecutor) {
sc_cli::init_logger(
sc_cli::InitLoggerParams {
pattern: "".into(),
tracing_receiver: Default::default(),
tracing_targets: None,
disable_log_reloading: false,
disable_log_color: true,
},
).expect("Sets up logger");
let mut builder = sc_cli::GlobalLoggerBuilder::new("");
builder.with_colors(false);
builder.init().expect("Sets up logger");

let mut alice = run_validator_node(
task_executor.clone(),
Expand Down
12 changes: 3 additions & 9 deletions parachain/test-parachains/adder/collator/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ async fn collating_using_adder_collator(task_executor: sc_service::TaskExecutor)
use futures::join;
use polkadot_primitives::v1::Id as ParaId;

sc_cli::init_logger(
sc_cli::InitLoggerParams {
pattern: "".into(),
tracing_receiver: Default::default(),
tracing_targets: None,
disable_log_reloading: false,
disable_log_color: true,
},
).expect("Sets up logger");
let mut builder = sc_cli::GlobalLoggerBuilder::new("");
builder.with_colors(false);
builder.init().expect("Set up logger");

let para_id = ParaId::from(100);

Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
serde = { version = "1.0.119", optional = true, features = ["derive"] }
serde = { version = "1.0.120", optional = true, features = ["derive"] }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["bit-vec", "derive"] }
primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.119", default-features = false }
serde = { version = "1.0.120", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
static_assertions = "1.1.0"

Expand Down
2 changes: 1 addition & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] }
log = { version = "0.4.13", optional = true }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.119", default-features = false }
serde = { version = "1.0.120", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
static_assertions = "1.1.0"
smallvec = "1.6.1"
Expand Down
25 changes: 17 additions & 8 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,17 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {

parameter_types! {
pub const CandidacyBond: Balance = 1 * DOLLARS;
pub const VotingBond: Balance = 5 * CENTS;
/// Daily council elections.
// 1 storage item created, key size is 32 bytes, value size is 16+16.
pub const VotingBondBase: Balance = deposit(1, 64);
// additional data per vote is 32 bytes (account id).
pub const VotingBondFactor: Balance = deposit(0, 32);
/// Daily council elections
pub const TermDuration: BlockNumber = 24 * HOURS;
pub const DesiredMembers: u32 = 19;
pub const DesiredRunnersUp: u32 = 19;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
}

// Make sure that there are no more than MaxMembers members elected via phragmen.
const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());

Expand All @@ -491,9 +495,9 @@ impl pallet_elections_phragmen::Config for Runtime {
type InitializeMembers = Council;
type CurrencyToVote = frame_support::traits::U128CurrencyToVote;
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type VotingBondBase = VotingBondBase;
type VotingBondFactor = VotingBondFactor;
type LoserCandidate = Treasury;
type BadReport = Treasury;
type KickedMember = Treasury;
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
Expand Down Expand Up @@ -943,10 +947,15 @@ impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
}
}

pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
pub struct PhragmenElectionDepositRuntimeUpgrade;
impl pallet_elections_phragmen::migrations_3_0_0::V2ToV3 for PhragmenElectionDepositRuntimeUpgrade {
type AccountId = AccountId;
type Balance = Balance;
type Module = ElectionsPhragmen;
}
impl frame_support::traits::OnRuntimeUpgrade for PhragmenElectionDepositRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
0
pallet_elections_phragmen::migrations_3_0_0::apply::<Self>(5 * CENTS, DOLLARS)
}
}

Expand Down Expand Up @@ -1052,7 +1061,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
UpgradeSessionKeys,
(UpgradeSessionKeys, PhragmenElectionDepositRuntimeUpgrade)
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down
Loading

0 comments on commit f42874d

Please sign in to comment.