,
/// Transaction pool instance.
pub pool: Arc,
/// The SelectChain Strategy
pub select_chain: SC,
+ /// A copy of the chain spec.
+ pub chain_spec: Box,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// BABE specific dependencies.
pub babe: BabeDeps,
/// GRANDPA specific dependencies.
- pub grandpa: GrandpaDeps,
+ pub grandpa: GrandpaDeps,
}
/// A IO handler that uses all Full RPC extensions.
pub type IoHandler = jsonrpc_core::IoHandler;
/// Instantiate all Full RPC extensions.
-pub fn create_full(
- deps: FullDeps,
+pub fn create_full(
+ deps: FullDeps,
) -> jsonrpc_core::IoHandler where
- C: ProvideRuntimeApi,
- C: HeaderBackend + HeaderMetadata + 'static,
- C: Send + Sync + 'static,
+ C: ProvideRuntimeApi + HeaderBackend + AuxStore +
+ HeaderMetadata + Sync + Send + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi,
C::Api: pallet_contracts_rpc::ContractsRuntimeApi,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi,
@@ -115,6 +121,8 @@ pub fn create_full(
C::Api: BlockBuilder,
P: TransactionPool + 'static,
SC: SelectChain +'static,
+ B: sc_client_api::Backend + Send + Sync + 'static,
+ B::State: sc_client_api::backend::StateBackend>,
{
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use pallet_contracts_rpc::{Contracts, ContractsApi};
@@ -125,6 +133,7 @@ pub fn create_full(
client,
pool,
select_chain,
+ chain_spec,
deny_unsafe,
babe,
grandpa,
@@ -140,6 +149,7 @@ pub fn create_full(
shared_authority_set,
justification_stream,
subscription_executor,
+ finality_provider,
} = grandpa;
io.extend_with(
@@ -157,8 +167,8 @@ pub fn create_full(
io.extend_with(
sc_consensus_babe_rpc::BabeApi::to_delegate(
BabeRpcHandler::new(
- client,
- shared_epoch_changes,
+ client.clone(),
+ shared_epoch_changes.clone(),
keystore,
babe_config,
select_chain,
@@ -169,10 +179,23 @@ pub fn create_full(
io.extend_with(
sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
GrandpaRpcHandler::new(
- shared_authority_set,
+ shared_authority_set.clone(),
shared_voter_state,
justification_stream,
subscription_executor,
+ finality_provider,
+ )
+ )
+ );
+
+ io.extend_with(
+ sc_sync_state_rpc::SyncStateRpcApi::to_delegate(
+ sc_sync_state_rpc::SyncStateRpcHandler::new(
+ chain_spec,
+ client,
+ shared_authority_set,
+ shared_epoch_changes,
+ deny_unsafe,
)
)
);
diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml
index 1195456b0fadadcec4ea4b9debb1f19529ce856e..80c914ff575806c4c11abad01690a58cc7bb7985 100644
--- a/bin/node/runtime/Cargo.toml
+++ b/bin/node/runtime/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "node-runtime"
-version = "2.0.0-rc6"
+version = "2.0.0"
authors = ["Parity Technologies "]
edition = "2018"
build = "build.rs"
@@ -21,73 +21,73 @@ static_assertions = "1.1.0"
hex-literal = { version = "0.3.1", optional = true }
# primitives
-sp-authority-discovery = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/authority-discovery" }
-sp-consensus-babe = { version = "0.8.0-rc6", default-features = false, path = "../../../primitives/consensus/babe" }
-sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "2.0.0-rc6"}
-sp-inherents = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/inherents" }
-node-primitives = { version = "2.0.0-rc6", default-features = false, path = "../primitives" }
-sp-offchain = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/offchain" }
-sp-core = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/core" }
-sp-std = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/std" }
-sp-api = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/api" }
-sp-runtime = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/runtime" }
-sp-staking = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/staking" }
-sp-keyring = { version = "2.0.0-rc6", optional = true, path = "../../../primitives/keyring" }
-sp-session = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/session" }
-sp-transaction-pool = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/transaction-pool" }
-sp-version = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/version" }
+sp-authority-discovery = { version = "2.0.0", default-features = false, path = "../../../primitives/authority-discovery" }
+sp-consensus-babe = { version = "0.8.0", default-features = false, path = "../../../primitives/consensus/babe" }
+sp-block-builder = { path = "../../../primitives/block-builder", default-features = false, version = "2.0.0"}
+sp-inherents = { version = "2.0.0", default-features = false, path = "../../../primitives/inherents" }
+node-primitives = { version = "2.0.0", default-features = false, path = "../primitives" }
+sp-offchain = { version = "2.0.0", default-features = false, path = "../../../primitives/offchain" }
+sp-core = { version = "2.0.0", default-features = false, path = "../../../primitives/core" }
+sp-std = { version = "2.0.0", default-features = false, path = "../../../primitives/std" }
+sp-api = { version = "2.0.0", default-features = false, path = "../../../primitives/api" }
+sp-runtime = { version = "2.0.0", default-features = false, path = "../../../primitives/runtime" }
+sp-staking = { version = "2.0.0", default-features = false, path = "../../../primitives/staking" }
+sp-keyring = { version = "2.0.0", optional = true, path = "../../../primitives/keyring" }
+sp-session = { version = "2.0.0", default-features = false, path = "../../../primitives/session" }
+sp-transaction-pool = { version = "2.0.0", default-features = false, path = "../../../primitives/transaction-pool" }
+sp-version = { version = "2.0.0", default-features = false, path = "../../../primitives/version" }
# frame dependencies
-frame-executive = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/executive" }
-frame-benchmarking = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/benchmarking", optional = true }
-frame-support = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/support" }
-frame-system = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/system" }
-frame-system-benchmarking = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
-frame-system-rpc-runtime-api = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
-pallet-authority-discovery = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/authority-discovery" }
-pallet-authorship = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/authorship" }
-pallet-babe = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/babe" }
-pallet-balances = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/balances" }
-pallet-collective = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/collective" }
-pallet-contracts = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/contracts" }
-pallet-contracts-primitives = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/contracts/common/" }
-pallet-contracts-rpc-runtime-api = { version = "0.8.0-rc6", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" }
-pallet-democracy = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/democracy" }
-pallet-elections-phragmen = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/elections-phragmen" }
-pallet-finality-tracker = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/finality-tracker" }
-pallet-grandpa = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/grandpa" }
-pallet-im-online = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/im-online" }
-pallet-indices = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/indices" }
-pallet-identity = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/identity" }
-pallet-membership = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/membership" }
-pallet-multisig = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/multisig" }
-pallet-offences = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/offences" }
-pallet-offences-benchmarking = { version = "2.0.0-rc6", path = "../../../frame/offences/benchmarking", default-features = false, optional = true }
-pallet-proxy = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/proxy" }
-pallet-randomness-collective-flip = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/randomness-collective-flip" }
-pallet-recovery = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/recovery" }
-pallet-session = { version = "2.0.0-rc6", features = ["historical"], path = "../../../frame/session", default-features = false }
-pallet-session-benchmarking = { version = "2.0.0-rc6", path = "../../../frame/session/benchmarking", default-features = false, optional = true }
-pallet-staking = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/staking" }
-pallet-staking-reward-curve = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/staking/reward-curve" }
-pallet-scheduler = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/scheduler" }
-pallet-society = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/society" }
-pallet-sudo = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/sudo" }
-pallet-timestamp = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/timestamp" }
-pallet-treasury = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/treasury" }
-pallet-utility = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/utility" }
-pallet-transaction-payment = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/transaction-payment" }
-pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" }
-pallet-vesting = { version = "2.0.0-rc6", default-features = false, path = "../../../frame/vesting" }
+frame-executive = { version = "2.0.0", default-features = false, path = "../../../frame/executive" }
+frame-benchmarking = { version = "2.0.0", default-features = false, path = "../../../frame/benchmarking", optional = true }
+frame-support = { version = "2.0.0", default-features = false, path = "../../../frame/support" }
+frame-system = { version = "2.0.0", default-features = false, path = "../../../frame/system" }
+frame-system-benchmarking = { version = "2.0.0", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
+frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
+pallet-authority-discovery = { version = "2.0.0", default-features = false, path = "../../../frame/authority-discovery" }
+pallet-authorship = { version = "2.0.0", default-features = false, path = "../../../frame/authorship" }
+pallet-babe = { version = "2.0.0", default-features = false, path = "../../../frame/babe" }
+pallet-balances = { version = "2.0.0", default-features = false, path = "../../../frame/balances" }
+pallet-collective = { version = "2.0.0", default-features = false, path = "../../../frame/collective" }
+pallet-contracts = { version = "2.0.0", default-features = false, path = "../../../frame/contracts" }
+pallet-contracts-primitives = { version = "2.0.0", default-features = false, path = "../../../frame/contracts/common/" }
+pallet-contracts-rpc-runtime-api = { version = "0.8.0", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" }
+pallet-democracy = { version = "2.0.0", default-features = false, path = "../../../frame/democracy" }
+pallet-elections-phragmen = { version = "2.0.0", default-features = false, path = "../../../frame/elections-phragmen" }
+pallet-grandpa = { version = "2.0.0", default-features = false, path = "../../../frame/grandpa" }
+pallet-im-online = { version = "2.0.0", default-features = false, path = "../../../frame/im-online" }
+pallet-indices = { version = "2.0.0", default-features = false, path = "../../../frame/indices" }
+pallet-identity = { version = "2.0.0", default-features = false, path = "../../../frame/identity" }
+pallet-membership = { version = "2.0.0", default-features = false, path = "../../../frame/membership" }
+pallet-multisig = { version = "2.0.0", default-features = false, path = "../../../frame/multisig" }
+pallet-offences = { version = "2.0.0", default-features = false, path = "../../../frame/offences" }
+pallet-offences-benchmarking = { version = "2.0.0", path = "../../../frame/offences/benchmarking", default-features = false, optional = true }
+pallet-proxy = { version = "2.0.0", default-features = false, path = "../../../frame/proxy" }
+pallet-randomness-collective-flip = { version = "2.0.0", default-features = false, path = "../../../frame/randomness-collective-flip" }
+pallet-recovery = { version = "2.0.0", default-features = false, path = "../../../frame/recovery" }
+pallet-session = { version = "2.0.0", features = ["historical"], path = "../../../frame/session", default-features = false }
+pallet-session-benchmarking = { version = "2.0.0", path = "../../../frame/session/benchmarking", default-features = false, optional = true }
+pallet-staking = { version = "2.0.0", default-features = false, path = "../../../frame/staking" }
+pallet-staking-reward-curve = { version = "2.0.0", default-features = false, path = "../../../frame/staking/reward-curve" }
+pallet-scheduler = { version = "2.0.0", default-features = false, path = "../../../frame/scheduler" }
+pallet-society = { version = "2.0.0", default-features = false, path = "../../../frame/society" }
+pallet-sudo = { version = "2.0.0", default-features = false, path = "../../../frame/sudo" }
+pallet-timestamp = { version = "2.0.0", default-features = false, path = "../../../frame/timestamp" }
+pallet-treasury = { version = "2.0.0", default-features = false, path = "../../../frame/treasury" }
+pallet-utility = { version = "2.0.0", default-features = false, path = "../../../frame/utility" }
+pallet-transaction-payment = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment" }
+pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" }
+pallet-vesting = { version = "2.0.0", default-features = false, path = "../../../frame/vesting" }
[build-dependencies]
-wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" }
+wasm-builder-runner = { version = "2.0.0", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" }
[dev-dependencies]
-sp-io = { version = "2.0.0-rc6", path = "../../../primitives/io" }
+sp-io = { version = "2.0.0", path = "../../../primitives/io" }
[features]
default = ["std"]
+with-tracing = [ "frame-executive/with-tracing" ]
std = [
"sp-authority-discovery/std",
"pallet-authority-discovery/std",
@@ -104,7 +104,6 @@ std = [
"pallet-democracy/std",
"pallet-elections-phragmen/std",
"frame-executive/std",
- "pallet-finality-tracker/std",
"pallet-grandpa/std",
"pallet-im-online/std",
"pallet-indices/std",
diff --git a/bin/node/runtime/build.rs b/bin/node/runtime/build.rs
index a2f09a460e69da62a7ebf410cef5c6420cb09e3d..4f111bc9930078d09f02a1e189e2edcd26c993e4 100644
--- a/bin/node/runtime/build.rs
+++ b/bin/node/runtime/build.rs
@@ -20,7 +20,7 @@ use wasm_builder_runner::WasmBuilder;
fn main() {
WasmBuilder::new()
.with_current_project()
- .with_wasm_builder_from_crates_or_path("2.0.0", "../../../utils/wasm-builder")
+ .with_wasm_builder_from_crates_or_path("2.0.1", "../../../utils/wasm-builder")
.export_heap_base()
.import_memory()
.build()
diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs
index 039093ddee69700594b70200595a39b07f7e7fa4..16666997b3a5597b807296f1b285177216342577 100644
--- a/bin/node/runtime/src/impls.rs
+++ b/bin/node/runtime/src/impls.rs
@@ -17,8 +17,6 @@
//! Some configurable implementations as associated type for the substrate runtime.
-use node_primitives::Balance;
-use sp_runtime::traits::Convert;
use frame_support::traits::{OnUnbalanced, Currency};
use crate::{Balances, Authorship, NegativeImbalance};
@@ -29,26 +27,9 @@ impl OnUnbalanced for Author {
}
}
-/// Struct that handles the conversion of Balance -> `u64`. This is used for staking's election
-/// calculation.
-pub struct CurrencyToVoteHandler;
-
-impl CurrencyToVoteHandler {
- fn factor() -> Balance { (Balances::total_issuance() / u64::max_value() as Balance).max(1) }
-}
-
-impl Convert for CurrencyToVoteHandler {
- fn convert(x: Balance) -> u64 { (x / Self::factor()) as u64 }
-}
-
-impl Convert for CurrencyToVoteHandler {
- fn convert(x: u128) -> Balance { x * Self::factor() }
-}
-
#[cfg(test)]
mod multiplier_tests {
- use super::*;
- use sp_runtime::{assert_eq_error_rate, FixedPointNumber};
+ use sp_runtime::{assert_eq_error_rate, FixedPointNumber, traits::Convert};
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
use crate::{
diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs
index eeac6d83b87776efcba3b4b0fa0e8689db0017a7..dddef0b46a884bb32cdb23e2c1904437eecc7cb0 100644
--- a/bin/node/runtime/src/lib.rs
+++ b/bin/node/runtime/src/lib.rs
@@ -20,24 +20,27 @@
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
-#![recursion_limit="256"]
+#![recursion_limit = "256"]
-use sp_std::prelude::*;
+use sp_std::prelude::*;
use frame_support::{
construct_runtime, parameter_types, debug, RuntimeDebug,
weights::{
Weight, IdentityFee,
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
},
- traits::{Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, Randomness, LockIdentifier},
+ traits::{
+ Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, Randomness, LockIdentifier,
+ U128CurrencyToVote,
+ },
};
use frame_system::{EnsureRoot, EnsureOneOf};
use frame_support::traits::InstanceFilter;
use codec::{Encode, Decode};
use sp_core::{
crypto::KeyTypeId,
- u32_trait::{_1, _2, _3, _4},
+ u32_trait::{_1, _2, _3, _4, _5},
OpaqueMetadata,
};
pub use node_primitives::{AccountId, Signature};
@@ -61,8 +64,7 @@ use pallet_grandpa::fg_primitives;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
-pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
-use pallet_contracts_rpc_runtime_api::ContractExecResult;
+pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, CurrencyAdapter};
use pallet_session::{historical as pallet_session_historical};
use sp_inherents::{InherentData, CheckInherentsResult};
use static_assertions::const_assert;
@@ -78,7 +80,7 @@ pub use pallet_staking::StakerStatus;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub mod impls;
-use impls::{CurrencyToVoteHandler, Author};
+use impls::Author;
/// Constant values used within the runtime.
pub mod constants;
@@ -109,7 +111,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: 259,
+ spec_version: 260,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
@@ -149,9 +151,8 @@ parameter_types! {
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
/// Assume 10% of weight for average on_initialize calls.
- pub MaximumExtrinsicWeight: Weight =
- AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
- * MaximumBlockWeight::get();
+ pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
+ * MaximumBlockWeight::get();
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
pub const Version: RuntimeVersion = VERSION;
}
@@ -179,17 +180,17 @@ impl frame_system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version;
- type ModuleToIndex = ModuleToIndex;
+ type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData;
type OnNewAccount = ();
type OnKilledAccount = ();
- type SystemWeightInfo = weights::frame_system::WeightInfo;
+ type SystemWeightInfo = frame_system::weights::SubstrateWeight;
}
impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
- type WeightInfo = weights::pallet_utility::WeightInfo;
+ type WeightInfo = pallet_utility::weights::SubstrateWeight;
}
parameter_types! {
@@ -207,7 +208,7 @@ impl pallet_multisig::Trait for Runtime {
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
- type WeightInfo = ();
+ type WeightInfo = pallet_multisig::weights::SubstrateWeight;
}
parameter_types! {
@@ -234,13 +235,20 @@ impl InstanceFilter for ProxyType {
fn filter(&self, c: &Call) -> bool {
match self {
ProxyType::Any => true,
- ProxyType::NonTransfer => !matches!(c,
- Call::Balances(..) | Call::Vesting(pallet_vesting::Call::vested_transfer(..))
- | Call::Indices(pallet_indices::Call::transfer(..))
+ ProxyType::NonTransfer => !matches!(
+ c,
+ Call::Balances(..) |
+ Call::Vesting(pallet_vesting::Call::vested_transfer(..)) |
+ Call::Indices(pallet_indices::Call::transfer(..))
),
- ProxyType::Governance => matches!(c,
- Call::Democracy(..) | Call::Council(..) | Call::Society(..)
- | Call::TechnicalCommittee(..) | Call::Elections(..) | Call::Treasury(..)
+ ProxyType::Governance => matches!(
+ c,
+ Call::Democracy(..) |
+ Call::Council(..) |
+ Call::Society(..) |
+ Call::TechnicalCommittee(..) |
+ Call::Elections(..) |
+ Call::Treasury(..)
),
ProxyType::Staking => matches!(c, Call::Staking(..)),
}
@@ -264,7 +272,7 @@ impl pallet_proxy::Trait for Runtime {
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
- type WeightInfo = weights::pallet_proxy::WeightInfo;
+ type WeightInfo = pallet_proxy::weights::SubstrateWeight;
type MaxPending = MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
@@ -273,6 +281,7 @@ impl pallet_proxy::Trait for Runtime {
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
+ pub const MaxScheduledPerBlock: u32 = 50;
}
impl pallet_scheduler::Trait for Runtime {
@@ -282,7 +291,8 @@ impl pallet_scheduler::Trait for Runtime {
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot;
- type WeightInfo = ();
+ type MaxScheduledPerBlock = MaxScheduledPerBlock;
+ type WeightInfo = pallet_scheduler::weights::SubstrateWeight;
}
parameter_types! {
@@ -309,6 +319,8 @@ impl pallet_babe::Trait for Runtime {
type HandleEquivocation =
pallet_babe::EquivocationHandler;
+
+ type WeightInfo = ();
}
parameter_types! {
@@ -320,20 +332,24 @@ impl pallet_indices::Trait for Runtime {
type Currency = Balances;
type Deposit = IndexDeposit;
type Event = Event;
- type WeightInfo = ();
+ type WeightInfo = pallet_indices::weights::SubstrateWeight;
}
parameter_types! {
pub const ExistentialDeposit: Balance = 1 * DOLLARS;
+ // For weight estimation, we assume that the most locks on an individual account will be 50.
+ // This number may need to be adjusted in the future if this assumption no longer holds true.
+ pub const MaxLocks: u32 = 50;
}
impl pallet_balances::Trait for Runtime {
+ type MaxLocks = MaxLocks;
type Balance = Balance;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module;
- type WeightInfo = weights::pallet_balances::WeightInfo;
+ type WeightInfo = pallet_balances::weights::SubstrateWeight;
}
parameter_types! {
@@ -344,8 +360,7 @@ parameter_types! {
}
impl pallet_transaction_payment::Trait for Runtime {
- type Currency = Balances;
- type OnTransactionPayment = DealWithFees;
+ type OnChargeTransaction = CurrencyAdapter;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee;
type FeeMultiplierUpdate =
@@ -360,7 +375,7 @@ impl pallet_timestamp::Trait for Runtime {
type Moment = Moment;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
- type WeightInfo = weights::pallet_timestamp::WeightInfo;
+ type WeightInfo = pallet_timestamp::weights::SubstrateWeight;
}
parameter_types! {
@@ -397,7 +412,7 @@ impl pallet_session::Trait for Runtime {
type SessionHandler = ::KeyTypeIdProviders;
type Keys = SessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
- type WeightInfo = ();
+ type WeightInfo = pallet_session::weights::SubstrateWeight;
}
impl pallet_session::historical::Trait for Runtime {
@@ -421,17 +436,20 @@ parameter_types! {
pub const BondingDuration: pallet_staking::EraIndex = 24 * 28;
pub const SlashDeferDuration: pallet_staking::EraIndex = 24 * 7; // 1/4 the bonding duration.
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
- pub const MaxNominatorRewardedPerValidator: u32 = 64;
+ pub const MaxNominatorRewardedPerValidator: u32 = 256;
pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
pub const MaxIterations: u32 = 10;
// 0.05%. The higher the value, the more strict solution acceptance becomes.
pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
+ pub OffchainSolutionWeightLimit: Weight = MaximumExtrinsicWeight::get()
+ .saturating_sub(BlockExecutionWeight::get())
+ .saturating_sub(ExtrinsicBaseWeight::get());
}
impl pallet_staking::Trait for Runtime {
type Currency = Balances;
type UnixTime = Timestamp;
- type CurrencyToVote = CurrencyToVoteHandler;
+ type CurrencyToVote = U128CurrencyToVote;
type RewardRemainder = Treasury;
type Event = Event;
type Slash = Treasury; // send the slashed funds to the treasury.
@@ -454,7 +472,10 @@ impl pallet_staking::Trait for Runtime {
type MinSolutionScoreBump = MinSolutionScoreBump;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = StakingUnsignedPriority;
- type WeightInfo = ();
+ // The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of
+ // a single extrinsic.
+ type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
+ type WeightInfo = pallet_staking::weights::SubstrateWeight;
}
parameter_types! {
@@ -468,6 +489,7 @@ parameter_types! {
// One cent: $10,000 / MB
pub const PreimageByteDeposit: Balance = 1 * CENTS;
pub const MaxVotes: u32 = 100;
+ pub const MaxProposals: u32 = 100;
}
impl pallet_democracy::Trait for Runtime {
@@ -493,6 +515,14 @@ impl pallet_democracy::Trait for Runtime {
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>;
+ // To cancel a proposal before it has been passed, the technical committee must be unanimous or
+ // Root must agree.
+ type CancelProposalOrigin = EnsureOneOf<
+ AccountId,
+ EnsureRoot,
+ pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>,
+ >;
+ type BlacklistOrigin = EnsureRoot;
// Any single technical committee member may veto a coming council proposal, however they can
// only do it once and it lasts only for the cooloff period.
type VetoOrigin = pallet_collective::EnsureMember;
@@ -503,7 +533,8 @@ impl pallet_democracy::Trait for Runtime {
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
- type WeightInfo = weights::pallet_democracy::WeightInfo;
+ type WeightInfo = pallet_democracy::weights::SubstrateWeight;
+ type MaxProposals = MaxProposals;
}
parameter_types! {
@@ -521,7 +552,7 @@ impl pallet_collective::Trait for Runtime {
type MaxProposals = CouncilMaxProposals;
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
- type WeightInfo = weights::pallet_collective::WeightInfo;
+ type WeightInfo = pallet_collective::weights::SubstrateWeight;
}
parameter_types! {
@@ -544,7 +575,7 @@ impl pallet_elections_phragmen::Trait for Runtime {
// NOTE: this implies that council's genesis members cannot be set directly and must come from
// this module.
type InitializeMembers = Council;
- type CurrencyToVote = CurrencyToVoteHandler;
+ type CurrencyToVote = U128CurrencyToVote;
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type LoserCandidate = ();
@@ -553,7 +584,7 @@ impl pallet_elections_phragmen::Trait for Runtime {
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
- type WeightInfo = ();
+ type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight;
}
parameter_types! {
@@ -571,7 +602,7 @@ impl pallet_collective::Trait for Runtime {
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
- type WeightInfo = weights::pallet_collective::WeightInfo;
+ type WeightInfo = pallet_collective::weights::SubstrateWeight;
}
type EnsureRootOrHalfCouncil = EnsureOneOf<
@@ -598,8 +629,14 @@ parameter_types! {
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
- pub const TipReportDepositPerByte: Balance = 1 * CENTS;
+ pub const DataDepositPerByte: Balance = 1 * CENTS;
+ pub const BountyDepositBase: Balance = 1 * DOLLARS;
+ pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
+ pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
+ pub const MaximumReasonLength: u32 = 16384;
+ pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
+ pub const BountyValueMinimum: Balance = 5 * DOLLARS;
}
impl pallet_treasury::Trait for Runtime {
@@ -608,26 +645,32 @@ impl pallet_treasury::Trait for Runtime {
type ApproveOrigin = EnsureOneOf<
AccountId,
EnsureRoot,
- pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>
+ pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>
>;
type RejectOrigin = EnsureOneOf<
AccountId,
EnsureRoot,
- pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>
+ pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>
>;
type Tippers = Elections;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
- type TipReportDepositPerByte = TipReportDepositPerByte;
+ type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
- type ProposalRejection = ();
+ type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
+ type BountyDepositBase = BountyDepositBase;
+ type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
+ type BountyUpdatePeriod = BountyUpdatePeriod;
+ type BountyCuratorDeposit = BountyCuratorDeposit;
+ type BountyValueMinimum = BountyValueMinimum;
+ type MaximumReasonLength = MaximumReasonLength;
type BurnDestination = ();
- type WeightInfo = ();
+ type WeightInfo = pallet_treasury::weights::SubstrateWeight;
}
parameter_types! {
@@ -654,6 +697,7 @@ impl pallet_contracts::Trait for Runtime {
type MaxDepth = pallet_contracts::DefaultMaxDepth;
type MaxValueSize = pallet_contracts::DefaultMaxValueSize;
type WeightPrice = pallet_transaction_payment::Module;
+ type WeightInfo = weights::pallet_contracts::WeightInfo;
}
impl pallet_sudo::Trait for Runtime {
@@ -732,7 +776,7 @@ impl pallet_im_online::Trait for Runtime {
type SessionDuration = SessionDuration;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority;
- type WeightInfo = ();
+ type WeightInfo = pallet_im_online::weights::SubstrateWeight;
}
parameter_types! {
@@ -744,7 +788,6 @@ impl pallet_offences::Trait for Runtime {
type IdentificationTuple = pallet_session::historical::IdentificationTuple;
type OnOffenceHandler = Staking;
type WeightSoftLimit = OffencesWeightSoftLimit;
- type WeightInfo = ();
}
impl pallet_authority_discovery::Trait for Runtime {}
@@ -765,17 +808,8 @@ impl pallet_grandpa::Trait for Runtime {
type HandleEquivocation =
pallet_grandpa::EquivocationHandler;
-}
-parameter_types! {
- pub const WindowSize: BlockNumber = 101;
- pub const ReportLatency: BlockNumber = 1000;
-}
-
-impl pallet_finality_tracker::Trait for Runtime {
- type OnFinalizationStalled = ();
- type WindowSize = WindowSize;
- type ReportLatency = ReportLatency;
+ type WeightInfo = ();
}
parameter_types! {
@@ -799,7 +833,7 @@ impl pallet_identity::Trait for Runtime {
type Slashed = Treasury;
type ForceOrigin = EnsureRootOrHalfCouncil;
type RegistrarOrigin = EnsureRootOrHalfCouncil;
- type WeightInfo = ();
+ type WeightInfo = pallet_identity::weights::SubstrateWeight;
}
parameter_types! {
@@ -856,7 +890,7 @@ impl pallet_vesting::Trait for Runtime {
type Currency = Balances;
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
- type WeightInfo = ();
+ type WeightInfo = pallet_vesting::weights::SubstrateWeight;
}
construct_runtime!(
@@ -880,10 +914,9 @@ construct_runtime!(
TechnicalCommittee: pallet_collective::::{Module, Call, Storage, Origin, Event, Config},
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event, Config},
TechnicalMembership: pallet_membership::::{Module, Call, Storage, Event, Config},
- FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event},
- Contracts: pallet_contracts::{Module, Call, Config, Storage, Event},
+ Contracts: pallet_contracts::{Module, Call, Config, Storage, Event},
Sudo: pallet_sudo::{Module, Call, Config, Storage, Event},
ImOnline: pallet_im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
@@ -1089,17 +1122,8 @@ impl_runtime_apis! {
value: Balance,
gas_limit: u64,
input_data: Vec,
- ) -> ContractExecResult {
- let (exec_result, gas_consumed) =
- Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);
- match exec_result {
- Ok(v) => ContractExecResult::Success {
- flags: v.flags.bits(),
- data: v.data,
- gas_consumed: gas_consumed,
- },
- Err(_) => ContractExecResult::Error,
- }
+ ) -> pallet_contracts_primitives::ContractExecResult {
+ Contracts::bare_call(origin, dest, value, gas_limit, input_data)
}
fn get_storage(
diff --git a/bin/node/runtime/src/weights/frame_system.rs b/bin/node/runtime/src/weights/frame_system.rs
deleted file mode 100644
index 9522fa75203906ab3c7264154a4b33835375843c..0000000000000000000000000000000000000000
--- a/bin/node/runtime/src/weights/frame_system.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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)
- }
-}
diff --git a/bin/node/runtime/src/weights/mod.rs b/bin/node/runtime/src/weights/mod.rs
index 372b13a093e27183f6cdd60bdb76c94379bc3f60..5de6286da9b71e8db2343633d356e8952c3211e6 100644
--- a/bin/node/runtime/src/weights/mod.rs
+++ b/bin/node/runtime/src/weights/mod.rs
@@ -15,10 +15,4 @@
//! A list of the different weight modules for our runtime.
-pub mod frame_system;
-pub mod pallet_balances;
-pub mod pallet_collective;
-pub mod pallet_democracy;
-pub mod pallet_proxy;
-pub mod pallet_timestamp;
-pub mod pallet_utility;
+pub mod pallet_contracts;
diff --git a/bin/node/runtime/src/weights/pallet_balances.rs b/bin/node/runtime/src/weights/pallet_balances.rs
deleted file mode 100644
index bcbc4ced6ef56895d4c62a31a7b0580ad71b9ecf..0000000000000000000000000000000000000000
--- a/bin/node/runtime/src/weights/pallet_balances.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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
-
-use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
-
-pub struct WeightInfo;
-impl pallet_balances::WeightInfo for WeightInfo {
- fn transfer() -> Weight {
- (65949000 as Weight)
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn transfer_keep_alive() -> Weight {
- (46665000 as Weight)
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn set_balance_creating() -> Weight {
- (27086000 as Weight)
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn set_balance_killing() -> Weight {
- (33424000 as Weight)
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn force_transfer() -> Weight {
- (65343000 as Weight)
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
-}
diff --git a/bin/node/runtime/src/weights/pallet_collective.rs b/bin/node/runtime/src/weights/pallet_collective.rs
deleted file mode 100644
index 32b4ad02d7aa94c8007429b24bef2f062b310036..0000000000000000000000000000000000000000
--- a/bin/node/runtime/src/weights/pallet_collective.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-// 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-rc6
-
-#![allow(unused_parens)]
-#![allow(unused_imports)]
-
-use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
-
-pub struct WeightInfo;
-impl pallet_collective::WeightInfo for WeightInfo {
- fn set_members(m: u32, n: u32, p: u32, ) -> Weight {
- (0 as Weight)
- .saturating_add((21040000 as Weight).saturating_mul(m as Weight))
- .saturating_add((173000 as Weight).saturating_mul(n as Weight))
- .saturating_add((31595000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight)))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
- }
- fn execute(b: u32, m: u32, ) -> Weight {
- (43359000 as Weight)
- .saturating_add((4000 as Weight).saturating_mul(b as Weight))
- .saturating_add((123000 as Weight).saturating_mul(m as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- }
- fn propose_execute(b: u32, m: u32, ) -> Weight {
- (54134000 as Weight)
- .saturating_add((4000 as Weight).saturating_mul(b as Weight))
- .saturating_add((239000 as Weight).saturating_mul(m as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- }
- fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight {
- (90650000 as Weight)
- .saturating_add((5000 as Weight).saturating_mul(b as Weight))
- .saturating_add((152000 as Weight).saturating_mul(m as Weight))
- .saturating_add((970000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(4 as Weight))
- .saturating_add(DbWeight::get().writes(4 as Weight))
- }
- fn vote(m: u32, ) -> Weight {
- (74460000 as Weight)
- .saturating_add((290000 as Weight).saturating_mul(m as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn close_early_disapproved(m: u32, p: u32, ) -> Weight {
- (86360000 as Weight)
- .saturating_add((232000 as Weight).saturating_mul(m as Weight))
- .saturating_add((954000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight {
- (123653000 as Weight)
- .saturating_add((1000 as Weight).saturating_mul(b as Weight))
- .saturating_add((287000 as Weight).saturating_mul(m as Weight))
- .saturating_add((920000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(4 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn close_disapproved(m: u32, p: u32, ) -> Weight {
- (95395000 as Weight)
- .saturating_add((236000 as Weight).saturating_mul(m as Weight))
- .saturating_add((965000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(4 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn close_approved(b: u32, m: u32, p: u32, ) -> Weight {
- (135284000 as Weight)
- .saturating_add((4000 as Weight).saturating_mul(b as Weight))
- .saturating_add((218000 as Weight).saturating_mul(m as Weight))
- .saturating_add((951000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(5 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn disapprove_proposal(p: u32, ) -> Weight {
- (50500000 as Weight)
- .saturating_add((966000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
-}
diff --git a/bin/node/runtime/src/weights/pallet_contracts.rs b/bin/node/runtime/src/weights/pallet_contracts.rs
new file mode 100644
index 0000000000000000000000000000000000000000..8cd97b4a72191c7ca450676b298729a49dcd0689
--- /dev/null
+++ b/bin/node/runtime/src/weights/pallet_contracts.rs
@@ -0,0 +1,294 @@
+// This file is part of Substrate.
+
+// 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.
+
+//! Weights for pallet_contracts
+//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
+//! DATE: 2020-10-06, STEPS: [50], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
+
+#![allow(unused_parens)]
+#![allow(unused_imports)]
+
+use frame_support::{traits::Get, weights::Weight};
+use sp_std::marker::PhantomData;
+
+pub struct WeightInfo(PhantomData);
+impl pallet_contracts::WeightInfo for WeightInfo {
+ fn update_schedule() -> Weight {
+ (33_207_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ }
+ fn put_code(n: u32, ) -> Weight {
+ (0 as Weight)
+ .saturating_add((144_833_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
+ }
+ fn instantiate(n: u32, ) -> Weight {
+ (223_974_000 as Weight)
+ .saturating_add((1_007_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(6 as Weight))
+ .saturating_add(T::DbWeight::get().writes(3 as Weight))
+ }
+ fn call() -> Weight {
+ (210_638_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
+ }
+ fn claim_surcharge() -> Weight {
+ (508_079_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(3 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
+ }
+ fn seal_caller(r: u32, ) -> Weight {
+ (143_336_000 as Weight)
+ .saturating_add((397_788_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_address(r: u32, ) -> Weight {
+ (147_296_000 as Weight)
+ .saturating_add((396_962_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_gas_left(r: u32, ) -> Weight {
+ (141_677_000 as Weight)
+ .saturating_add((393_308_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_balance(r: u32, ) -> Weight {
+ (157_556_000 as Weight)
+ .saturating_add((879_861_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ }
+ fn seal_value_transferred(r: u32, ) -> Weight {
+ (148_867_000 as Weight)
+ .saturating_add((391_678_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_minimum_balance(r: u32, ) -> Weight {
+ (147_252_000 as Weight)
+ .saturating_add((393_977_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_tombstone_deposit(r: u32, ) -> Weight {
+ (144_208_000 as Weight)
+ .saturating_add((394_625_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_rent_allowance(r: u32, ) -> Weight {
+ (135_320_000 as Weight)
+ .saturating_add((925_541_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_block_number(r: u32, ) -> Weight {
+ (145_849_000 as Weight)
+ .saturating_add((390_065_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_now(r: u32, ) -> Weight {
+ (146_363_000 as Weight)
+ .saturating_add((391_772_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_weight_to_fee(r: u32, ) -> Weight {
+ (129_872_000 as Weight)
+ .saturating_add((670_744_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ }
+ fn seal_gas(r: u32, ) -> Weight {
+ (130_985_000 as Weight)
+ .saturating_add((198_427_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_input(r: u32, ) -> Weight {
+ (138_647_000 as Weight)
+ .saturating_add((8_363_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_input_per_kb(n: u32, ) -> Weight {
+ (149_418_000 as Weight)
+ .saturating_add((272_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_return(r: u32, ) -> Weight {
+ (129_116_000 as Weight)
+ .saturating_add((5_745_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_return_per_kb(n: u32, ) -> Weight {
+ (139_601_000 as Weight)
+ .saturating_add((680_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_terminate(r: u32, ) -> Weight {
+ (138_548_000 as Weight)
+ .saturating_add((355_473_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(r as Weight)))
+ .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_restore_to(r: u32, ) -> Weight {
+ (239_880_000 as Weight)
+ .saturating_add((138_305_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(r as Weight)))
+ .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_restore_to_per_delta(d: u32, ) -> Weight {
+ (40_572_000 as Weight)
+ .saturating_add((3_748_632_000 as Weight).saturating_mul(d as Weight))
+ .saturating_add(T::DbWeight::get().reads(7 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(d as Weight)))
+ .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ .saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(d as Weight)))
+ }
+ fn seal_random(r: u32, ) -> Weight {
+ (148_156_000 as Weight)
+ .saturating_add((1_036_452_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ }
+ fn seal_deposit_event(r: u32, ) -> Weight {
+ (176_039_000 as Weight)
+ .saturating_add((1_497_705_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight {
+ (1_923_547_000 as Weight)
+ .saturating_add((783_354_000 as Weight).saturating_mul(t as Weight))
+ .saturating_add((240_600_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(t as Weight)))
+ .saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(t as Weight)))
+ }
+ fn seal_set_rent_allowance(r: u32, ) -> Weight {
+ (151_095_000 as Weight)
+ .saturating_add((1_104_696_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ }
+ fn seal_set_storage(r: u32, ) -> Weight {
+ (0 as Weight)
+ .saturating_add((14_975_467_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_set_storage_per_kb(n: u32, ) -> Weight {
+ (2_465_724_000 as Weight)
+ .saturating_add((203_125_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
+ }
+ fn seal_clear_storage(r: u32, ) -> Weight {
+ (0 as Weight)
+ .saturating_add((5_254_595_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_get_storage(r: u32, ) -> Weight {
+ (60_303_000 as Weight)
+ .saturating_add((1_135_486_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_get_storage_per_kb(n: u32, ) -> Weight {
+ (931_900_000 as Weight)
+ .saturating_add((144_572_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ }
+ fn seal_transfer(r: u32, ) -> Weight {
+ (50_722_000 as Weight)
+ .saturating_add((6_701_164_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_call(r: u32, ) -> Weight {
+ (0 as Weight)
+ .saturating_add((10_589_747_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight {
+ (11_223_388_000 as Weight)
+ .saturating_add((4_965_182_000 as Weight).saturating_mul(t as Weight))
+ .saturating_add((50_603_000 as Weight).saturating_mul(i as Weight))
+ .saturating_add((72_972_000 as Weight).saturating_mul(o as Weight))
+ .saturating_add(T::DbWeight::get().reads(105 as Weight))
+ .saturating_add(T::DbWeight::get().reads((101 as Weight).saturating_mul(t as Weight)))
+ .saturating_add(T::DbWeight::get().writes((101 as Weight).saturating_mul(t as Weight)))
+ }
+ fn seal_instantiate(r: u32, ) -> Weight {
+ (0 as Weight)
+ .saturating_add((22_933_938_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(6 as Weight))
+ .saturating_add(T::DbWeight::get().reads((300 as Weight).saturating_mul(r as Weight)))
+ .saturating_add(T::DbWeight::get().writes(2 as Weight))
+ .saturating_add(T::DbWeight::get().writes((200 as Weight).saturating_mul(r as Weight)))
+ }
+ fn seal_instantiate_per_input_output_kb(i: u32, o: u32, ) -> Weight {
+ (20_986_307_000 as Weight)
+ .saturating_add((152_611_000 as Weight).saturating_mul(i as Weight))
+ .saturating_add((73_457_000 as Weight).saturating_mul(o as Weight))
+ .saturating_add(T::DbWeight::get().reads(207 as Weight))
+ .saturating_add(T::DbWeight::get().writes(202 as Weight))
+ }
+ fn seal_hash_sha2_256(r: u32, ) -> Weight {
+ (145_988_000 as Weight)
+ .saturating_add((343_540_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight {
+ (719_758_000 as Weight)
+ .saturating_add((420_306_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_keccak_256(r: u32, ) -> Weight {
+ (116_261_000 as Weight)
+ .saturating_add((360_601_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight {
+ (583_726_000 as Weight)
+ .saturating_add((333_091_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_blake2_256(r: u32, ) -> Weight {
+ (144_609_000 as Weight)
+ .saturating_add((332_388_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight {
+ (612_987_000 as Weight)
+ .saturating_add((150_030_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_blake2_128(r: u32, ) -> Weight {
+ (142_085_000 as Weight)
+ .saturating_add((329_426_000 as Weight).saturating_mul(r as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+ fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight {
+ (632_517_000 as Weight)
+ .saturating_add((149_974_000 as Weight).saturating_mul(n as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ }
+}
diff --git a/bin/node/runtime/src/weights/pallet_democracy.rs b/bin/node/runtime/src/weights/pallet_democracy.rs
deleted file mode 100644
index 2c55a848061a393c179614688f18885fd63c2c97..0000000000000000000000000000000000000000
--- a/bin/node/runtime/src/weights/pallet_democracy.rs
+++ /dev/null
@@ -1,155 +0,0 @@
-// 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.
-
-//! Weights for the Democracy Pallet
-//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
-
-use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
-
-pub struct WeightInfo;
-impl pallet_democracy::WeightInfo for WeightInfo {
- fn propose() -> Weight {
- (49113000 as Weight)
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn second(s: u32, ) -> Weight {
- (42067000 as Weight)
- .saturating_add((220000 as Weight).saturating_mul(s as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn vote_new(r: u32, ) -> Weight {
- (54159000 as Weight)
- .saturating_add((252000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn vote_existing(r: u32, ) -> Weight {
- (54145000 as Weight)
- .saturating_add((262000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn emergency_cancel() -> Weight {
- (31071000 as Weight)
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn external_propose(v: u32, ) -> Weight {
- (14282000 as Weight)
- .saturating_add((109000 as Weight).saturating_mul(v as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn external_propose_majority() -> Weight {
- (3478000 as Weight)
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn external_propose_default() -> Weight {
- (3442000 as Weight)
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn fast_track() -> Weight {
- (30820000 as Weight)
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn veto_external(v: u32, ) -> Weight {
- (30971000 as Weight)
- .saturating_add((184000 as Weight).saturating_mul(v as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn cancel_referendum() -> Weight {
- (20431000 as Weight)
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn cancel_queued(r: u32, ) -> Weight {
- (42438000 as Weight)
- .saturating_add((3284000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn on_initialize_base(r: u32, ) -> Weight {
- (70826000 as Weight)
- .saturating_add((10716000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(6 as Weight))
- .saturating_add(DbWeight::get().reads((2 as Weight).saturating_mul(r as Weight)))
- .saturating_add(DbWeight::get().writes(5 as Weight))
- }
- fn delegate(r: u32, ) -> Weight {
- (72046000 as Weight)
- .saturating_add((7837000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(4 as Weight))
- .saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight)))
- .saturating_add(DbWeight::get().writes(4 as Weight))
- .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight)))
- }
- fn undelegate(r: u32, ) -> Weight {
- (41028000 as Weight)
- .saturating_add((7810000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight)))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- .saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight)))
- }
- fn clear_public_proposals() -> Weight {
- (3643000 as Weight)
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn note_preimage(b: u32, ) -> Weight {
- (46629000 as Weight)
- .saturating_add((4000 as Weight).saturating_mul(b as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn note_imminent_preimage(b: u32, ) -> Weight {
- (31147000 as Weight)
- .saturating_add((3000 as Weight).saturating_mul(b as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn reap_preimage(b: u32, ) -> Weight {
- (42848000 as Weight)
- .saturating_add((3000 as Weight).saturating_mul(b as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn unlock_remove(r: u32, ) -> Weight {
- (45333000 as Weight)
- .saturating_add((171000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn unlock_set(r: u32, ) -> Weight {
- (44424000 as Weight)
- .saturating_add((291000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(3 as Weight))
- }
- fn remove_vote(r: u32, ) -> Weight {
- (28250000 as Weight)
- .saturating_add((283000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn remove_other_vote(r: u32, ) -> Weight {
- (28250000 as Weight)
- .saturating_add((283000 as Weight).saturating_mul(r as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
-}
diff --git a/bin/node/runtime/src/weights/pallet_proxy.rs b/bin/node/runtime/src/weights/pallet_proxy.rs
deleted file mode 100644
index 92c43cd4853a215edade20d9b281e20ee8559663..0000000000000000000000000000000000000000
--- a/bin/node/runtime/src/weights/pallet_proxy.rs
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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
-
-use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
-
-pub struct WeightInfo;
-impl pallet_proxy::WeightInfo for WeightInfo {
- fn proxy(p: u32, ) -> Weight {
- (26127000 as Weight)
- .saturating_add((214000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- }
- fn proxy_announced(a: u32, p: u32, ) -> Weight {
- (55405000 as Weight)
- .saturating_add((774000 as Weight).saturating_mul(a as Weight))
- .saturating_add((209000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn remove_announcement(a: u32, p: u32, ) -> Weight {
- (35879000 as Weight)
- .saturating_add((783000 as Weight).saturating_mul(a as Weight))
- .saturating_add((20000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn reject_announcement(a: u32, p: u32, ) -> Weight {
- (36097000 as Weight)
- .saturating_add((780000 as Weight).saturating_mul(a as Weight))
- .saturating_add((12000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn announce(a: u32, p: u32, ) -> Weight {
- (53769000 as Weight)
- .saturating_add((675000 as Weight).saturating_mul(a as Weight))
- .saturating_add((214000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(3 as Weight))
- .saturating_add(DbWeight::get().writes(2 as Weight))
- }
- fn add_proxy(p: u32, ) -> Weight {
- (36082000 as Weight)
- .saturating_add((234000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn remove_proxy(p: u32, ) -> Weight {
- (32885000 as Weight)
- .saturating_add((267000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn remove_proxies(p: u32, ) -> Weight {
- (31735000 as Weight)
- .saturating_add((215000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn anonymous(p: u32, ) -> Weight {
- (50907000 as Weight)
- .saturating_add((61000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(2 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
- fn kill_anonymous(p: u32, ) -> Weight {
- (33926000 as Weight)
- .saturating_add((208000 as Weight).saturating_mul(p as Weight))
- .saturating_add(DbWeight::get().reads(1 as Weight))
- .saturating_add(DbWeight::get().writes(1 as Weight))
- }
-}
diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml
index 89079d53ece4d8d89322c31ddcd69406bd116ad3..bc1f07645eed90de0884781242b008e451665eb7 100644
--- a/bin/node/testing/Cargo.toml
+++ b/bin/node/testing/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "node-testing"
-version = "2.0.0-rc6"
+version = "2.0.0"
authors = ["Parity Technologies "]
description = "Test utilities for Substrate node."
edition = "2018"
@@ -13,39 +13,38 @@ publish = true
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
-pallet-balances = { version = "2.0.0-rc6", path = "../../../frame/balances" }
-sc-service = { version = "0.8.0-rc6", features = ["test-helpers", "db"], path = "../../../client/service" }
-sc-client-db = { version = "0.8.0-rc6", path = "../../../client/db/", features = ["kvdb-rocksdb", "parity-db"] }
-sc-client-api = { version = "2.0.0-rc6", path = "../../../client/api/" }
+pallet-balances = { version = "2.0.0", path = "../../../frame/balances" }
+sc-service = { version = "0.8.0", features = ["test-helpers", "db"], path = "../../../client/service" }
+sc-client-db = { version = "0.8.0", path = "../../../client/db/", features = ["kvdb-rocksdb", "parity-db"] }
+sc-client-api = { version = "2.0.0", path = "../../../client/api/" }
codec = { package = "parity-scale-codec", version = "1.3.4" }
-pallet-contracts = { version = "2.0.0-rc6", path = "../../../frame/contracts" }
-pallet-grandpa = { version = "2.0.0-rc6", path = "../../../frame/grandpa" }
-pallet-indices = { version = "2.0.0-rc6", path = "../../../frame/indices" }
-sp-keyring = { version = "2.0.0-rc6", path = "../../../primitives/keyring" }
-node-executor = { version = "2.0.0-rc6", path = "../executor" }
-node-primitives = { version = "2.0.0-rc6", path = "../primitives" }
-node-runtime = { version = "2.0.0-rc6", path = "../runtime" }
-sp-core = { version = "2.0.0-rc6", path = "../../../primitives/core" }
-sp-io = { version = "2.0.0-rc6", path = "../../../primitives/io" }
-frame-support = { version = "2.0.0-rc6", path = "../../../frame/support" }
-pallet-session = { version = "2.0.0-rc6", path = "../../../frame/session" }
-pallet-society = { version = "2.0.0-rc6", path = "../../../frame/society" }
-sp-runtime = { version = "2.0.0-rc6", path = "../../../primitives/runtime" }
-pallet-staking = { version = "2.0.0-rc6", path = "../../../frame/staking" }
-sc-executor = { version = "0.8.0-rc6", path = "../../../client/executor", features = ["wasmtime"] }
-sp-consensus = { version = "0.8.0-rc6", path = "../../../primitives/consensus/common" }
-frame-system = { version = "2.0.0-rc6", path = "../../../frame/system" }
-substrate-test-client = { version = "2.0.0-rc6", path = "../../../test-utils/client" }
-pallet-timestamp = { version = "2.0.0-rc6", path = "../../../frame/timestamp" }
-pallet-transaction-payment = { version = "2.0.0-rc6", path = "../../../frame/transaction-payment" }
-pallet-treasury = { version = "2.0.0-rc6", path = "../../../frame/treasury" }
-sp-api = { version = "2.0.0-rc6", path = "../../../primitives/api" }
-sp-finality-tracker = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/finality-tracker" }
-sp-timestamp = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/timestamp" }
-sp-block-builder = { version = "2.0.0-rc6", path = "../../../primitives/block-builder" }
-sc-block-builder = { version = "0.8.0-rc6", path = "../../../client/block-builder" }
-sp-inherents = { version = "2.0.0-rc6", path = "../../../primitives/inherents" }
-sp-blockchain = { version = "2.0.0-rc6", path = "../../../primitives/blockchain" }
+pallet-contracts = { version = "2.0.0", path = "../../../frame/contracts" }
+pallet-grandpa = { version = "2.0.0", path = "../../../frame/grandpa" }
+pallet-indices = { version = "2.0.0", path = "../../../frame/indices" }
+sp-keyring = { version = "2.0.0", path = "../../../primitives/keyring" }
+node-executor = { version = "2.0.0", path = "../executor" }
+node-primitives = { version = "2.0.0", path = "../primitives" }
+node-runtime = { version = "2.0.0", path = "../runtime" }
+sp-core = { version = "2.0.0", path = "../../../primitives/core" }
+sp-io = { version = "2.0.0", path = "../../../primitives/io" }
+frame-support = { version = "2.0.0", path = "../../../frame/support" }
+pallet-session = { version = "2.0.0", path = "../../../frame/session" }
+pallet-society = { version = "2.0.0", path = "../../../frame/society" }
+sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" }
+pallet-staking = { version = "2.0.0", path = "../../../frame/staking" }
+sc-executor = { version = "0.8.0", path = "../../../client/executor", features = ["wasmtime"] }
+sp-consensus = { version = "0.8.0", path = "../../../primitives/consensus/common" }
+frame-system = { version = "2.0.0", path = "../../../frame/system" }
+substrate-test-client = { version = "2.0.0", path = "../../../test-utils/client" }
+pallet-timestamp = { version = "2.0.0", path = "../../../frame/timestamp" }
+pallet-transaction-payment = { version = "2.0.0", path = "../../../frame/transaction-payment" }
+pallet-treasury = { version = "2.0.0", path = "../../../frame/treasury" }
+sp-api = { version = "2.0.0", path = "../../../primitives/api" }
+sp-timestamp = { version = "2.0.0", default-features = false, path = "../../../primitives/timestamp" }
+sp-block-builder = { version = "2.0.0", path = "../../../primitives/block-builder" }
+sc-block-builder = { version = "0.8.0", path = "../../../client/block-builder" }
+sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" }
+sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" }
log = "0.4.8"
tempfile = "3.1.0"
fs_extra = "1"
@@ -53,4 +52,4 @@ futures = "0.3.1"
[dev-dependencies]
criterion = "0.3.0"
-sc-cli = { version = "0.8.0-rc6", path = "../../../client/cli" }
+sc-cli = { version = "0.8.0", path = "../../../client/cli" }
diff --git a/bin/node/testing/src/bench.rs b/bin/node/testing/src/bench.rs
index 8242886fe95ed5662bdd81f37de030cff56d5af2..153a52375c2a9a23d6bb46d34191c25f445beb78 100644
--- a/bin/node/testing/src/bench.rs
+++ b/bin/node/testing/src/bench.rs
@@ -88,6 +88,61 @@ impl BenchPair {
}
}
+/// Drop system cache.
+///
+/// Will panic if cache drop is impossbile.
+pub fn drop_system_cache() {
+ #[cfg(target_os = "windows")] {
+ log::warn!(
+ target: "bench-logistics",
+ "Clearing system cache on windows is not supported. Benchmark might totally be wrong.",
+ );
+ return;
+ }
+
+ std::process::Command::new("sync")
+ .output()
+ .expect("Failed to execute system cache clear");
+
+ #[cfg(target_os = "linux")] {
+ log::trace!(target: "bench-logistics", "Clearing system cache...");
+ std::process::Command::new("echo")
+ .args(&["3", ">", "/proc/sys/vm/drop_caches", "2>", "/dev/null"])
+ .output()
+ .expect("Failed to execute system cache clear");
+
+ let temp = tempfile::tempdir().expect("Failed to spawn tempdir");
+ let temp_file_path = format!("of={}/buf", temp.path().to_string_lossy());
+
+ // this should refill write cache with 2GB of garbage
+ std::process::Command::new("dd")
+ .args(&["if=/dev/urandom", &temp_file_path, "bs=64M", "count=32"])
+ .output()
+ .expect("Failed to execute dd for cache clear");
+
+ // remove tempfile of previous command
+ std::process::Command::new("rm")
+ .arg(&temp_file_path)
+ .output()
+ .expect("Failed to remove temp file");
+
+ std::process::Command::new("sync")
+ .output()
+ .expect("Failed to execute system cache clear");
+
+ log::trace!(target: "bench-logistics", "Clearing system cache done!");
+ }
+
+ #[cfg(target_os = "macos")] {
+ log::trace!(target: "bench-logistics", "Clearing system cache...");
+ if let Err(err) = std::process::Command::new("purge").output() {
+ log::error!("purge error {:?}: ", err);
+ panic!("Could not clear system cache. Run under sudo?");
+ }
+ log::trace!(target: "bench-logistics", "Clearing system cache done!");
+ }
+}
+
/// Pre-initialized benchmarking database.
///
/// This is prepared database with genesis and keyring
@@ -124,6 +179,13 @@ impl Clone for BenchDb {
&fs_extra::dir::CopyOptions::new(),
).expect("Copy of seed database is ok");
+ // We clear system cache after db clone but before any warmups.
+ // This populates system cache with some data unrelated to actual
+ // data we will be quering further under benchmark (like what
+ // would have happened in real system that queries random entries
+ // from database).
+ drop_system_cache();
+
BenchDb { keyring, directory_guard: Guard(dir), database_type }
}
}
@@ -311,7 +373,12 @@ impl BenchDb {
"Created seed db at {}",
dir.path().to_string_lossy(),
);
- let (_client, _backend) = Self::bench_client(database_type, dir.path(), Profile::Native, &keyring);
+ let (_client, _backend, _task_executor) = Self::bench_client(
+ database_type,
+ dir.path(),
+ Profile::Native,
+ &keyring,
+ );
let directory_guard = Guard(dir);
BenchDb { keyring, directory_guard, database_type }
@@ -339,13 +406,14 @@ impl BenchDb {
dir: &std::path::Path,
profile: Profile,
keyring: &BenchKeyring,
- ) -> (Client, std::sync::Arc) {
+ ) -> (Client, std::sync::Arc, TaskExecutor) {
let db_config = sc_client_db::DatabaseSettings {
state_cache_size: 16*1024*1024,
state_cache_child_ratio: Some((0, 100)),
pruning: PruningMode::ArchiveAll,
source: database_type.into_settings(dir.into()),
};
+ let task_executor = TaskExecutor::new();
let (client, backend) = sc_service::new_client(
db_config,
@@ -354,12 +422,12 @@ impl BenchDb {
None,
None,
ExecutionExtensions::new(profile.into_execution_strategies(), None),
- Box::new(TaskExecutor::new()),
+ Box::new(task_executor.clone()),
None,
Default::default(),
).expect("Should not fail");
- (client, backend)
+ (client, backend, task_executor)
}
/// Generate list of required inherents.
@@ -369,10 +437,9 @@ impl BenchDb {
let mut inherent_data = InherentData::new();
let timestamp = 1 * MinimumPeriod::get();
- inherent_data.put_data(sp_timestamp::INHERENT_IDENTIFIER, ×tamp)
+ inherent_data
+ .put_data(sp_timestamp::INHERENT_IDENTIFIER, ×tamp)
.expect("Put timestamp failed");
- inherent_data.put_data(sp_finality_tracker::INHERENT_IDENTIFIER, &0)
- .expect("Put finality tracker failed");
client.runtime_api()
.inherent_extrinsics_with_context(
@@ -389,7 +456,7 @@ impl BenchDb {
/// Get cliet for this database operations.
pub fn client(&mut self) -> Client {
- let (client, _backend) = Self::bench_client(
+ let (client, _backend, _task_executor) = Self::bench_client(
self.database_type,
self.directory_guard.path(),
Profile::Wasm,
@@ -443,7 +510,7 @@ impl BenchDb {
/// Clone this database and create context for testing/benchmarking.
pub fn create_context(&self, profile: Profile) -> BenchContext {
let BenchDb { directory_guard, keyring, database_type } = self.clone();
- let (client, backend) = Self::bench_client(
+ let (client, backend, task_executor) = Self::bench_client(
database_type,
directory_guard.path(),
profile,
@@ -454,6 +521,7 @@ impl BenchDb {
client: Arc::new(client),
db_guard: directory_guard,
backend,
+ spawn_handle: Box::new(task_executor),
}
}
}
@@ -588,6 +656,8 @@ pub struct BenchContext {
pub client: Arc,
/// Node backend.
pub backend: Arc,
+ /// Spawn handle.
+ pub spawn_handle: Box,
db_guard: Guard,
}
diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml
index f6d03d4f3d107ce268f2d84efce197cdd1688659..a57dadd26bda88df7a0bc495a388c28f17539130 100644
--- a/bin/utils/chain-spec-builder/Cargo.toml
+++ b/bin/utils/chain-spec-builder/Cargo.toml
@@ -1,21 +1,23 @@
[package]
name = "chain-spec-builder"
-version = "2.0.0-rc6"
+version = "2.0.0"
authors = ["Parity Technologies "]
edition = "2018"
build = "build.rs"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
+readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
ansi_term = "0.12.1"
-sc-keystore = { version = "2.0.0-rc6", path = "../../../client/keystore" }
-sc-chain-spec = { version = "2.0.0-rc6", path = "../../../client/chain-spec" }
-node-cli = { version = "2.0.0-rc6", path = "../../node/cli" }
-sp-core = { version = "2.0.0-rc6", path = "../../../primitives/core" }
+sc-keystore = { version = "2.0.0", path = "../../../client/keystore" }
+sc-chain-spec = { version = "2.0.0", path = "../../../client/chain-spec" }
+node-cli = { version = "2.0.0", path = "../../node/cli" }
+sp-core = { version = "2.0.0", path = "../../../primitives/core" }
+sp-keystore = { version = "0.8.0", path = "../../../primitives/keystore" }
rand = "0.7.2"
structopt = "0.3.8"
diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs
index 2bfbb0952775d9b138d8014b1be342785ed892f6..c2db944050eb452708e50001edaeb609bbc0057c 100644
--- a/bin/utils/chain-spec-builder/src/main.rs
+++ b/bin/utils/chain-spec-builder/src/main.rs
@@ -16,15 +16,19 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use std::{fs, path::{Path, PathBuf}};
+use std::{fs, path::{Path, PathBuf}, sync::Arc};
use ansi_term::Style;
use rand::{Rng, distributions::Alphanumeric, rngs::OsRng};
use structopt::StructOpt;
-use sc_keystore::{Store as Keystore};
+use sc_keystore::LocalKeystore;
use node_cli::chain_spec::{self, AccountId};
-use sp_core::{sr25519, crypto::{Public, Ss58Codec}, traits::BareCryptoStore};
+use sp_core::{
+ sr25519,
+ crypto::{Public, Ss58Codec},
+};
+use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
/// A utility to easily create a testnet chain spec definition with a given set
/// of authorities and endowed accounts and/or generate random accounts.
@@ -139,16 +143,17 @@ fn generate_authority_keys_and_store(
keystore_path: &Path,
) -> Result<(), String> {
for (n, seed) in seeds.into_iter().enumerate() {
- let keystore = Keystore::open(
+ let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::open(
keystore_path.join(format!("auth-{}", n)),
None,
- ).map_err(|err| err.to_string())?;
+ ).map_err(|err| err.to_string())?);
let (_, _, grandpa, babe, im_online, authority_discovery) =
chain_spec::authority_keys_from_seed(seed);
let insert_key = |key_type, public| {
- keystore.write().insert_unknown(
+ SyncCryptoStore::insert_unknown(
+ &*keystore,
key_type,
&format!("//{}", seed),
public,
diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml
index 0dc1a1b5970c90a22a8a569d3a2e4b072d48ae93..fa0b345bc8406f2f4ea33228276fdb712b1b4845 100644
--- a/bin/utils/subkey/Cargo.toml
+++ b/bin/utils/subkey/Cargo.toml
@@ -1,11 +1,12 @@
[package]
name = "subkey"
-version = "2.0.0-rc6"
+version = "2.0.0"
authors = ["Parity Technologies "]
edition = "2018"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
+readme = "README.md"
[[bin]]
path = "src/main.rs"
@@ -15,13 +16,13 @@ name = "subkey"
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
-node-runtime = { version = "2.0.0-rc6", path = "../../node/runtime" }
-node-primitives = { version = "2.0.0-rc6", path = "../../node/primitives" }
-sc-cli = { version = "0.8.0-rc6", path = "../../../client/cli" }
-substrate-frame-cli = { version = "2.0.0-rc6", path = "../../../utils/frame/frame-utilities-cli" }
+node-runtime = { version = "2.0.0", path = "../../node/runtime" }
+node-primitives = { version = "2.0.0", path = "../../node/primitives" }
+sc-cli = { version = "0.8.0", path = "../../../client/cli" }
+substrate-frame-cli = { version = "2.0.0", path = "../../../utils/frame/frame-utilities-cli" }
structopt = "0.3.14"
-frame-system = { version = "2.0.0-rc6", path = "../../../frame/system" }
-sp-core = { version = "2.0.0-rc6", path = "../../../primitives/core" }
+frame-system = { version = "2.0.0", path = "../../../frame/system" }
+sp-core = { version = "2.0.0", path = "../../../primitives/core" }
[features]
bench = []
diff --git a/bin/utils/subkey/src/lib.rs b/bin/utils/subkey/src/lib.rs
index 15f7bf538c4b40878de124da7027030e313f76b9..051628e84a193419221d0eccd04f797dc2b56a23 100644
--- a/bin/utils/subkey/src/lib.rs
+++ b/bin/utils/subkey/src/lib.rs
@@ -39,7 +39,7 @@ pub enum Subkey {
Generate(GenerateCmd),
/// Gets a public key and a SS58 address from the provided Secret URI
- InspectKey(InspectKeyCmd),
+ Inspect(InspectKeyCmd),
/// Print the peer ID corresponding to the node key in the given file
InspectNodeKey(InspectNodeKeyCmd),
@@ -69,7 +69,7 @@ pub fn run() -> Result<(), Error>
match Subkey::from_args() {
Subkey::GenerateNodeKey(cmd) => cmd.run()?,
Subkey::Generate(cmd) => cmd.run()?,
- Subkey::InspectKey(cmd) => cmd.run()?,
+ Subkey::Inspect(cmd) => cmd.run()?,
Subkey::InspectNodeKey(cmd) => cmd.run()?,
Subkey::Insert(cmd) => cmd.run()?,
Subkey::ModuleId(cmd) => cmd.run::()?,
diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml
index 8f31e831bebac62d72c2964ea882b95e6040a1f5..d0fb5fc3ee0e2e82034f09f227df63fd1a635060 100644
--- a/client/api/Cargo.toml
+++ b/client/api/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sc-client-api"
-version = "2.0.0-rc6"
+version = "2.0.0"
authors = ["Parity Technologies "]
edition = "2018"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
@@ -8,42 +8,44 @@ homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
description = "Substrate client interfaces."
documentation = "https://docs.rs/sc-client-api"
+readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
-sp-consensus = { version = "0.8.0-rc6", path = "../../primitives/consensus/common" }
+sp-consensus = { version = "0.8.0", path = "../../primitives/consensus/common" }
derive_more = "0.99.2"
-sc-executor = { version = "0.8.0-rc6", path = "../executor" }
-sp-externalities = { version = "0.8.0-rc6", path = "../../primitives/externalities" }
+sc-executor = { version = "0.8.0", path = "../executor" }
+sp-externalities = { version = "0.8.0", path = "../../primitives/externalities" }
fnv = "1.0.6"
futures = "0.3.1"
hash-db = { version = "0.15.2", default-features = false }
-sp-blockchain = { version = "2.0.0-rc6", path = "../../primitives/blockchain" }
+sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" }
hex-literal = "0.3.1"
-sp-inherents = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/inherents" }
-sp-keyring = { version = "2.0.0-rc6", path = "../../primitives/keyring" }
+sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" }
+sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" }
kvdb = "0.7.0"
log = "0.4.8"
parking_lot = "0.10.0"
lazy_static = "1.4.0"
-sp-database = { version = "2.0.0-rc6", path = "../../primitives/database" }
-sp-core = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/core" }
-sp-std = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/std" }
-sp-version = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/version" }
-sp-api = { version = "2.0.0-rc6", path = "../../primitives/api" }
-sp-utils = { version = "2.0.0-rc6", path = "../../primitives/utils" }
-sp-runtime = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/runtime" }
-sp-state-machine = { version = "0.8.0-rc6", path = "../../primitives/state-machine" }
-sc-telemetry = { version = "2.0.0-rc6", path = "../telemetry" }
-sp-trie = { version = "2.0.0-rc6", path = "../../primitives/trie" }
-sp-storage = { version = "2.0.0-rc6", path = "../../primitives/storage" }
-sp-transaction-pool = { version = "2.0.0-rc6", path = "../../primitives/transaction-pool" }
-prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.8.0-rc6", path = "../../utils/prometheus" }
+sp-database = { version = "2.0.0", path = "../../primitives/database" }
+sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" }
+sp-keystore = { version = "0.8.0", default-features = false, path = "../../primitives/keystore" }
+sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" }
+sp-version = { version = "2.0.0", default-features = false, path = "../../primitives/version" }
+sp-api = { version = "2.0.0", path = "../../primitives/api" }
+sp-utils = { version = "2.0.0", path = "../../primitives/utils" }
+sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" }
+sp-state-machine = { version = "0.8.0", path = "../../primitives/state-machine" }
+sc-telemetry = { version = "2.0.0", path = "../telemetry" }
+sp-trie = { version = "2.0.0", path = "../../primitives/trie" }
+sp-storage = { version = "2.0.0", path = "../../primitives/storage" }
+sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" }
+prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.8.0", path = "../../utils/prometheus" }
[dev-dependencies]
kvdb-memorydb = "0.7.0"
-sp-test-primitives = { version = "2.0.0-rc6", path = "../../primitives/test-primitives" }
-substrate-test-runtime = { version = "2.0.0-rc6", path = "../../test-utils/runtime" }
+sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" }
+substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" }
diff --git a/client/api/src/call_executor.rs b/client/api/src/call_executor.rs
index d9d43900dfc94f2732db7be0051401a832bf8c5b..86e3440f19c93b6f25b5623bacefbce336a01d47 100644
--- a/client/api/src/call_executor.rs
+++ b/client/api/src/call_executor.rs
@@ -114,8 +114,7 @@ pub trait CallExecutor {
) -> Result<(Vec, StorageProof), sp_blockchain::Error> {
let trie_state = state.as_trie_backend()
.ok_or_else(||
- Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof)
- as Box
+ sp_blockchain::Error::from_state(Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) as Box<_>)
)?;
self.prove_at_trie_state(trie_state, overlay, method, call_data)
}
diff --git a/client/api/src/cht.rs b/client/api/src/cht.rs
index 30cfd3a1b671b8f159d40bdcb499137de8fe5a69..7fd7aa0dbcb7e7c18a35f7ce1da31bae173c2fc7 100644
--- a/client/api/src/cht.rs
+++ b/client/api/src/cht.rs
@@ -122,7 +122,7 @@ pub fn build_proof(
prove_read_on_trie_backend(
trie_storage,
blocks.into_iter().map(|number| encode_cht_key(number)),
- ).map_err(ClientError::Execution)
+ ).map_err(ClientError::from_state)
}
/// Check CHT-based header proof.
@@ -150,7 +150,7 @@ pub fn check_proof(
.map(|mut map| map
.remove(local_cht_key)
.expect("checked proof of local_cht_key; qed"))
- .map_err(|e| ClientError::from(e)),
+ .map_err(ClientError::from_state),
)
}
@@ -174,7 +174,7 @@ pub fn check_proof_on_proving_backend(
read_proof_check_on_proving_backend::(
proving_backend,
local_cht_key,
- ).map_err(|e| ClientError::from(e)),
+ ).map_err(ClientError::from_state),
)
}
diff --git a/client/api/src/execution_extensions.rs b/client/api/src/execution_extensions.rs
index 4f2ddb77e6653a056fcfd1647cfacdf6afbbec54..4fdd897b215797c2eae07ca503c0df6e063e7942 100644
--- a/client/api/src/execution_extensions.rs
+++ b/client/api/src/execution_extensions.rs
@@ -25,8 +25,8 @@ use codec::Decode;
use sp_core::{
ExecutionContext,
offchain::{self, OffchainExt, TransactionPoolExt},
- traits::{BareCryptoStorePtr, KeystoreExt},
};
+use sp_keystore::{KeystoreExt, SyncCryptoStorePtr};
use sp_runtime::{
generic::BlockId,
traits,
@@ -81,7 +81,7 @@ impl ExtensionsFactory for () {
/// for each call, based on required `Capabilities`.
pub struct ExecutionExtensions {
strategies: ExecutionStrategies,
- keystore: Option,
+ keystore: Option,
// FIXME: these two are only RwLock because of https://github.com/paritytech/substrate/issues/4587
// remove when fixed.
// To break retain cycle between `Client` and `TransactionPool` we require this
@@ -107,11 +107,16 @@ impl ExecutionExtensions {
/// Create new `ExecutionExtensions` given a `keystore` and `ExecutionStrategies`.
pub fn new(
strategies: ExecutionStrategies,
- keystore: Option,
+ keystore: Option,
) -> Self {
let transaction_pool = RwLock::new(None);
let extensions_factory = Box::new(());
- Self { strategies, keystore, extensions_factory: RwLock::new(extensions_factory), transaction_pool }
+ Self {
+ strategies,
+ keystore,
+ extensions_factory: RwLock::new(extensions_factory),
+ transaction_pool,
+ }
}
/// Get a reference to the execution strategies.
@@ -161,23 +166,27 @@ impl ExecutionExtensions {
let mut extensions = self.extensions_factory.read().extensions_for(capabilities);
if capabilities.has(offchain::Capability::Keystore) {
- if let Some(keystore) = self.keystore.as_ref() {
+ if let Some(ref keystore) = self.keystore {
extensions.register(KeystoreExt(keystore.clone()));
}
}
if capabilities.has(offchain::Capability::TransactionPool) {
if let Some(pool) = self.transaction_pool.read().as_ref().and_then(|x| x.upgrade()) {
- extensions.register(TransactionPoolExt(Box::new(TransactionPoolAdapter {
- at: *at,
- pool,
- }) as _));
+ extensions.register(
+ TransactionPoolExt(
+ Box::new(TransactionPoolAdapter {
+ at: *at,
+ pool,
+ }) as _
+ ),
+ );
}
}
if let ExecutionContext::OffchainCall(Some(ext)) = context {
extensions.register(
- OffchainExt::new(offchain::LimitedExternalities::new(capabilities, ext.0))
+ OffchainExt::new(offchain::LimitedExternalities::new(capabilities, ext.0)),
);
}
diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml
index e2be0f68e2318fee6a1a33cde09d26e244fbfff0..ff6c26bbee53ecf504281d71317104348e2986b7 100644
--- a/client/authority-discovery/Cargo.toml
+++ b/client/authority-discovery/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sc-authority-discovery"
-version = "0.8.0-rc6"
+version = "0.8.0"
authors = ["Parity Technologies "]
edition = "2018"
build = "build.rs"
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
description = "Substrate authority discovery."
+readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -16,29 +17,31 @@ targets = ["x86_64-unknown-linux-gnu"]
prost-build = "0.6.1"
[dependencies]
+async-trait = "0.1"
bytes = "0.5.0"
codec = { package = "parity-scale-codec", default-features = false, version = "1.3.4" }
derive_more = "0.99.2"
either = "1.5.3"
futures = "0.3.4"
futures-timer = "3.0.1"
-libp2p = { version = "0.28.1", default-features = false, features = ["kad"] }
+libp2p = { version = "0.29.1", default-features = false, features = ["kad"] }
log = "0.4.8"
-prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0-rc6"}
+prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0"}
prost = "0.6.1"
rand = "0.7.2"
-sc-client-api = { version = "2.0.0-rc6", path = "../api" }
-sc-keystore = { version = "2.0.0-rc6", path = "../keystore" }
-sc-network = { version = "0.8.0-rc6", path = "../network" }
+sc-client-api = { version = "2.0.0", path = "../api" }
+sc-keystore = { version = "2.0.0", path = "../keystore" }
+sc-network = { version = "0.8.0", path = "../network" }
serde_json = "1.0.41"
-sp-authority-discovery = { version = "2.0.0-rc6", path = "../../primitives/authority-discovery" }
-sp-blockchain = { version = "2.0.0-rc6", path = "../../primitives/blockchain" }
-sp-core = { version = "2.0.0-rc6", path = "../../primitives/core" }
-sp-runtime = { version = "2.0.0-rc6", path = "../../primitives/runtime" }
-sp-api = { version = "2.0.0-rc6", path = "../../primitives/api" }
+sp-authority-discovery = { version = "2.0.0", path = "../../primitives/authority-discovery" }
+sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" }
+sp-core = { version = "2.0.0", path = "../../primitives/core" }
+sp-keystore = { version = "0.8.0", path = "../../primitives/keystore" }
+sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" }
+sp-api = { version = "2.0.0", path = "../../primitives/api" }
[dev-dependencies]
-env_logger = "0.7.0"
quickcheck = "0.9.0"
-sc-peerset = { version = "2.0.0-rc6", path = "../peerset" }
-substrate-test-runtime-client = { version = "2.0.0-rc6", path = "../../test-utils/runtime/client"}
+sp-tracing = { version = "2.0.0", path = "../../primitives/tracing" }
+sc-peerset = { version = "2.0.0", path = "../peerset" }
+substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client"}
diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs
index 347deb8d9fc5d99f421d70c2d99623652ef7418a..4ee57f31e04a59d311dd0cf3ee493f4c1b3e8c6c 100644
--- a/client/authority-discovery/src/lib.rs
+++ b/client/authority-discovery/src/lib.rs
@@ -15,7 +15,7 @@
// along with Substrate. If not, see .
#![warn(missing_docs)]
-
+#![recursion_limit = "1024"]
//! Substrate authority discovery.
//!
//! This crate enables Substrate authorities to discover and directly connect to
@@ -26,14 +26,13 @@
pub use crate::{service::Service, worker::{NetworkProvider, Worker, Role}};
-use std::pin::Pin;
-use std::sync::Arc;
+use std::{sync::Arc, time::Duration};
use futures::channel::{mpsc, oneshot};
use futures::Stream;
use sc_client_api::blockchain::HeaderBackend;
-use sc_network::{config::MultiaddrWithPeerId, DhtEvent, Multiaddr, PeerId};
+use sc_network::{DhtEvent, Multiaddr, PeerId};
use sp_authority_discovery::{AuthorityDiscoveryApi, AuthorityId};
use sp_runtime::traits::Block as BlockT;
use sp_api::ProvideRuntimeApi;
@@ -44,25 +43,104 @@ mod service;
mod tests;
mod worker;
+/// Configuration of [`Worker`].
+pub struct WorkerConfig {
+ /// The interval in which the node will publish its own address on the DHT.
+ ///
+ /// By default this is set to 12 hours.
+ pub publish_interval: Duration,
+ /// The interval in which the node will query the DHT for new entries.
+ ///
+ /// By default this is set to 10 minutes.
+ pub query_interval: Duration,
+ /// The time the node will wait before triggering the first DHT query or publish.
+ ///
+ /// By default this is set to 30 seconds.
+ ///
+ /// This default is based on the rough boostrap time required by libp2p Kademlia.
+ pub query_start_delay: Duration,
+ /// The interval in which the worker will instruct the peerset to connect to a random subset
+ /// of discovered validators.
+ ///
+ /// By default this is set to 10 minutes.
+ pub priority_group_set_interval: Duration,
+ /// The time the worker will wait after each query interval tick to pass a subset of
+ /// the cached authority addresses down to the peerset.
+ ///
+ /// Be aware that the actual delay will be computed by [`Self::query_start_delay`] +
+ /// [`Self::priority_group_set_start_delay`]
+ ///
+ /// By default this is set to 5 minutes.
+ pub priority_group_set_offset: Duration,
+}
+
+impl Default for WorkerConfig {
+ fn default() -> Self {
+ Self {
+ publish_interval: Duration::from_secs(12 * 60 * 60),
+ query_interval: Duration::from_secs(10 * 60),
+ query_start_delay: Duration::from_secs(30),
+ priority_group_set_interval: Duration::from_secs(10 * 60),
+ priority_group_set_offset: Duration::from_secs(5 * 60),
+ }
+ }
+}
+
/// Create a new authority discovery [`Worker`] and [`Service`].
-pub fn new_worker_and_service(
+///
+/// See the struct documentation of each for more details.
+pub fn new_worker_and_service(
+ client: Arc,
+ network: Arc,
+ dht_event_rx: DhtEventStream,
+ role: Role,
+ prometheus_registry: Option,
+) -> (Worker, Service)
+where
+ Block: BlockT + Unpin + 'static,
+ Network: NetworkProvider,
+ Client: ProvideRuntimeApi + Send + Sync + 'static + HeaderBackend,
+ >::Api: AuthorityDiscoveryApi,
+ DhtEventStream: Stream- + Unpin,
+{
+ new_worker_and_service_with_config(
+ Default::default(),
+ client,
+ network,
+ dht_event_rx,
+ role,
+ prometheus_registry,
+ )
+}
+
+/// Same as [`new_worker_and_service`] but with support for providing the `config`.
+///
+/// When in doubt use [`new_worker_and_service`] as it will use the default configuration.
+pub fn new_worker_and_service_with_config(
+ config: WorkerConfig,
client: Arc,
network: Arc,
- sentry_nodes: Vec,
- dht_event_rx: Pin + Send>>,
+ dht_event_rx: DhtEventStream,
role: Role,
prometheus_registry: Option,
-) -> (Worker, Service)
+) -> (Worker, Service)
where
Block: BlockT + Unpin + 'static,
Network: NetworkProvider,
Client: ProvideRuntimeApi + Send + Sync + 'static + HeaderBackend,
>::Api: AuthorityDiscoveryApi,
+ DhtEventStream: Stream
- + Unpin,
{
let (to_worker, from_service) = mpsc::channel(0);
let worker = Worker::new(
- from_service, client, network, sentry_nodes, dht_event_rx, role, prometheus_registry,
+ from_service,
+ client,
+ network,
+ dht_event_rx,
+ role,
+ prometheus_registry,
+ config,
);
let service = Service::new(to_worker);
diff --git a/client/authority-discovery/src/service.rs b/client/authority-discovery/src/service.rs
index ed0205d262fc60934c50bb04f0a17dd8f50c2e5e..7eabeb3daf52e3fb6e3c16bd965d357c178915c7 100644
--- a/client/authority-discovery/src/service.rs
+++ b/client/authority-discovery/src/service.rs
@@ -43,12 +43,12 @@ impl Service {
/// Returns `None` if no entry was present or connection to the
/// [`crate::Worker`] failed.
///
- /// [`Multiaddr`]s returned always include a [`PeerId`] via a
- /// [`libp2p::core::multiaddr:Protocol::P2p`] component. [`Multiaddr`]s
- /// might differ in their [`PeerId`], e.g. when each [`Multiaddr`]
- /// represents a different sentry node. This might change once support for
- /// sentry nodes is removed (see
- /// https://github.com/paritytech/substrate/issues/6845).
+ /// Note: [`Multiaddr`]s returned always include a [`PeerId`] via a
+ /// [`libp2p::core::multiaddr:Protocol::P2p`] component. Equality of
+ /// [`PeerId`]s across [`Multiaddr`]s returned by a single call is not
+ /// enforced today, given that there are still authorities out there
+ /// publishing the addresses of their sentry nodes on the DHT. In the future
+ /// this guarantee can be provided.
pub async fn get_addresses_by_authority_id(&mut self, authority: AuthorityId) -> Option> {
let (tx, rx) = oneshot::channel();
diff --git a/client/authority-discovery/src/tests.rs b/client/authority-discovery/src/tests.rs
index 8e7367f2f78857089ff4b21c5bcd4f81099921f8..414ffc1e3f3947718241f6586ff1e5cfda4d8fb8 100644
--- a/client/authority-discovery/src/tests.rs
+++ b/client/authority-discovery/src/tests.rs
@@ -19,28 +19,29 @@
use crate::{new_worker_and_service, worker::{tests::{TestApi, TestNetwork}, Role}};
use std::sync::Arc;
-
-use futures::prelude::*;
-use futures::channel::mpsc::channel;
-use futures::executor::LocalPool;
-use futures::task::LocalSpawn;
+use futures::{channel::mpsc::channel, executor::LocalPool, task::LocalSpawn};
use libp2p::core::{multiaddr::{Multiaddr, Protocol}, PeerId};
use sp_authority_discovery::AuthorityId;
use sp_core::crypto::key_types;
-use sp_core::testing::KeyStore;
+use sp_keystore::{CryptoStore, testing::KeyStore};
#[test]
fn get_addresses_and_authority_id() {
let (_dht_event_tx, dht_event_rx) = channel(0);
let network: Arc = Arc::new(Default::default());
+ let mut pool = LocalPool::new();
+
let key_store = KeyStore::new();
- let remote_authority_id: AuthorityId = key_store
- .write()
- .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None)
- .unwrap()
- .into();
+
+ let remote_authority_id: AuthorityId = pool.run_until(async {
+ key_store
+ .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None)
+ .await
+ .unwrap()
+ .into()
+ });
let remote_peer_id = PeerId::random();
let remote_addr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333".parse::()
@@ -54,16 +55,13 @@ fn get_addresses_and_authority_id() {
let (mut worker, mut service) = new_worker_and_service(
test_api,
network.clone(),
- vec![],
- dht_event_rx.boxed(),
- Role::Authority(key_store),
+ Box::pin(dht_event_rx),
+ Role::PublishAndDiscover(key_store.into()),
None,
);
-
worker.inject_addresses(remote_authority_id.clone(), vec![remote_addr.clone()]);
- let mut pool = LocalPool::new();
- pool.spawner().spawn_local_obj(Box::pin(worker).into()).unwrap();
+ pool.spawner().spawn_local_obj(Box::pin(worker.run()).into()).unwrap();
pool.run_until(async {
assert_eq!(
diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs
index ff4d12dadd98871a23a94a4a2925b069dea39077..42ae3a5213f0fc04ef78605e5b115cc71ca0abab 100644
--- a/client/authority-discovery/src/worker.rs
+++ b/client/authority-discovery/src/worker.rs
@@ -19,18 +19,16 @@ use crate::{error::{Error, Result}, ServicetoWorkerMsg};
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use std::marker::PhantomData;
-use std::pin::Pin;
use std::sync::Arc;
use std::time::{Duration, Instant};
use futures::channel::mpsc;
-use futures::task::{Context, Poll};
-use futures::{Future, FutureExt, ready, Stream, StreamExt, stream::Fuse};
+use futures::{FutureExt, Stream, StreamExt, stream::Fuse};
use futures_timer::Delay;
use addr_cache::AddrCache;
+use async_trait::async_trait;
use codec::Decode;
-use either::Either;
use libp2p::{core::multiaddr, multihash::Multihash};
use log::{debug, error, log_enabled};
use prometheus_endpoint::{Counter, CounterVec, Gauge, Opts, U64, register};
@@ -38,7 +36,6 @@ use prost::Message;
use rand::{seq::SliceRandom, thread_rng};
use sc_client_api::blockchain::HeaderBackend;
use sc_network::{
- config::MultiaddrWithPeerId,
DhtEvent,
ExHashT,
Multiaddr,
@@ -47,7 +44,7 @@ use sc_network::{
};
use sp_authority_discovery::{AuthorityDiscoveryApi, AuthorityId, AuthoritySignature, AuthorityPair};
use sp_core::crypto::{key_types, Pair};
-use sp_core::traits::BareCryptoStorePtr;
+use sp_keystore::CryptoStore;
use sp_runtime::{traits::Block as BlockT, generic::BlockId};
use sp_api::ProvideRuntimeApi;
@@ -61,9 +58,6 @@ type Interval = Box + Unpin + Send + Sync>;
const LOG_TARGET: &'static str = "sub-authority-discovery";
-/// Upper bound estimation on how long one should wait before accessing the Kademlia DHT.
-const LIBP2P_KADEMLIA_BOOTSTRAP_TIME: Duration = Duration::from_secs(30);
-
/// Name of the Substrate peerset priority group for authorities discovered through the authority
/// discovery module.
const AUTHORITIES_PRIORITY_GROUP_NAME: &'static str = "authorities";
@@ -74,70 +68,49 @@ const MAX_ADDRESSES_PER_AUTHORITY: usize = 10;
/// Maximum number of in-flight DHT lookups at any given point in time.
const MAX_IN_FLIGHT_LOOKUPS: usize = 8;
-/// Role an authority discovery module can run as.
+/// Role an authority discovery [`Worker`] can run as.
pub enum Role {
- /// Actual authority as well as a reference to its key store.
- Authority(BareCryptoStorePtr),
- /// Sentry node that guards an authority.
- ///
- /// No reference to its key store needed, as sentry nodes don't have an identity to sign
- /// addresses with in the first place.
- Sentry,
+ /// Publish own addresses and discover addresses of others.
+ PublishAndDiscover(Arc),
+ /// Discover addresses of others.
+ Discover,
}
-/// A [`Worker`] makes a given authority discoverable and discovers other
-/// authorities.
-///
-/// The [`Worker`] implements the Future trait. By
-/// polling [`Worker`] an authority:
+
+/// An authority discovery [`Worker`] can publish the local node's addresses as well as discover
+/// those of other nodes via a Kademlia DHT.
///
-/// 1. **Makes itself discoverable**
+/// When constructed with [`Role::PublishAndDiscover`] a [`Worker`] will
///
-/// 1. Retrieves its external addresses (including peer id) or the ones of
-/// its sentry nodes.
+/// 1. Retrieve its external addresses (including peer id).
///
-/// 2. Signs the above.
+/// 2. Get the list of keys owned by the local node participating in the current authority set.
///
-/// 3. Puts the signature and the addresses on the libp2p Kademlia DHT.
+/// 3. Sign the addresses with the keys.
///
+/// 4. Put addresses and signature as a record with the authority id as a key on a Kademlia DHT.
///
-/// 2. **Discovers other authorities**
+/// When constructed with either [`Role::PublishAndDiscover`] or [`Role::Publish`] a [`Worker`] will
///
-/// 1. Retrieves the current and next set of authorities.
+/// 1. Retrieve the current and next set of authorities.
///
-/// 2. Starts DHT queries for the ids of the authorities.
+/// 2. Start DHT queries for the ids of the authorities.
///
-/// 3. Validates the signatures of the retrieved key value pairs.
+/// 3. Validate the signatures of the retrieved key value pairs.
///
-/// 4. Adds the retrieved external addresses as priority nodes to the
-/// peerset.
+/// 4. Add the retrieved external addresses as priority nodes to the
+/// network peerset.
///
-/// When run as a sentry node, the [`Worker`] does not publish
-/// any addresses to the DHT but still discovers validators and sentry nodes of
-/// validators, i.e. only step 2 (Discovers other authorities) is executed.
-pub struct Worker
-where
- Block: BlockT + 'static,
- Network: NetworkProvider,
- Client: ProvideRuntimeApi + Send + Sync + 'static + HeaderBackend,
- >::Api: AuthorityDiscoveryApi,
-{
- /// Channel receiver for messages send by an [`Service`].
+/// 5. Allow querying of the collected addresses via the [`crate::Service`].
+pub struct Worker {
+ /// Channel receiver for messages send by a [`Service`].
from_service: Fuse>,
client: Arc,
network: Arc,
- /// List of sentry node public addresses.
- //
- // There are 3 states:
- // - None: No addresses were specified.
- // - Some(vec![]): Addresses were specified, but none could be parsed as proper
- // Multiaddresses.
- // - Some(vec![a, b, c, ...]): Valid addresses were specified.
- sentry_nodes: Option>,
/// Channel we receive Dht events on.
- dht_event_rx: Pin + Send>>,
+ dht_event_rx: DhtEventStream,
/// Interval to be proactive, publishing own addresses.
publish_interval: Interval,
@@ -161,59 +134,52 @@ where
phantom: PhantomData