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

Commit

Permalink
Merge remote-tracking branch 'origin/master' into gui-benchmark-child…
Browse files Browse the repository at this point in the history
…trie-tracker
  • Loading branch information
gui1117 committed Aug 19, 2020
2 parents c16b232 + 368903f commit 34ede0b
Show file tree
Hide file tree
Showing 50 changed files with 1,085 additions and 339 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

24 changes: 11 additions & 13 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ impl frame_system::Trait for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemWeightInfo = weights::frame_system::WeightInfo;
}

impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type WeightInfo = ();
type WeightInfo = weights::pallet_utility::WeightInfo;
}

parameter_types! {
Expand Down Expand Up @@ -352,7 +352,7 @@ impl pallet_timestamp::Trait for Runtime {
type Moment = Moment;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
type WeightInfo = weights::pallet_timestamp::WeightInfo;
}

parameter_types! {
Expand Down Expand Up @@ -1130,7 +1130,7 @@ impl_runtime_apis! {
repeat: u32,
extra: bool,
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency issues.
// To get around that, we separated the Session benchmarks into its own crate, which is why
// we need these two lines below.
Expand All @@ -1142,21 +1142,19 @@ impl_runtime_apis! {
impl pallet_offences_benchmarking::Trait for Runtime {}
impl frame_system_benchmarking::Trait for Runtime {}

let whitelist: Vec<Vec<u8>> = vec![
let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
// Total Issuance
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec(),
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
// Execution Phase
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
// Event Count
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
// System Events
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec(),
// Caller 0 Account
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
// Treasury Account
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec(),
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
];

let mut batches = Vec::<BenchmarkBatch>::new();
Expand Down
58 changes: 58 additions & 0 deletions bin/node/runtime/src/weights/frame_system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// This file is part of Substrate.

// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
#![allow(unused_parens)]

use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};

pub struct WeightInfo;
impl frame_system::WeightInfo for WeightInfo {
// WARNING! Some components were not used: ["b"]
fn remark() -> Weight {
(1305000 as Weight)
}
fn set_heap_pages() -> Weight {
(2023000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["d"]
fn set_changes_trie_config() -> Weight {
(10026000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn set_storage(i: u32, ) -> Weight {
(0 as Weight)
.saturating_add((656000 as Weight).saturating_mul(i as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_storage(i: u32, ) -> Weight {
(4327000 as Weight)
.saturating_add((478000 as Weight).saturating_mul(i as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_prefix(p: u32, ) -> Weight {
(8349000 as Weight)
.saturating_add((838000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
}
fn suicide() -> Weight {
(29247000 as Weight)
}
}
3 changes: 3 additions & 0 deletions bin/node/runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@

//! A list of the different weight modules for our runtime.
pub mod frame_system;
pub mod pallet_balances;
pub mod pallet_democracy;
pub mod pallet_timestamp;
pub mod pallet_utility;
34 changes: 34 additions & 0 deletions bin/node/runtime/src/weights/pallet_timestamp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
#![allow(unused_parens)]

use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};

pub struct WeightInfo;
impl pallet_timestamp::WeightInfo for WeightInfo {
// WARNING! Some components were not used: ["t"]
fn set() -> Weight {
(9133000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["t"]
fn on_finalize() -> Weight {
(5915000 as Weight)
}
}
35 changes: 35 additions & 0 deletions bin/node/runtime/src/weights/pallet_utility.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is part of Substrate.

// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};

pub struct WeightInfo;
impl pallet_utility::WeightInfo for WeightInfo {
fn batch(c: u32, ) -> Weight {
(16461000 as Weight)
.saturating_add((1982000 as Weight).saturating_mul(c as Weight))
}
// WARNING! Some components were not used: ["u"]
fn as_derivative() -> Weight {
(4086000 as Weight)
}
}
42 changes: 27 additions & 15 deletions client/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub enum Subcommand {
ExportState(ExportStateCmd),
}

// TODO: move to config.rs?
/// Macro that helps implement CliConfiguration on an enum of subcommand automatically
///
/// # Example
Expand Down Expand Up @@ -189,17 +188,24 @@ macro_rules! substrate_cli_subcommands {

fn network_config(
&self,
chain_spec: &::std::boxed::Box<dyn ::sc_service::ChainSpec>,
chain_spec: &std::boxed::Box<dyn sc_service::ChainSpec>,
is_dev: bool,
net_config_dir: ::std::path::PathBuf,
net_config_dir: std::path::PathBuf,
client_id: &str,
node_name: &str,
node_key: ::sc_service::config::NodeKeyConfig,
node_key: sc_service::config::NodeKeyConfig,
default_listen_port: u16,
) -> $crate::Result<::sc_service::config::NetworkConfiguration> {
match self {
$(
$enum::$variant(cmd) => cmd.network_config(
chain_spec, is_dev, net_config_dir, client_id, node_name, node_key
chain_spec,
is_dev,
net_config_dir,
client_id,
node_name,
node_key,
default_listen_port,
)
),*
}
Expand Down Expand Up @@ -291,15 +297,21 @@ macro_rules! substrate_cli_subcommands {
}
}

fn rpc_http(&self) -> $crate::Result<::std::option::Option<::std::net::SocketAddr>> {
fn rpc_http(
&self,
default_listen_port: u16,
) -> $crate::Result<std::option::Option<std::net::SocketAddr>> {
match self {
$($enum::$variant(cmd) => cmd.rpc_http()),*
$($enum::$variant(cmd) => cmd.rpc_http(default_listen_port)),*
}
}

fn rpc_ws(&self) -> $crate::Result<::std::option::Option<::std::net::SocketAddr>> {
fn rpc_ws(
&self,
default_listen_port: u16,
) -> $crate::Result<std::option::Option<std::net::SocketAddr>> {
match self {
$($enum::$variant(cmd) => cmd.rpc_ws()),*
$($enum::$variant(cmd) => cmd.rpc_ws(default_listen_port)),*
}
}

Expand All @@ -316,23 +328,23 @@ macro_rules! substrate_cli_subcommands {
}

fn rpc_cors(&self, is_dev: bool)
-> $crate::Result<::std::option::Option<::std::vec::Vec<String>>> {
-> $crate::Result<std::option::Option<std::vec::Vec<String>>> {
match self {
$($enum::$variant(cmd) => cmd.rpc_cors(is_dev)),*
}
}

fn prometheus_config(&self)
-> $crate::Result<::std::option::Option<::sc_service::config::PrometheusConfig>> {
fn prometheus_config(&self, default_listen_port: u16)
-> $crate::Result<std::option::Option<sc_service::config::PrometheusConfig>> {
match self {
$($enum::$variant(cmd) => cmd.prometheus_config()),*
$($enum::$variant(cmd) => cmd.prometheus_config(default_listen_port)),*
}
}

fn telemetry_endpoints(
&self,
chain_spec: &Box<dyn ::sc_service::ChainSpec>,
) -> $crate::Result<::std::option::Option<::sc_service::config::TelemetryEndpoints>> {
chain_spec: &Box<dyn sc_service::ChainSpec>,
) -> $crate::Result<std::option::Option<sc_service::config::TelemetryEndpoints>> {
match self {
$($enum::$variant(cmd) => cmd.telemetry_endpoints(chain_spec)),*
}
Expand Down
17 changes: 10 additions & 7 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl CliConfiguration for RunCmd {
Ok(self.shared_params.dev || self.force_authoring)
}

fn prometheus_config(&self) -> Result<Option<PrometheusConfig>> {
fn prometheus_config(&self, default_listen_port: u16) -> Result<Option<PrometheusConfig>> {
Ok(if self.no_prometheus {
None
} else {
Expand All @@ -393,7 +393,10 @@ impl CliConfiguration for RunCmd {
};

Some(PrometheusConfig::new_with_default_registry(
SocketAddr::new(interface.into(), self.prometheus_port.unwrap_or(9615))
SocketAddr::new(
interface.into(),
self.prometheus_port.unwrap_or(default_listen_port),
)
))
})
}
Expand Down Expand Up @@ -427,30 +430,30 @@ impl CliConfiguration for RunCmd {
.into())
}

fn rpc_http(&self) -> Result<Option<SocketAddr>> {
fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
let interface = rpc_interface(
self.rpc_external,
self.unsafe_rpc_external,
self.rpc_methods,
self.validator
)?;

Ok(Some(SocketAddr::new(interface, self.rpc_port.unwrap_or(9933))))
Ok(Some(SocketAddr::new(interface, self.rpc_port.unwrap_or(default_listen_port))))
}

fn rpc_ipc(&self) -> Result<Option<String>> {
Ok(self.ipc_path.clone())
}

fn rpc_ws(&self) -> Result<Option<SocketAddr>> {
fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
let interface = rpc_interface(
self.ws_external,
self.unsafe_ws_external,
self.rpc_methods,
self.validator
self.validator,
)?;

Ok(Some(SocketAddr::new(interface, self.ws_port.unwrap_or(9944))))
Ok(Some(SocketAddr::new(interface, self.ws_port.unwrap_or(default_listen_port))))
}

fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
Expand Down
Loading

0 comments on commit 34ede0b

Please sign in to comment.