mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 11:01:08 +00:00
[big refactor] Remove crate aliasing. (#4395)
* Rename: Phase 1. * Unify codec. * Fixing: Phase 2 * Fixing: Phase 3. * Fixing: Phase 4. * Fixing: Phase 5. * Fixing: Phase 6. * Fixing: Phase 7. * Fixing: Phase 8. Tests * Fixing: Phase 9. Tests!!! * Fixing: Phase 10. Moar tests! * Finally done! * More fixes. * Rename primitives:: to sp_core:: * Apply renames in finality-grandpa. * Fix benches. * Fix benches 2. * Revert node-template. * Fix frame-system in our modules.
This commit is contained in:
committed by
Gavin Wood
parent
f14d98a439
commit
8778ca7dc8
Generated
+1
@@ -6076,6 +6076,7 @@ dependencies = [
|
||||
name = "sp-application-crypto-test"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"sp-application-crypto 2.0.0",
|
||||
"sp-core 2.0.0",
|
||||
"sp-runtime 2.0.0",
|
||||
"substrate-test-runtime-client 2.0.0",
|
||||
|
||||
@@ -20,22 +20,22 @@ codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
trie-root = "0.15.2"
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
sc-cli = { path = "../../client/cli" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sc-executor = { path = "../../client/executor" }
|
||||
sc-service = { path = "../../client/service" }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents" }
|
||||
txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" }
|
||||
txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" }
|
||||
network = { package = "sc-network", path = "../../client/network" }
|
||||
aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" }
|
||||
aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura" }
|
||||
consensus-common = { package = "sp-consensus", path = "../../primitives/consensus/common" }
|
||||
sp-inherents = { path = "../../primitives/inherents" }
|
||||
sc-transaction-pool = { path = "../../client/transaction-pool" }
|
||||
sp-transaction-pool = { path = "../../primitives/transaction-pool" }
|
||||
sc-network = { path = "../../client/network" }
|
||||
sc-consensus-aura = { path = "../../client/consensus/aura" }
|
||||
sp-consensus-aura = { path = "../../primitives/consensus/aura" }
|
||||
sp-consensus = { path = "../../primitives/consensus/common" }
|
||||
grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grandpa" }
|
||||
grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" }
|
||||
sc-client = { path = "../../client/" }
|
||||
runtime = { package = "node-template-runtime", path = "runtime" }
|
||||
node-template-runtime = { path = "runtime" }
|
||||
sp-runtime = { path = "../../primitives/runtime" }
|
||||
basic-authorship = { package = "sc-basic-authority", path = "../../client/basic-authorship"}
|
||||
sc-basic-authority = { path = "../../client/basic-authorship"}
|
||||
|
||||
[build-dependencies]
|
||||
vergen = "3.0.4"
|
||||
|
||||
@@ -6,31 +6,32 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
aura = { package = "pallet-aura", path = "../../../frame/aura", default-features = false }
|
||||
aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false }
|
||||
balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false }
|
||||
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false}
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false }
|
||||
frame-support = { path = "../../../frame/support", default-features = false }
|
||||
grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false }
|
||||
indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false}
|
||||
offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
|
||||
randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false }
|
||||
sp-std = { path = "../../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../../primitives/io", default-features = false }
|
||||
safe-mix = { version = "1.0.0", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-api = { path = "../../../primitives/api", default-features = false }
|
||||
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
sp-session = { path = "../../../primitives/session", default-features = false }
|
||||
sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false }
|
||||
support = { package = "frame-support", path = "../../../frame/support", default-features = false }
|
||||
system = { package = "frame-system", path = "../../../frame/system", default-features = false }
|
||||
timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false }
|
||||
sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false }
|
||||
version = { package = "sp-version", path = "../../../primitives/version", default-features = false }
|
||||
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
frame-executive = { path = "../../../frame/executive", default-features = false }
|
||||
safe-mix = { version = "1.0.0", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-api = { path = "../../../primitives/api", default-features = false }
|
||||
sp-block-builder = { path = "../../../primitives/block-builder", default-features = false}
|
||||
sp-consensus-aura = { path = "../../../primitives/consensus/aura", default-features = false }
|
||||
sp-core = { path = "../../../primitives/core", default-features = false }
|
||||
sp-inherents = { path = "../../../primitives/inherents", default-features = false}
|
||||
sp-io = { path = "../../../primitives/io", default-features = false }
|
||||
sp-offchain = { path = "../../../primitives/offchain", default-features = false }
|
||||
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
sp-session = { path = "../../../primitives/session", default-features = false }
|
||||
sp-std = { path = "../../../primitives/std", default-features = false }
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false }
|
||||
sp-version = { path = "../../../primitives/version", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" }
|
||||
@@ -38,30 +39,30 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../..
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"aura-primitives/std",
|
||||
"aura/std",
|
||||
"balances/std",
|
||||
"block-builder-api/std",
|
||||
"codec/std",
|
||||
"executive/std",
|
||||
"frame-executive/std",
|
||||
"frame-support/std",
|
||||
"grandpa/std",
|
||||
"indices/std",
|
||||
"inherents/std",
|
||||
"offchain-primitives/std",
|
||||
"primitives/std",
|
||||
"randomness-collective-flip/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"safe-mix/std",
|
||||
"serde",
|
||||
"sp-api/std",
|
||||
"sp-block-builder/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-io/std",
|
||||
"sp-offchain/std",
|
||||
"sp-runtime/std",
|
||||
"sp-session/std",
|
||||
"sp-std/std",
|
||||
"sp-transaction-pool/std",
|
||||
"sp-version/std",
|
||||
"sudo/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"timestamp/std",
|
||||
"transaction-payment/std",
|
||||
"sp-transaction-pool/std",
|
||||
"version/std",
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use primitives::OpaqueMetadata;
|
||||
use sp_core::OpaqueMetadata;
|
||||
use sp_runtime::{
|
||||
ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
|
||||
impl_opaque_keys, MultiSignature
|
||||
@@ -18,12 +18,12 @@ use sp_runtime::traits::{
|
||||
NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount
|
||||
};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use aura_primitives::sr25519::AuthorityId as AuraId;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use grandpa::AuthorityList as GrandpaAuthorityList;
|
||||
use grandpa::fg_primitives;
|
||||
use version::RuntimeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
#[cfg(feature = "std")]
|
||||
use version::NativeVersion;
|
||||
use sp_version::NativeVersion;
|
||||
|
||||
// A few exports that help ease life for downstream crates.
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -31,7 +31,7 @@ pub use sp_runtime::BuildStorage;
|
||||
pub use timestamp::Call as TimestampCall;
|
||||
pub use balances::Call as BalancesCall;
|
||||
pub use sp_runtime::{Permill, Perbill};
|
||||
pub use support::{
|
||||
pub use frame_support::{
|
||||
StorageValue, construct_runtime, parameter_types,
|
||||
traits::Randomness,
|
||||
weights::Weight,
|
||||
@@ -58,7 +58,7 @@ pub type Balance = u128;
|
||||
pub type Index = u32;
|
||||
|
||||
/// A hash of some data used by the chain.
|
||||
pub type Hash = primitives::H256;
|
||||
pub type Hash = sp_core::H256;
|
||||
|
||||
/// Digest item type.
|
||||
pub type DigestItem = generic::DigestItem<Hash>;
|
||||
@@ -280,7 +280,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signatu
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
pub type Executive = frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
@@ -303,7 +303,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl block_builder_api::BlockBuilder<Block> for Runtime {
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
@@ -312,14 +312,14 @@ impl_runtime_apis! {
|
||||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: Block,
|
||||
data: inherents::InherentData,
|
||||
) -> inherents::CheckInherentsResult {
|
||||
data: sp_inherents::InherentData,
|
||||
) -> sp_inherents::CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
|
||||
@@ -334,13 +334,13 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
|
||||
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(number: NumberFor<Block>) {
|
||||
Executive::offchain_worker(number)
|
||||
}
|
||||
}
|
||||
|
||||
impl aura_primitives::AuraApi<Block, AuraId> for Runtime {
|
||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> u64 {
|
||||
Aura::slot_duration()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// For more guidance on Substrate modules, see the example module
|
||||
/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs
|
||||
|
||||
use support::{decl_module, decl_storage, decl_event, dispatch};
|
||||
use frame_support::{decl_module, decl_storage, decl_event, dispatch};
|
||||
use system::ensure_signed;
|
||||
|
||||
/// The module's configuration trait.
|
||||
@@ -69,8 +69,8 @@ decl_event!(
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use primitives::H256;
|
||||
use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
use frame_support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight};
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use primitives::{Pair, Public, sr25519};
|
||||
use runtime::{
|
||||
use sp_core::{Pair, Public, sr25519};
|
||||
use node_template_runtime::{
|
||||
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
|
||||
SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, Signature
|
||||
};
|
||||
use aura_primitives::sr25519::{AuthorityId as AuraId};
|
||||
use sp_consensus_aura::sr25519::{AuthorityId as AuraId};
|
||||
use grandpa_primitives::{AuthorityId as GrandpaId};
|
||||
use sc_service;
|
||||
use sp_runtime::traits::{Verify, IdentifyAccount};
|
||||
|
||||
@@ -5,7 +5,7 @@ use tokio::runtime::Runtime;
|
||||
pub use sc_cli::{VersionInfo, IntoExit, error};
|
||||
use sc_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom};
|
||||
use sc_service::{AbstractService, Roles as ServiceRoles, Configuration};
|
||||
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
|
||||
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
|
||||
use crate::chain_spec;
|
||||
use log::info;
|
||||
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use sc_client::LongestChain;
|
||||
use runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
|
||||
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
|
||||
use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
|
||||
use inherents::InherentDataProviders;
|
||||
use network::{construct_simple_protocol};
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use sc_network::{construct_simple_protocol};
|
||||
use sc_executor::native_executor_instance;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
|
||||
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use basic_authorship;
|
||||
use sc_basic_authority;
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
pub Executor,
|
||||
runtime::api::dispatch,
|
||||
runtime::native_version,
|
||||
node_template_runtime::api::dispatch,
|
||||
node_template_runtime::native_version,
|
||||
);
|
||||
|
||||
construct_simple_protocol! {
|
||||
@@ -32,19 +32,19 @@ construct_simple_protocol! {
|
||||
macro_rules! new_full_start {
|
||||
($config:expr) => {{
|
||||
let mut import_setup = None;
|
||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let builder = sc_service::ServiceBuilder::new_full::<
|
||||
runtime::opaque::Block, runtime::RuntimeApi, crate::service::Executor
|
||||
node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(sc_client::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client, _fetcher| {
|
||||
let pool_api = txpool::FullChainApi::new(client.clone());
|
||||
let pool = txpool::BasicPool::new(config, pool_api);
|
||||
let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
|
||||
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
|
||||
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
|
||||
let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
|
||||
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
|
||||
Ok(maintainable_pool)
|
||||
})?
|
||||
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
|
||||
@@ -52,12 +52,12 @@ macro_rules! new_full_start {
|
||||
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;
|
||||
|
||||
let (grandpa_block_import, grandpa_link) =
|
||||
grandpa::block_import::<_, _, _, runtime::RuntimeApi, _>(
|
||||
grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _>(
|
||||
client.clone(), &*client, select_chain
|
||||
)?;
|
||||
|
||||
let import_queue = aura::import_queue::<_, _, AuraPair, _>(
|
||||
aura::SlotDuration::get_or_compute(&*client)?,
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, AuraPair, _>(
|
||||
sc_consensus_aura::SlotDuration::get_or_compute(&*client)?,
|
||||
Box::new(grandpa_block_import.clone()),
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
@@ -102,7 +102,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
.build()?;
|
||||
|
||||
if participates_in_consensus {
|
||||
let proposer = basic_authorship::ProposerFactory {
|
||||
let proposer = sc_basic_authority::ProposerFactory {
|
||||
client: service.client(),
|
||||
transaction_pool: service.transaction_pool(),
|
||||
};
|
||||
@@ -112,10 +112,10 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
.ok_or(ServiceError::SelectChainRequired)?;
|
||||
|
||||
let can_author_with =
|
||||
consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
let aura = aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
|
||||
aura::SlotDuration::get_or_compute(&*client)?,
|
||||
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
|
||||
sc_consensus_aura::SlotDuration::get_or_compute(&*client)?,
|
||||
client,
|
||||
select_chain,
|
||||
block_import,
|
||||
@@ -203,10 +203,10 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
|
||||
.with_transaction_pool(|config, client, fetcher| {
|
||||
let fetcher = fetcher
|
||||
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
|
||||
let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone());
|
||||
let pool = txpool::BasicPool::new(config, pool_api);
|
||||
let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
|
||||
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
|
||||
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
|
||||
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
|
||||
let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
|
||||
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
|
||||
Ok(maintainable_pool)
|
||||
})?
|
||||
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
|
||||
@@ -220,8 +220,8 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let import_queue = aura::import_queue::<_, _, AuraPair, ()>(
|
||||
aura::SlotDuration::get_or_compute(&*client)?,
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, AuraPair, ()>(
|
||||
sc_consensus_aura::SlotDuration::get_or_compute(&*client)?,
|
||||
Box::new(grandpa_block_import),
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
|
||||
@@ -34,45 +34,45 @@ rand = "0.7.2"
|
||||
structopt = "0.3.3"
|
||||
|
||||
# primitives
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery"}
|
||||
babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" }
|
||||
sp-authority-discovery = { path = "../../../primitives/authority-discovery"}
|
||||
sp-consensus-babe = { path = "../../../primitives/consensus/babe" }
|
||||
grandpa-primitives = { package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
sp-timestamp = { path = "../../../primitives/timestamp", default-features = false }
|
||||
sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents" }
|
||||
keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
|
||||
sp-inherents = { path = "../../../primitives/inherents" }
|
||||
sp-keyring = { path = "../../../primitives/keyring" }
|
||||
sp-io = { path = "../../../primitives/io" }
|
||||
consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
|
||||
# client dependencies
|
||||
client-api = { package = "sc-client-api", path = "../../../client/api" }
|
||||
client = { package = "sc-client", path = "../../../client/" }
|
||||
chain-spec = { package = "sc-chain-spec", path = "../../../client/chain-spec" }
|
||||
txpool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" }
|
||||
txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" }
|
||||
network = { package = "sc-network", path = "../../../client/network" }
|
||||
babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe" }
|
||||
sc-client-api = { path = "../../../client/api" }
|
||||
sc-client = { path = "../../../client/" }
|
||||
sc-chain-spec = { path = "../../../client/chain-spec" }
|
||||
sc-transaction-pool = { path = "../../../client/transaction-pool" }
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool" }
|
||||
sc-network = { path = "../../../client/network" }
|
||||
sc-consensus-babe = { path = "../../../client/consensus/babe" }
|
||||
grandpa = { package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" }
|
||||
client-db = { package = "sc-client-db", path = "../../../client/db", default-features = false }
|
||||
offchain = { package = "sc-offchain", path = "../../../client/offchain" }
|
||||
sc-client-db = { path = "../../../client/db", default-features = false }
|
||||
sc-offchain = { path = "../../../client/offchain" }
|
||||
sc-rpc = { path = "../../../client/rpc" }
|
||||
sc-basic-authority = { path = "../../../client/basic-authorship" }
|
||||
sc-service = { path = "../../../client/service", default-features = false }
|
||||
sc-telemetry = { path = "../../../client/telemetry" }
|
||||
authority-discovery = { package = "sc-authority-discovery", path = "../../../client/authority-discovery"}
|
||||
sc-authority-discovery = { path = "../../../client/authority-discovery"}
|
||||
|
||||
# frame dependencies
|
||||
indices = { package = "pallet-indices", path = "../../../frame/indices" }
|
||||
timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false }
|
||||
contracts = { package = "pallet-contracts", path = "../../../frame/contracts" }
|
||||
system = { package = "frame-system", path = "../../../frame/system" }
|
||||
balances = { package = "pallet-balances", path = "../../../frame/balances" }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" }
|
||||
support = { package = "frame-support", path = "../../../frame/support", default-features = false }
|
||||
im_online = { package = "pallet-im-online", path = "../../../frame/im-online", default-features = false }
|
||||
sr-authority-discovery = { package = "pallet-authority-discovery", path = "../../../frame/authority-discovery"}
|
||||
pallet-indices = { path = "../../../frame/indices" }
|
||||
pallet-timestamp = { path = "../../../frame/timestamp", default-features = false }
|
||||
pallet-contracts = { path = "../../../frame/contracts" }
|
||||
frame-system = { path = "../../../frame/system" }
|
||||
pallet-balances = { path = "../../../frame/balances" }
|
||||
pallet-transaction-payment = { path = "../../../frame/transaction-payment" }
|
||||
frame-support = { path = "../../../frame/support", default-features = false }
|
||||
pallet-im-online = { path = "../../../frame/im-online", default-features = false }
|
||||
pallet-authority-discovery = { path = "../../../frame/authority-discovery"}
|
||||
|
||||
# node-specific dependencies
|
||||
node-runtime = { path = "../runtime" }
|
||||
@@ -98,9 +98,9 @@ kvdb-memorydb = { version = "0.1.1", optional = true }
|
||||
rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature
|
||||
|
||||
[dev-dependencies]
|
||||
keystore = { package = "sc-keystore", path = "../../../client/keystore" }
|
||||
babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe", features = ["test-helpers"] }
|
||||
service-test = { package = "sc-service-test", path = "../../../client/service/test" }
|
||||
sc-keystore = { path = "../../../client/keystore" }
|
||||
sc-consensus-babe = { path = "../../../client/consensus/babe", features = ["test-helpers"] }
|
||||
sc-service-test = { path = "../../../client/service/test" }
|
||||
futures = "0.3.1"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ fn start_inner(wasm_ext: wasm_ext::ffi::Transport) -> Result<Client, Box<dyn std
|
||||
let wasm_ext = wasm_ext::ExtTransport::new(wasm_ext);
|
||||
let chain_spec = ChainSpec::FlamingFir.load().map_err(|e| format!("{:?}", e))?;
|
||||
let mut config = Configuration::<(), _, _>::default_with_spec_and_base_path(chain_spec, None);
|
||||
config.network.transport = network::config::TransportConfig::Normal {
|
||||
config.network.transport = sc_network::config::TransportConfig::Normal {
|
||||
wasm_external_transport: Some(wasm_ext.clone()),
|
||||
allow_private_ipv4: true,
|
||||
enable_mdns: false,
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Substrate chain configurations.
|
||||
|
||||
use chain_spec::ChainSpecExtension;
|
||||
use primitives::{Pair, Public, crypto::UncheckedInto, sr25519};
|
||||
use sc_chain_spec::ChainSpecExtension;
|
||||
use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use node_runtime::{
|
||||
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig,
|
||||
@@ -30,9 +30,9 @@ use sc_service;
|
||||
use hex_literal::hex;
|
||||
use sc_telemetry::TelemetryEndpoints;
|
||||
use grandpa_primitives::{AuthorityId as GrandpaId};
|
||||
use babe_primitives::{AuthorityId as BabeId};
|
||||
use im_online::sr25519::{AuthorityId as ImOnlineId};
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_consensus_babe::{AuthorityId as BabeId};
|
||||
use pallet_im_online::sr25519::{AuthorityId as ImOnlineId};
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}};
|
||||
|
||||
pub use node_primitives::{AccountId, Balance, Signature};
|
||||
@@ -49,7 +49,7 @@ const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
#[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)]
|
||||
pub struct Extensions {
|
||||
/// Block numbers with known hashes.
|
||||
pub fork_blocks: client::ForkBlocks<Block>,
|
||||
pub fork_blocks: sc_client::ForkBlocks<Block>,
|
||||
}
|
||||
|
||||
/// Specialized `ChainSpec`.
|
||||
@@ -229,24 +229,24 @@ pub fn testnet_genesis(
|
||||
code: WASM_BINARY.to_vec(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
balances: Some(BalancesConfig {
|
||||
pallet_balances: Some(BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned()
|
||||
.map(|k| (k, ENDOWMENT))
|
||||
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
|
||||
.collect(),
|
||||
vesting: vec![],
|
||||
}),
|
||||
indices: Some(IndicesConfig {
|
||||
pallet_indices: Some(IndicesConfig {
|
||||
ids: endowed_accounts.iter().cloned()
|
||||
.chain(initial_authorities.iter().map(|x| x.0.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
}),
|
||||
session: Some(SessionConfig {
|
||||
pallet_session: Some(SessionConfig {
|
||||
keys: initial_authorities.iter().map(|x| {
|
||||
(x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()))
|
||||
}).collect::<Vec<_>>(),
|
||||
}),
|
||||
staking: Some(StakingConfig {
|
||||
pallet_staking: Some(StakingConfig {
|
||||
current_era: 0,
|
||||
validator_count: initial_authorities.len() as u32 * 2,
|
||||
minimum_validator_count: initial_authorities.len() as u32,
|
||||
@@ -257,41 +257,41 @@ pub fn testnet_genesis(
|
||||
slash_reward_fraction: Perbill::from_percent(10),
|
||||
.. Default::default()
|
||||
}),
|
||||
democracy: Some(DemocracyConfig::default()),
|
||||
collective_Instance1: Some(CouncilConfig {
|
||||
pallet_democracy: Some(DemocracyConfig::default()),
|
||||
pallet_collective_Instance1: Some(CouncilConfig {
|
||||
members: endowed_accounts.iter().cloned()
|
||||
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
|
||||
phantom: Default::default(),
|
||||
}),
|
||||
collective_Instance2: Some(TechnicalCommitteeConfig {
|
||||
pallet_collective_Instance2: Some(TechnicalCommitteeConfig {
|
||||
members: endowed_accounts.iter().cloned()
|
||||
.collect::<Vec<_>>()[..(num_endowed_accounts + 1) / 2].to_vec(),
|
||||
phantom: Default::default(),
|
||||
}),
|
||||
contracts: Some(ContractsConfig {
|
||||
current_schedule: contracts::Schedule {
|
||||
pallet_contracts: Some(ContractsConfig {
|
||||
current_schedule: pallet_contracts::Schedule {
|
||||
enable_println, // this should only be enabled on development chains
|
||||
..Default::default()
|
||||
},
|
||||
gas_price: 1 * MILLICENTS,
|
||||
}),
|
||||
sudo: Some(SudoConfig {
|
||||
pallet_sudo: Some(SudoConfig {
|
||||
key: root_key,
|
||||
}),
|
||||
babe: Some(BabeConfig {
|
||||
pallet_babe: Some(BabeConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
im_online: Some(ImOnlineConfig {
|
||||
pallet_im_online: Some(ImOnlineConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
authority_discovery: Some(AuthorityDiscoveryConfig {
|
||||
pallet_authority_discovery: Some(AuthorityDiscoveryConfig {
|
||||
keys: vec![],
|
||||
}),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
pallet_grandpa: Some(GrandpaConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
membership_Instance1: Some(Default::default()),
|
||||
treasury: Some(Default::default()),
|
||||
pallet_membership_Instance1: Some(Default::default()),
|
||||
pallet_treasury: Some(Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::service::new_full;
|
||||
use sc_service::Roles;
|
||||
use service_test;
|
||||
use sc_service_test;
|
||||
|
||||
fn local_testnet_genesis_instant_single() -> GenesisConfig {
|
||||
testnet_genesis(
|
||||
@@ -395,7 +395,7 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_connectivity() {
|
||||
service_test::connectivity(
|
||||
sc_service_test::connectivity(
|
||||
integration_test_config_with_two_authorities(),
|
||||
|config| new_full(config),
|
||||
|mut config| {
|
||||
|
||||
@@ -22,19 +22,19 @@ use rand::{Rng, SeedableRng};
|
||||
use rand::rngs::StdRng;
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use keyring::sr25519::Keyring;
|
||||
use sp_keyring::sr25519::Keyring;
|
||||
use node_runtime::{
|
||||
Call, CheckedExtrinsic, UncheckedExtrinsic, SignedExtra, BalancesCall, ExistentialDeposit,
|
||||
MinimumPeriod
|
||||
};
|
||||
use node_primitives::Signature;
|
||||
use primitives::{sr25519, crypto::Pair};
|
||||
use sp_core::{sr25519, crypto::Pair};
|
||||
use sp_runtime::{
|
||||
generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension, Verify, IdentifyAccount}
|
||||
};
|
||||
use node_transaction_factory::RuntimeAdapter;
|
||||
use node_transaction_factory::modes::Mode;
|
||||
use inherents::InherentData;
|
||||
use sp_inherents::InherentData;
|
||||
use sp_timestamp;
|
||||
use sp_finality_tracker;
|
||||
|
||||
@@ -56,12 +56,12 @@ type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
|
||||
impl<Number> FactoryState<Number> {
|
||||
fn build_extra(index: node_primitives::Index, phase: u64) -> node_runtime::SignedExtra {
|
||||
(
|
||||
system::CheckVersion::new(),
|
||||
system::CheckGenesis::new(),
|
||||
system::CheckEra::from(Era::mortal(256, phase)),
|
||||
system::CheckNonce::from(index),
|
||||
system::CheckWeight::new(),
|
||||
transaction_payment::ChargeTransactionPayment::from(0),
|
||||
frame_system::CheckVersion::new(),
|
||||
frame_system::CheckGenesis::new(),
|
||||
frame_system::CheckEra::from(Era::mortal(256, phase)),
|
||||
frame_system::CheckNonce::from(index),
|
||||
frame_system::CheckWeight::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::from(0),
|
||||
Default::default(),
|
||||
)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
signed: Some((sender.clone(), Self::build_extra(index, phase))),
|
||||
function: Call::Balances(
|
||||
BalancesCall::transfer(
|
||||
indices::address::Address::Id(destination.clone().into()),
|
||||
pallet_indices::address::Address::Id(destination.clone().into()),
|
||||
(*amount).into()
|
||||
)
|
||||
)
|
||||
@@ -253,7 +253,7 @@ fn sign<RA: RuntimeAdapter>(
|
||||
}
|
||||
}).into();
|
||||
UncheckedExtrinsic {
|
||||
signature: Some((indices::address::Address::Id(signed), signature, extra)),
|
||||
signature: Some((pallet_indices::address::Address::Id(signed), signature, extra)),
|
||||
function: payload.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use babe;
|
||||
use client::{self, LongestChain};
|
||||
use sc_consensus_babe;
|
||||
use sc_client::{self, LongestChain};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use node_executor;
|
||||
use node_primitives::Block;
|
||||
@@ -29,17 +29,17 @@ use node_runtime::{GenesisConfig, RuntimeApi};
|
||||
use sc_service::{
|
||||
AbstractService, ServiceBuilder, config::Configuration, error::{Error as ServiceError},
|
||||
};
|
||||
use inherents::InherentDataProviders;
|
||||
use network::construct_simple_protocol;
|
||||
use sp_inherents::InherentDataProviders;
|
||||
use sc_network::construct_simple_protocol;
|
||||
|
||||
use sc_service::{Service, NetworkStatus};
|
||||
use client::{Client, LocalCallExecutor};
|
||||
use client_db::Backend;
|
||||
use sc_client::{Client, LocalCallExecutor};
|
||||
use sc_client_db::Backend;
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use node_executor::NativeExecutor;
|
||||
use network::NetworkService;
|
||||
use offchain::OffchainWorkers;
|
||||
use primitives::Blake2Hasher;
|
||||
use sc_network::NetworkService;
|
||||
use sc_offchain::OffchainWorkers;
|
||||
use sp_core::Blake2Hasher;
|
||||
|
||||
construct_simple_protocol! {
|
||||
/// Demo protocol attachment for substrate.
|
||||
@@ -54,19 +54,19 @@ macro_rules! new_full_start {
|
||||
($config:expr) => {{
|
||||
type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
|
||||
let mut import_setup = None;
|
||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let builder = sc_service::ServiceBuilder::new_full::<
|
||||
node_primitives::Block, node_runtime::RuntimeApi, node_executor::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(client::LongestChain::new(backend.clone()))
|
||||
Ok(sc_client::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client, _fetcher| {
|
||||
let pool_api = txpool::FullChainApi::new(client.clone());
|
||||
let pool = txpool::BasicPool::new(config, pool_api);
|
||||
let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
|
||||
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
|
||||
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
|
||||
let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
|
||||
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
|
||||
Ok(maintainable_pool)
|
||||
})?
|
||||
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
|
||||
@@ -79,14 +79,14 @@ macro_rules! new_full_start {
|
||||
)?;
|
||||
let justification_import = grandpa_block_import.clone();
|
||||
|
||||
let (block_import, babe_link) = babe::block_import(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
let (block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = babe::import_queue(
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
@@ -114,7 +114,7 @@ macro_rules! new_full_start {
|
||||
macro_rules! new_full {
|
||||
($config:expr, $with_startup_data: expr) => {{
|
||||
use futures01::sync::mpsc;
|
||||
use network::DhtEvent;
|
||||
use sc_network::DhtEvent;
|
||||
use futures::{
|
||||
compat::Stream01CompatExt,
|
||||
stream::StreamExt,
|
||||
@@ -172,9 +172,9 @@ macro_rules! new_full {
|
||||
.ok_or(sc_service::Error::SelectChainRequired)?;
|
||||
|
||||
let can_author_with =
|
||||
consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
let babe_config = babe::BabeParams {
|
||||
let babe_config = sc_consensus_babe::BabeParams {
|
||||
keystore: service.keystore(),
|
||||
client,
|
||||
select_chain,
|
||||
@@ -187,13 +187,13 @@ macro_rules! new_full {
|
||||
can_author_with,
|
||||
};
|
||||
|
||||
let babe = babe::start_babe(babe_config)?;
|
||||
let babe = sc_consensus_babe::start_babe(babe_config)?;
|
||||
service.spawn_essential_task(babe);
|
||||
|
||||
let future03_dht_event_rx = dht_event_rx.compat()
|
||||
.map(|x| x.expect("<mpsc::channel::Receiver as Stream> never returns an error; qed"))
|
||||
.boxed();
|
||||
let authority_discovery = authority_discovery::AuthorityDiscovery::new(
|
||||
let authority_discovery = sc_authority_discovery::AuthorityDiscovery::new(
|
||||
service.client(),
|
||||
service.network(),
|
||||
sentry_nodes,
|
||||
@@ -280,14 +280,14 @@ type ConcreteClient =
|
||||
#[allow(dead_code)]
|
||||
type ConcreteBackend = Backend<ConcreteBlock>;
|
||||
#[allow(dead_code)]
|
||||
type ConcreteTransactionPool = txpool_api::MaintainableTransactionPool<
|
||||
txpool::BasicPool<
|
||||
txpool::FullChainApi<ConcreteClient, ConcreteBlock>,
|
||||
type ConcreteTransactionPool = sp_transaction_pool::MaintainableTransactionPool<
|
||||
sc_transaction_pool::BasicPool<
|
||||
sc_transaction_pool::FullChainApi<ConcreteClient, ConcreteBlock>,
|
||||
ConcreteBlock
|
||||
>,
|
||||
txpool::FullBasicPoolMaintainer<
|
||||
sc_transaction_pool::FullBasicPoolMaintainer<
|
||||
ConcreteClient,
|
||||
txpool::FullChainApi<ConcreteClient, Block>
|
||||
sc_transaction_pool::FullChainApi<ConcreteClient, Block>
|
||||
>
|
||||
>;
|
||||
|
||||
@@ -306,7 +306,7 @@ pub fn new_full<C: Send + Default + 'static>(config: NodeConfiguration<C>)
|
||||
ConcreteTransactionPool,
|
||||
OffchainWorkers<
|
||||
ConcreteClient,
|
||||
<ConcreteBackend as client_api::backend::Backend<Block, Blake2Hasher>>::OffchainStorage,
|
||||
<ConcreteBackend as sc_client_api::backend::Backend<Block, Blake2Hasher>>::OffchainStorage,
|
||||
ConcreteBlock,
|
||||
>
|
||||
>,
|
||||
@@ -329,10 +329,10 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
|
||||
.with_transaction_pool(|config, client, fetcher| {
|
||||
let fetcher = fetcher
|
||||
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
|
||||
let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone());
|
||||
let pool = txpool::BasicPool::new(config, pool_api);
|
||||
let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
|
||||
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
|
||||
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
|
||||
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
|
||||
let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
|
||||
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
|
||||
Ok(maintainable_pool)
|
||||
})?
|
||||
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
|
||||
@@ -350,14 +350,14 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let (babe_block_import, babe_link) = babe::block_import(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
|
||||
sc_consensus_babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = babe::import_queue(
|
||||
let import_queue = sc_consensus_babe::import_queue(
|
||||
babe_link,
|
||||
babe_block_import,
|
||||
None,
|
||||
@@ -390,15 +390,15 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use babe::CompatibleDigestItem;
|
||||
use consensus_common::{
|
||||
use sc_consensus_babe::CompatibleDigestItem;
|
||||
use sp_consensus::{
|
||||
Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport,
|
||||
};
|
||||
use node_primitives::{Block, DigestItem, Signature};
|
||||
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address};
|
||||
use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::{crypto::Pair as CryptoPair, H256};
|
||||
use sp_core::{crypto::Pair as CryptoPair, H256};
|
||||
use sp_runtime::{
|
||||
generic::{BlockId, Era, Digest, SignedPayload},
|
||||
traits::Block as BlockT,
|
||||
@@ -407,7 +407,7 @@ mod tests {
|
||||
};
|
||||
use sp_timestamp;
|
||||
use sp_finality_tracker;
|
||||
use keyring::AccountKeyring;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use sc_service::{AbstractService, Roles};
|
||||
use crate::service::new_full;
|
||||
use sp_runtime::traits::IdentifyAccount;
|
||||
@@ -416,10 +416,10 @@ mod tests {
|
||||
|
||||
#[cfg(feature = "rhd")]
|
||||
fn test_sync() {
|
||||
use primitives::ed25519::Pair;
|
||||
use sp_core::ed25519::Pair;
|
||||
|
||||
use {service_test, Factory};
|
||||
use client::{BlockImportParams, BlockOrigin};
|
||||
use sc_client::{BlockImportParams, BlockOrigin};
|
||||
|
||||
let alice: Arc<ed25519::Pair> = Arc::new(Keyring::Alice.into());
|
||||
let bob: Arc<ed25519::Pair> = Arc::new(Keyring::Bob.into());
|
||||
@@ -467,8 +467,8 @@ mod tests {
|
||||
let v: Vec<u8> = Decode::decode(&mut xt.as_slice()).unwrap();
|
||||
OpaqueExtrinsic(v)
|
||||
};
|
||||
service_test::sync(
|
||||
chain_spec::integration_test_config(),
|
||||
sc_service_test::sync(
|
||||
sc_chain_spec::integration_test_config(),
|
||||
|config| new_full(config),
|
||||
|mut config| {
|
||||
// light nodes are unsupported
|
||||
@@ -484,9 +484,9 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_sync() {
|
||||
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
|
||||
let keystore = keystore::Store::open(keystore_path.path(), None)
|
||||
let keystore = sc_keystore::Store::open(keystore_path.path(), None)
|
||||
.expect("Creates keystore");
|
||||
let alice = keystore.write().insert_ephemeral_from_seed::<babe::AuthorityPair>("//Alice")
|
||||
let alice = keystore.write().insert_ephemeral_from_seed::<sc_consensus_babe::AuthorityPair>("//Alice")
|
||||
.expect("Creates authority pair");
|
||||
|
||||
let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority();
|
||||
@@ -499,13 +499,13 @@ mod tests {
|
||||
let charlie = Arc::new(AccountKeyring::Charlie.pair());
|
||||
let mut index = 0;
|
||||
|
||||
service_test::sync(
|
||||
sc_service_test::sync(
|
||||
chain_spec,
|
||||
|config| {
|
||||
let mut setup_handles = None;
|
||||
new_full!(config, |
|
||||
block_import: &babe::BabeBlockImport<_, _, Block, _, _, _>,
|
||||
babe_link: &babe::BabeLink<Block>,
|
||||
block_import: &sc_consensus_babe::BabeBlockImport<_, _, Block, _, _, _>,
|
||||
babe_link: &sc_consensus_babe::BabeLink<Block>,
|
||||
| {
|
||||
setup_handles = Some((block_import.clone(), babe_link.clone()));
|
||||
}).map(move |(node, x)| (node, (x, setup_handles.unwrap())))
|
||||
@@ -534,7 +534,7 @@ mod tests {
|
||||
// so we must keep trying the next slots until we can claim one.
|
||||
let babe_pre_digest = loop {
|
||||
inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot_num * SLOT_DURATION));
|
||||
if let Some(babe_pre_digest) = babe::test_helpers::claim_slot(
|
||||
if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot(
|
||||
slot_num,
|
||||
&parent_header,
|
||||
&*service.client(),
|
||||
@@ -594,12 +594,12 @@ mod tests {
|
||||
|
||||
let function = Call::Balances(BalancesCall::transfer(to.into(), amount));
|
||||
|
||||
let check_version = system::CheckVersion::new();
|
||||
let check_genesis = system::CheckGenesis::new();
|
||||
let check_era = system::CheckEra::from(Era::Immortal);
|
||||
let check_nonce = system::CheckNonce::from(index);
|
||||
let check_weight = system::CheckWeight::new();
|
||||
let payment = transaction_payment::ChargeTransactionPayment::from(0);
|
||||
let check_version = frame_system::CheckVersion::new();
|
||||
let check_genesis = frame_system::CheckGenesis::new();
|
||||
let check_era = frame_system::CheckEra::from(Era::Immortal);
|
||||
let check_nonce = frame_system::CheckNonce::from(index);
|
||||
let check_weight = frame_system::CheckWeight::new();
|
||||
let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0);
|
||||
let extra = (
|
||||
check_version,
|
||||
check_genesis,
|
||||
@@ -635,7 +635,7 @@ mod tests {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_consensus() {
|
||||
service_test::consensus(
|
||||
sc_service_test::consensus(
|
||||
crate::chain_spec::tests::integration_test_config_with_two_authorities(),
|
||||
|config| new_full(config),
|
||||
|mut config| {
|
||||
|
||||
@@ -9,27 +9,27 @@ edition = "2018"
|
||||
trie-root = "0.15.2"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
sp-io = { path = "../../../primitives/io" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" }
|
||||
sp-state-machine = { path = "../../../primitives/state-machine" }
|
||||
sc-executor = { path = "../../../client/executor" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
trie = { package = "sp-trie", path = "../../../primitives/trie" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-trie = { path = "../../../primitives/trie" }
|
||||
node-primitives = { path = "../primitives" }
|
||||
node-runtime = { path = "../runtime" }
|
||||
|
||||
[dev-dependencies]
|
||||
node-testing = { path = "../testing" }
|
||||
test-client = { package = "substrate-test-client", path = "../../../test-utils/client" }
|
||||
substrate-test-client = { path = "../../../test-utils/client" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
runtime_support = { package = "frame-support", path = "../../../frame/support" }
|
||||
balances = { package = "pallet-balances", path = "../../../frame/balances" }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" }
|
||||
session = { package = "pallet-session", path = "../../../frame/session" }
|
||||
system = { package = "frame-system", path = "../../../frame/system" }
|
||||
timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp" }
|
||||
treasury = { package = "pallet-treasury", path = "../../../frame/treasury" }
|
||||
contracts = { package = "pallet-contracts", path = "../../../frame/contracts" }
|
||||
grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa" }
|
||||
indices = { package = "pallet-indices", path = "../../../frame/indices" }
|
||||
frame-support = { path = "../../../frame/support" }
|
||||
pallet-balances = { path = "../../../frame/balances" }
|
||||
pallet-transaction-payment = { path = "../../../frame/transaction-payment" }
|
||||
pallet-session = { path = "../../../frame/session" }
|
||||
frame-system = { path = "../../../frame/system" }
|
||||
pallet-timestamp = { path = "../../../frame/timestamp" }
|
||||
pallet-treasury = { path = "../../../frame/treasury" }
|
||||
pallet-contracts = { path = "../../../frame/contracts" }
|
||||
pallet-grandpa = { path = "../../../frame/grandpa" }
|
||||
pallet-indices = { path = "../../../frame/indices" }
|
||||
wabt = "0.9.2"
|
||||
criterion = "0.3.0"
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ use node_runtime::{
|
||||
};
|
||||
use node_runtime::constants::currency::*;
|
||||
use node_testing::keyring::*;
|
||||
use primitives::{Blake2Hasher, NativeOrEncoded, NeverNativeValue};
|
||||
use primitives::storage::well_known_keys;
|
||||
use primitives::traits::CodeExecutor;
|
||||
use runtime_support::Hashable;
|
||||
use state_machine::TestExternalities as CoreTestExternalities;
|
||||
use sp_core::{Blake2Hasher, NativeOrEncoded, NeverNativeValue};
|
||||
use sp_core::storage::well_known_keys;
|
||||
use sp_core::traits::CodeExecutor;
|
||||
use frame_support::Hashable;
|
||||
use sp_state_machine::TestExternalities as CoreTestExternalities;
|
||||
use sc_executor::{NativeExecutor, RuntimeInfo, WasmExecutionMethod, Externalities};
|
||||
|
||||
criterion_group!(benches, bench_execute_block);
|
||||
@@ -70,7 +70,7 @@ fn construct_block<E: Externalities>(
|
||||
parent_hash: Hash,
|
||||
extrinsics: Vec<CheckedExtrinsic>,
|
||||
) -> (Vec<u8>, Hash) {
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
use sp_trie::{TrieConfiguration, trie_types::Layout};
|
||||
|
||||
// sign extrinsics.
|
||||
let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();
|
||||
@@ -131,13 +131,13 @@ fn test_blocks(genesis_config: &GenesisConfig, executor: &NativeExecutor<Executo
|
||||
let mut block1_extrinsics = vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)),
|
||||
},
|
||||
];
|
||||
block1_extrinsics.extend((0..20).map(|i| {
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), signed_extra(i, 0))),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 1 * DOLLARS)),
|
||||
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 1 * DOLLARS)),
|
||||
}
|
||||
}));
|
||||
let block1 = construct_block(
|
||||
|
||||
@@ -32,15 +32,14 @@ native_executor_instance!(
|
||||
mod tests {
|
||||
use sc_executor::error::Result;
|
||||
use super::Executor;
|
||||
use {balances, contracts, indices, system, timestamp};
|
||||
use codec::{Encode, Decode, Joiner};
|
||||
use runtime_support::{
|
||||
use frame_support::{
|
||||
Hashable, StorageValue, StorageMap,
|
||||
traits::Currency,
|
||||
weights::{GetDispatchInfo, DispatchInfo, DispatchClass},
|
||||
};
|
||||
use state_machine::TestExternalities as CoreTestExternalities;
|
||||
use primitives::{
|
||||
use sp_state_machine::TestExternalities as CoreTestExternalities;
|
||||
use sp_core::{
|
||||
Blake2Hasher, NeverNativeValue, NativeOrEncoded, map,
|
||||
traits::{CodeExecutor, Externalities}, storage::{well_known_keys, Storage},
|
||||
};
|
||||
@@ -48,9 +47,9 @@ mod tests {
|
||||
Fixed64, traits::{Header as HeaderT, Hash as HashT, Convert}, ApplyExtrinsicResult,
|
||||
transaction_validity::InvalidTransaction,
|
||||
};
|
||||
use contracts::ContractAddressFor;
|
||||
use pallet_contracts::ContractAddressFor;
|
||||
use sc_executor::{NativeExecutor, WasmExecutionMethod};
|
||||
use system::{EventRecord, Phase};
|
||||
use frame_system::{EventRecord, Phase};
|
||||
use node_runtime::{
|
||||
Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances, BuildStorage,
|
||||
System, TransactionPayment, Event, TransferFee, TransactionBaseFee, TransactionByteFee,
|
||||
@@ -93,13 +92,13 @@ mod tests {
|
||||
(extrinsic.encode().len() as Balance);
|
||||
|
||||
let weight = default_transfer_call().get_dispatch_info().weight;
|
||||
let weight_fee = <Runtime as transaction_payment::Trait>::WeightToFee::convert(weight);
|
||||
let weight_fee = <Runtime as pallet_transaction_payment::Trait>::WeightToFee::convert(weight);
|
||||
|
||||
fee_multiplier.saturated_multiply_accumulate(length_fee + weight_fee) + TransferFee::get()
|
||||
}
|
||||
|
||||
fn default_transfer_call() -> balances::Call<Runtime> {
|
||||
balances::Call::transfer::<Runtime>(bob().into(), 69 * DOLLARS)
|
||||
fn default_transfer_call() -> pallet_balances::Call<Runtime> {
|
||||
pallet_balances::Call::transfer::<Runtime>(bob().into(), 69 * DOLLARS)
|
||||
}
|
||||
|
||||
fn xt() -> UncheckedExtrinsic {
|
||||
@@ -145,16 +144,16 @@ mod tests {
|
||||
fn panic_execution_with_foreign_code_gives_error() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
69_u128.encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
69_u128.encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
|
||||
0_u128.encode()
|
||||
},
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => {
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => {
|
||||
vec![0u8; 32]
|
||||
}
|
||||
],
|
||||
@@ -184,16 +183,16 @@ mod tests {
|
||||
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
69_u128.encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
69_u128.encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
|
||||
0_u128.encode()
|
||||
},
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => {
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => {
|
||||
vec![0u8; 32]
|
||||
}
|
||||
],
|
||||
@@ -223,14 +222,14 @@ mod tests {
|
||||
fn successful_execution_with_native_equivalent_code_gives_ok() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
(111 * DOLLARS).encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
(111 * DOLLARS).encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
],
|
||||
children: map![],
|
||||
});
|
||||
@@ -265,14 +264,14 @@ mod tests {
|
||||
fn successful_execution_with_foreign_code_gives_ok() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
(111 * DOLLARS).encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
(111 * DOLLARS).encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
],
|
||||
children: map![],
|
||||
});
|
||||
@@ -318,7 +317,7 @@ mod tests {
|
||||
parent_hash: Hash,
|
||||
extrinsics: Vec<CheckedExtrinsic>,
|
||||
) -> (Vec<u8>, Hash) {
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
use sp_trie::{TrieConfiguration, trie_types::Layout};
|
||||
|
||||
// sign extrinsics.
|
||||
let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();
|
||||
@@ -379,11 +378,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), signed_extra(0, 0))),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 69 * DOLLARS)),
|
||||
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 69 * DOLLARS)),
|
||||
},
|
||||
]
|
||||
)
|
||||
@@ -401,11 +400,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), signed_extra(0, 0))),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 69 * DOLLARS)),
|
||||
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 69 * DOLLARS)),
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -416,15 +415,15 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(52 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(52 * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((bob(), signed_extra(0, 0))),
|
||||
function: Call::Balances(balances::Call::transfer(alice().into(), 5 * DOLLARS)),
|
||||
function: Call::Balances(pallet_balances::Call::transfer(alice().into(), 5 * DOLLARS)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), signed_extra(1, 0))),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 15 * DOLLARS)),
|
||||
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 15 * DOLLARS)),
|
||||
}
|
||||
]
|
||||
);
|
||||
@@ -444,11 +443,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(time * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((alice(), signed_extra(nonce, 0))),
|
||||
function: Call::System(system::Call::remark(vec![0; size])),
|
||||
function: Call::System(frame_system::Call::remark(vec![0; size])),
|
||||
}
|
||||
]
|
||||
)
|
||||
@@ -478,19 +477,19 @@ mod tests {
|
||||
let events = vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: Event::system(system::Event::ExtrinsicSuccess(
|
||||
event: Event::system(frame_system::Event::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 10000, class: DispatchClass::Operational, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::treasury(treasury::RawEvent::Deposit(1984800000000)),
|
||||
event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984800000000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::balances(balances::RawEvent::Transfer(
|
||||
event: Event::pallet_balances(pallet_balances::RawEvent::Transfer(
|
||||
alice().into(),
|
||||
bob().into(),
|
||||
69 * DOLLARS,
|
||||
@@ -500,7 +499,7 @@ mod tests {
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::system(system::Event::ExtrinsicSuccess(
|
||||
event: Event::system(frame_system::Event::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
@@ -531,20 +530,20 @@ mod tests {
|
||||
let events = vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: Event::system(system::Event::ExtrinsicSuccess(
|
||||
event: Event::system(frame_system::Event::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 10000, class: DispatchClass::Operational, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::treasury(treasury::RawEvent::Deposit(1984780231392)),
|
||||
event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984780231392)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::balances(
|
||||
balances::RawEvent::Transfer(
|
||||
event: Event::pallet_balances(
|
||||
pallet_balances::RawEvent::Transfer(
|
||||
bob().into(),
|
||||
alice().into(),
|
||||
5 * DOLLARS,
|
||||
@@ -555,20 +554,20 @@ mod tests {
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::system(system::Event::ExtrinsicSuccess(
|
||||
event: Event::system(frame_system::Event::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(2),
|
||||
event: Event::treasury(treasury::RawEvent::Deposit(1984780231392)),
|
||||
event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984780231392)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(2),
|
||||
event: Event::balances(
|
||||
balances::RawEvent::Transfer(
|
||||
event: Event::pallet_balances(
|
||||
pallet_balances::RawEvent::Transfer(
|
||||
alice().into(),
|
||||
bob().into(),
|
||||
15 * DOLLARS,
|
||||
@@ -579,7 +578,7 @@ mod tests {
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(2),
|
||||
event: Event::system(system::Event::ExtrinsicSuccess(
|
||||
event: Event::system(frame_system::Event::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
@@ -729,9 +728,9 @@ mod tests {
|
||||
#[test]
|
||||
fn deploying_wasm_contract_should_work() {
|
||||
let transfer_code = wabt::wat2wasm(CODE_TRANSFER).unwrap();
|
||||
let transfer_ch = <Runtime as system::Trait>::Hashing::hash(&transfer_code);
|
||||
let transfer_ch = <Runtime as frame_system::Trait>::Hashing::hash(&transfer_code);
|
||||
|
||||
let addr = <Runtime as contracts::Trait>::DetermineContractAddress::contract_address_for(
|
||||
let addr = <Runtime as pallet_contracts::Trait>::DetermineContractAddress::contract_address_for(
|
||||
&transfer_ch,
|
||||
&[],
|
||||
&charlie(),
|
||||
@@ -744,25 +743,25 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(0, 0))),
|
||||
function: Call::Contracts(
|
||||
contracts::Call::put_code::<Runtime>(10_000, transfer_code)
|
||||
pallet_contracts::Call::put_code::<Runtime>(10_000, transfer_code)
|
||||
),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(1, 0))),
|
||||
function: Call::Contracts(
|
||||
contracts::Call::instantiate::<Runtime>(1 * DOLLARS, 10_000, transfer_ch, Vec::new())
|
||||
pallet_contracts::Call::instantiate::<Runtime>(1 * DOLLARS, 10_000, transfer_ch, Vec::new())
|
||||
),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(2, 0))),
|
||||
function: Call::Contracts(
|
||||
contracts::Call::call::<Runtime>(
|
||||
indices::address::Address::Id(addr.clone()),
|
||||
pallet_contracts::Call::call::<Runtime>(
|
||||
pallet_indices::address::Address::Id(addr.clone()),
|
||||
10,
|
||||
10_000,
|
||||
vec![0x00, 0x01, 0x02, 0x03]
|
||||
@@ -785,7 +784,7 @@ mod tests {
|
||||
t.execute_with(|| {
|
||||
// Verify that the contract constructor worked well and code of TRANSFER contract is actually deployed.
|
||||
assert_eq!(
|
||||
&contracts::ContractInfoOf::<Runtime>::get(addr)
|
||||
&pallet_contracts::ContractInfoOf::<Runtime>::get(addr)
|
||||
.and_then(|c| c.get_alive())
|
||||
.unwrap()
|
||||
.code_hash,
|
||||
@@ -842,14 +841,14 @@ mod tests {
|
||||
fn panic_execution_gives_error() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
0_u128.encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
0_u128.encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
],
|
||||
children: map![],
|
||||
});
|
||||
@@ -877,14 +876,14 @@ mod tests {
|
||||
fn successful_execution_gives_ok() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
(111 * DOLLARS).encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
(111 * DOLLARS).encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
],
|
||||
children: map![],
|
||||
});
|
||||
@@ -952,7 +951,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn should_import_block_with_test_client() {
|
||||
use node_testing::client::{ClientExt, TestClientBuilderExt, TestClientBuilder, consensus::BlockOrigin};
|
||||
use node_testing::client::{
|
||||
ClientExt, TestClientBuilderExt, TestClientBuilder, sp_consensus::BlockOrigin
|
||||
};
|
||||
|
||||
let client = TestClientBuilder::new().build();
|
||||
let block1 = changes_trie_block();
|
||||
@@ -984,11 +985,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(42 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(0, 0))),
|
||||
function: Call::System(system::Call::fill_block()),
|
||||
function: Call::System(frame_system::Call::fill_block()),
|
||||
}
|
||||
]
|
||||
);
|
||||
@@ -1001,11 +1002,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(52 * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(52 * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(1, 0))),
|
||||
function: Call::System(system::Call::remark(vec![0; 1])),
|
||||
function: Call::System(frame_system::Call::remark(vec![0; 1])),
|
||||
}
|
||||
]
|
||||
);
|
||||
@@ -1057,17 +1058,17 @@ mod tests {
|
||||
// (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`)
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
|
||||
(100 * DOLLARS).encode()
|
||||
},
|
||||
<balances::FreeBalance<Runtime>>::hashed_key_for(bob()) => {
|
||||
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(bob()) => {
|
||||
(10 * DOLLARS).encode()
|
||||
},
|
||||
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
(110 * DOLLARS).encode()
|
||||
},
|
||||
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
|
||||
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
|
||||
],
|
||||
children: map![],
|
||||
});
|
||||
@@ -1147,12 +1148,12 @@ mod tests {
|
||||
let num_transfers = block_number * factor;
|
||||
let mut xts = (0..num_transfers).map(|i| CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(nonce + i as Index, 0))),
|
||||
function: Call::Balances(balances::Call::transfer(bob().into(), 0)),
|
||||
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 0)),
|
||||
}).collect::<Vec<CheckedExtrinsic>>();
|
||||
|
||||
xts.insert(0, CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(time * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)),
|
||||
});
|
||||
|
||||
// NOTE: this is super slow. Can probably be improved.
|
||||
@@ -1219,11 +1220,11 @@ mod tests {
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
signed: None,
|
||||
function: Call::Timestamp(timestamp::Call::set(time * 1000)),
|
||||
function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
signed: Some((charlie(), signed_extra(nonce, 0))),
|
||||
function: Call::System(system::Call::remark(vec![0u8; (block_number * factor) as usize])),
|
||||
function: Call::System(frame_system::Call::remark(vec![0u8; (block_number * factor) as usize])),
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../../primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -15,6 +15,6 @@ pretty_assertions = "0.6.1"
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
]
|
||||
|
||||
@@ -47,7 +47,7 @@ pub type Moment = u64;
|
||||
pub type Index = u32;
|
||||
|
||||
/// A hash of some data used by the chain.
|
||||
pub type Hash = primitives::H256;
|
||||
pub type Hash = sp_core::H256;
|
||||
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
/// `u64` is enough to represent a duration of half a billion years, when the
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
client = { package = "sc-client", path = "../../../client/" }
|
||||
sc-client = { path = "../../../client/" }
|
||||
jsonrpc-core = "14.0.3"
|
||||
node-primitives = { path = "../primitives" }
|
||||
node-runtime = { path = "../runtime" }
|
||||
@@ -13,4 +13,4 @@ sp-runtime = { path = "../../../primitives/runtime" }
|
||||
pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" }
|
||||
pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" }
|
||||
substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" }
|
||||
txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" }
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool" }
|
||||
|
||||
@@ -34,12 +34,12 @@ use std::sync::Arc;
|
||||
use node_primitives::{Block, AccountId, Index, Balance};
|
||||
use node_runtime::UncheckedExtrinsic;
|
||||
use sp_runtime::traits::ProvideRuntimeApi;
|
||||
use txpool_api::TransactionPool;
|
||||
use sp_transaction_pool::TransactionPool;
|
||||
|
||||
/// Light client extra dependencies.
|
||||
pub struct LightDeps<F> {
|
||||
/// Remote access to the blockchain (async).
|
||||
pub remote_blockchain: Arc<dyn client::light::blockchain::RemoteBlockchain<Block>>,
|
||||
pub remote_blockchain: Arc<dyn sc_client::light::blockchain::RemoteBlockchain<Block>>,
|
||||
/// Fetcher instance.
|
||||
pub fetcher: Arc<F>,
|
||||
}
|
||||
@@ -63,12 +63,12 @@ pub fn create<C, P, M, F>(
|
||||
light_deps: Option<LightDeps<F>>,
|
||||
) -> jsonrpc_core::IoHandler<M> where
|
||||
C: ProvideRuntimeApi,
|
||||
C: client::blockchain::HeaderBackend<Block>,
|
||||
C: sc_client::blockchain::HeaderBackend<Block>,
|
||||
C: Send + Sync + 'static,
|
||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
|
||||
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance>,
|
||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
|
||||
F: client::light::fetcher::Fetcher<Block> + 'static,
|
||||
F: sc_client::light::fetcher::Fetcher<Block> + 'static,
|
||||
P: TransactionPool + 'static,
|
||||
M: jsonrpc_core::Metadata + Default,
|
||||
{
|
||||
|
||||
@@ -14,53 +14,53 @@ rustc-hex = { version = "2.0", optional = true }
|
||||
serde = { version = "1.0.102", optional = true }
|
||||
|
||||
# primitives
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery", default-features = false }
|
||||
babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false }
|
||||
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false}
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false }
|
||||
sp-authority-discovery = { path = "../../../primitives/authority-discovery", default-features = false }
|
||||
sp-consensus-babe = { path = "../../../primitives/consensus/babe", default-features = false }
|
||||
sp-block-builder = { path = "../../../primitives/block-builder", default-features = false}
|
||||
sp-inherents = { path = "../../../primitives/inherents", default-features = false }
|
||||
node-primitives = { path = "../primitives", default-features = false }
|
||||
offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
|
||||
sp-offchain = { path = "../../../primitives/offchain", default-features = false }
|
||||
sp-core = { path = "../../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../../primitives/std", default-features = false }
|
||||
sp-api = { path = "../../../primitives/api", default-features = false }
|
||||
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../../primitives/staking", default-features = false }
|
||||
sp-keyring = { path = "../../../primitives/keyring", optional = true }
|
||||
sp-session = { path = "../../../primitives/session", default-features = false }
|
||||
sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false }
|
||||
version = { package = "sp-version", path = "../../../primitives/version", default-features = false }
|
||||
sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false }
|
||||
sp-version = { path = "../../../primitives/version", default-features = false }
|
||||
|
||||
# frame dependencies
|
||||
authority-discovery = { package = "pallet-authority-discovery", path = "../../../frame/authority-discovery", default-features = false }
|
||||
authorship = { package = "pallet-authorship", path = "../../../frame/authorship", default-features = false }
|
||||
babe = { package = "pallet-babe", path = "../../../frame/babe", default-features = false }
|
||||
balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false }
|
||||
collective = { package = "pallet-collective", path = "../../../frame/collective", default-features = false }
|
||||
contracts = { package = "pallet-contracts", path = "../../../frame/contracts", default-features = false }
|
||||
contracts-rpc-runtime-api = { package = "pallet-contracts-rpc-runtime-api", path = "../../../frame/contracts/rpc/runtime-api/", default-features = false }
|
||||
democracy = { package = "pallet-democracy", path = "../../../frame/democracy", default-features = false }
|
||||
elections-phragmen = { package = "pallet-elections-phragmen", path = "../../../frame/elections-phragmen", default-features = false }
|
||||
executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false }
|
||||
finality-tracker = { package = "pallet-finality-tracker", path = "../../../frame/finality-tracker", default-features = false }
|
||||
grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false }
|
||||
im-online = { package = "pallet-im-online", path = "../../../frame/im-online", default-features = false }
|
||||
indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false }
|
||||
membership = { package = "pallet-membership", path = "../../../frame/membership", default-features = false }
|
||||
nicks = { package = "pallet-nicks", path = "../../../frame/nicks", default-features = false }
|
||||
offences = { package = "pallet-offences", path = "../../../frame/offences", default-features = false }
|
||||
randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false }
|
||||
session = { package = "pallet-session", path = "../../../frame/session", default-features = false, features = ["historical"] }
|
||||
staking = { package = "pallet-staking", path = "../../../frame/staking", default-features = false, features = ["migrate"] }
|
||||
pallet-authority-discovery = { path = "../../../frame/authority-discovery", default-features = false }
|
||||
pallet-authorship = { path = "../../../frame/authorship", default-features = false }
|
||||
pallet-babe = { path = "../../../frame/babe", default-features = false }
|
||||
pallet-balances = { path = "../../../frame/balances", default-features = false }
|
||||
pallet-collective = { path = "../../../frame/collective", default-features = false }
|
||||
pallet-contracts = { path = "../../../frame/contracts", default-features = false }
|
||||
pallet-contracts-rpc-runtime-api = { path = "../../../frame/contracts/rpc/runtime-api/", default-features = false }
|
||||
pallet-democracy = { path = "../../../frame/democracy", default-features = false }
|
||||
pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", default-features = false }
|
||||
frame-executive = { path = "../../../frame/executive", default-features = false }
|
||||
pallet-finality-tracker = { path = "../../../frame/finality-tracker", default-features = false }
|
||||
pallet-grandpa = { path = "../../../frame/grandpa", default-features = false }
|
||||
pallet-im-online = { path = "../../../frame/im-online", default-features = false }
|
||||
pallet-indices = { path = "../../../frame/indices", default-features = false }
|
||||
pallet-membership = { path = "../../../frame/membership", default-features = false }
|
||||
pallet-nicks = { path = "../../../frame/nicks", default-features = false }
|
||||
pallet-offences = { path = "../../../frame/offences", default-features = false }
|
||||
pallet-randomness-collective-flip = { path = "../../../frame/randomness-collective-flip", default-features = false }
|
||||
pallet-session = { path = "../../../frame/session", default-features = false, features = ["historical"] }
|
||||
pallet-staking = { path = "../../../frame/staking", default-features = false, features = ["migrate"] }
|
||||
pallet-staking-reward-curve = { path = "../../../frame/staking/reward-curve"}
|
||||
sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false }
|
||||
support = { package = "frame-support", path = "../../../frame/support", default-features = false }
|
||||
system = { package = "frame-system", path = "../../../frame/system", default-features = false }
|
||||
system-rpc-runtime-api = { package = "frame-system-rpc-runtime-api", path = "../../../frame/system/rpc/runtime-api/", default-features = false }
|
||||
timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false }
|
||||
treasury = { package = "pallet-treasury", path = "../../../frame/treasury", default-features = false }
|
||||
utility = { package = "frame-utility", path = "../../../frame/utility", default-features = false }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false }
|
||||
transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false }
|
||||
pallet-sudo = { path = "../../../frame/sudo", default-features = false }
|
||||
frame-support = { path = "../../../frame/support", default-features = false }
|
||||
frame-system = { path = "../../../frame/system", default-features = false }
|
||||
frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api/", default-features = false }
|
||||
pallet-timestamp = { path = "../../../frame/timestamp", default-features = false }
|
||||
pallet-treasury = { path = "../../../frame/treasury", default-features = false }
|
||||
frame-utility = { path = "../../../frame/utility", default-features = false }
|
||||
pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false }
|
||||
pallet-transaction-payment-rpc-runtime-api = { path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" }
|
||||
@@ -71,52 +71,52 @@ sp-io = { path = "../../../primitives/io" }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"authority-discovery-primitives/std",
|
||||
"authority-discovery/std",
|
||||
"authorship/std",
|
||||
"babe-primitives/std",
|
||||
"babe/std",
|
||||
"balances/std",
|
||||
"block-builder-api/std",
|
||||
"sp-authority-discovery/std",
|
||||
"pallet-authority-discovery/std",
|
||||
"pallet-authorship/std",
|
||||
"sp-consensus-babe/std",
|
||||
"pallet-babe/std",
|
||||
"pallet-balances/std",
|
||||
"sp-block-builder/std",
|
||||
"codec/std",
|
||||
"collective/std",
|
||||
"contracts-rpc-runtime-api/std",
|
||||
"contracts/std",
|
||||
"democracy/std",
|
||||
"elections-phragmen/std",
|
||||
"executive/std",
|
||||
"finality-tracker/std",
|
||||
"grandpa/std",
|
||||
"im-online/std",
|
||||
"indices/std",
|
||||
"inherents/std",
|
||||
"membership/std",
|
||||
"nicks/std",
|
||||
"pallet-collective/std",
|
||||
"pallet-contracts-rpc-runtime-api/std",
|
||||
"pallet-contracts/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",
|
||||
"sp-inherents/std",
|
||||
"pallet-membership/std",
|
||||
"pallet-nicks/std",
|
||||
"node-primitives/std",
|
||||
"offchain-primitives/std",
|
||||
"offences/std",
|
||||
"primitives/std",
|
||||
"randomness-collective-flip/std",
|
||||
"sp-offchain/std",
|
||||
"pallet-offences/std",
|
||||
"sp-core/std",
|
||||
"pallet-randomness-collective-flip/std",
|
||||
"sp-std/std",
|
||||
"rustc-hex",
|
||||
"safe-mix/std",
|
||||
"serde",
|
||||
"session/std",
|
||||
"pallet-session/std",
|
||||
"sp-api/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"staking/std",
|
||||
"pallet-staking/std",
|
||||
"sp-keyring",
|
||||
"sp-session/std",
|
||||
"sudo/std",
|
||||
"support/std",
|
||||
"system-rpc-runtime-api/std",
|
||||
"system/std",
|
||||
"timestamp/std",
|
||||
"transaction-payment-rpc-runtime-api/std",
|
||||
"transaction-payment/std",
|
||||
"treasury/std",
|
||||
"pallet-sudo/std",
|
||||
"frame-support/std",
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"frame-system/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-transaction-payment-rpc-runtime-api/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"pallet-treasury/std",
|
||||
"sp-transaction-pool/std",
|
||||
"utility/std",
|
||||
"version/std",
|
||||
"frame-utility/std",
|
||||
"sp-version/std",
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use node_primitives::Balance;
|
||||
use sp_runtime::traits::{Convert, Saturating};
|
||||
use sp_runtime::{Fixed64, Perbill};
|
||||
use support::{traits::{OnUnbalanced, Currency, Get}, weights::Weight};
|
||||
use frame_support::{traits::{OnUnbalanced, Currency, Get}, weights::Weight};
|
||||
use crate::{Balances, System, Authorship, MaximumBlockWeight, NegativeImbalance};
|
||||
|
||||
pub struct Author;
|
||||
@@ -118,7 +118,7 @@ mod tests {
|
||||
use sp_runtime::assert_eq_error_rate;
|
||||
use crate::{MaximumBlockWeight, AvailableBlockRatio, Runtime};
|
||||
use crate::{constants::currency::*, TransactionPayment, TargetBlockFullness};
|
||||
use support::weights::Weight;
|
||||
use frame_support::weights::Weight;
|
||||
|
||||
fn max() -> Weight {
|
||||
MaximumBlockWeight::get()
|
||||
@@ -151,7 +151,7 @@ mod tests {
|
||||
|
||||
fn run_with_system_weight<F>(w: Weight, assertions: F) where F: Fn() -> () {
|
||||
let mut t: sp_io::TestExternalities =
|
||||
system::GenesisConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||
frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||
t.execute_with(|| {
|
||||
System::set_block_limits(w, 0);
|
||||
assertions()
|
||||
@@ -227,7 +227,7 @@ mod tests {
|
||||
if fm == next { panic!("The fee should ever increase"); }
|
||||
fm = next;
|
||||
iterations += 1;
|
||||
let fee = <Runtime as transaction_payment::Trait>::WeightToFee::convert(tx_weight);
|
||||
let fee = <Runtime as pallet_transaction_payment::Trait>::WeightToFee::convert(tx_weight);
|
||||
let adjusted_fee = fm.saturated_multiply_accumulate(fee);
|
||||
println!(
|
||||
"iteration {}, new fm = {:?}. Fee at this point is: {} units / {} millicents, \
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
weights::Weight,
|
||||
traits::{SplitTwoWays, Currency, Randomness},
|
||||
};
|
||||
use primitives::u32_trait::{_1, _2, _3, _4};
|
||||
use sp_core::u32_trait::{_1, _2, _3, _4};
|
||||
use node_primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_runtime::{Permill, Perbill, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str};
|
||||
@@ -36,26 +36,26 @@ use sp_runtime::traits::{
|
||||
self, BlakeTwo256, Block as BlockT, NumberFor, StaticLookup, SaturatedConversion,
|
||||
OpaqueKeys,
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use version::NativeVersion;
|
||||
use primitives::OpaqueMetadata;
|
||||
use grandpa::AuthorityList as GrandpaAuthorityList;
|
||||
use grandpa::fg_primitives;
|
||||
use im_online::sr25519::{AuthorityId as ImOnlineId};
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use contracts_rpc_runtime_api::ContractExecResult;
|
||||
use system::offchain::TransactionSubmitter;
|
||||
use inherents::{InherentData, CheckInherentsResult};
|
||||
use sp_version::NativeVersion;
|
||||
use sp_core::OpaqueMetadata;
|
||||
use pallet_grandpa::AuthorityList as GrandpaAuthorityList;
|
||||
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;
|
||||
use pallet_contracts_rpc_runtime_api::ContractExecResult;
|
||||
use frame_system::offchain::TransactionSubmitter;
|
||||
use sp_inherents::{InherentData, CheckInherentsResult};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use timestamp::Call as TimestampCall;
|
||||
pub use balances::Call as BalancesCall;
|
||||
pub use contracts::Gas;
|
||||
pub use support::StorageValue;
|
||||
pub use staking::StakerStatus;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_contracts::Gas;
|
||||
pub use frame_support::StorageValue;
|
||||
pub use pallet_staking::StakerStatus;
|
||||
|
||||
/// Implementations of some helper traits passed into runtime modules as associated types.
|
||||
pub mod impls;
|
||||
@@ -109,7 +109,7 @@ parameter_types! {
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
}
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
impl frame_system::Trait for Runtime {
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type Index = Index;
|
||||
@@ -127,7 +127,7 @@ impl system::Trait for Runtime {
|
||||
type Version = Version;
|
||||
}
|
||||
|
||||
impl utility::Trait for Runtime {
|
||||
impl frame_utility::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
@@ -137,16 +137,16 @@ parameter_types! {
|
||||
pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
||||
}
|
||||
|
||||
impl babe::Trait for Runtime {
|
||||
impl pallet_babe::Trait for Runtime {
|
||||
type EpochDuration = EpochDuration;
|
||||
type ExpectedBlockTime = ExpectedBlockTime;
|
||||
type EpochChangeTrigger = babe::ExternalTrigger;
|
||||
type EpochChangeTrigger = pallet_babe::ExternalTrigger;
|
||||
}
|
||||
|
||||
impl indices::Trait for Runtime {
|
||||
impl pallet_indices::Trait for Runtime {
|
||||
type AccountIndex = AccountIndex;
|
||||
type IsDeadAccount = Balances;
|
||||
type ResolveHint = indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
|
||||
type ResolveHint = pallet_indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ parameter_types! {
|
||||
pub const CreationFee: Balance = 1 * CENTS;
|
||||
}
|
||||
|
||||
impl balances::Trait for Runtime {
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
type Balance = Balance;
|
||||
type OnFreeBalanceZero = ((Staking, Contracts), Session);
|
||||
type OnNewAccount = Indices;
|
||||
@@ -177,7 +177,7 @@ parameter_types! {
|
||||
pub const TargetBlockFullness: Perbill = Perbill::from_percent(25);
|
||||
}
|
||||
|
||||
impl transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type OnTransactionPayment = DealWithFees;
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
@@ -189,7 +189,7 @@ impl transaction_payment::Trait for Runtime {
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
|
||||
}
|
||||
impl timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
type Moment = Moment;
|
||||
type OnTimestampSet = Babe;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
@@ -199,8 +199,8 @@ parameter_types! {
|
||||
pub const UncleGenerations: BlockNumber = 5;
|
||||
}
|
||||
|
||||
impl authorship::Trait for Runtime {
|
||||
type FindAuthor = session::FindAccountFromAuthorIndex<Self, Babe>;
|
||||
impl pallet_authorship::Trait for Runtime {
|
||||
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
|
||||
type UncleGenerations = UncleGenerations;
|
||||
type FilterUncle = ();
|
||||
type EventHandler = (Staking, ImOnline);
|
||||
@@ -219,21 +219,21 @@ parameter_types! {
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
|
||||
}
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
impl pallet_session::Trait for Runtime {
|
||||
type OnSessionEnding = Staking;
|
||||
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
|
||||
type ShouldEndSession = Babe;
|
||||
type Event = Event;
|
||||
type Keys = SessionKeys;
|
||||
type ValidatorId = <Self as system::Trait>::AccountId;
|
||||
type ValidatorIdOf = staking::StashOf<Self>;
|
||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
||||
type ValidatorIdOf = pallet_staking::StashOf<Self>;
|
||||
type SelectInitialValidators = Staking;
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
}
|
||||
|
||||
impl session::historical::Trait for Runtime {
|
||||
type FullIdentification = staking::Exposure<AccountId, Balance>;
|
||||
type FullIdentificationOf = staking::ExposureOf<Runtime>;
|
||||
impl pallet_session::historical::Trait for Runtime {
|
||||
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
|
||||
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
|
||||
}
|
||||
|
||||
pallet_staking_reward_curve::build! {
|
||||
@@ -249,12 +249,12 @@ pallet_staking_reward_curve::build! {
|
||||
|
||||
parameter_types! {
|
||||
pub const SessionsPerEra: sp_staking::SessionIndex = 6;
|
||||
pub const BondingDuration: staking::EraIndex = 24 * 28;
|
||||
pub const SlashDeferDuration: staking::EraIndex = 24 * 7; // 1/4 the bonding duration.
|
||||
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;
|
||||
}
|
||||
|
||||
impl staking::Trait for Runtime {
|
||||
impl pallet_staking::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type Time = Timestamp;
|
||||
type CurrencyToVote = CurrencyToVoteHandler;
|
||||
@@ -266,7 +266,7 @@ impl staking::Trait for Runtime {
|
||||
type BondingDuration = BondingDuration;
|
||||
type SlashDeferDuration = SlashDeferDuration;
|
||||
/// A super-majority of the council can cancel the slash.
|
||||
type SlashCancelOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
|
||||
type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
|
||||
type SessionInterface = Self;
|
||||
type RewardCurve = RewardCurve;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ parameter_types! {
|
||||
pub const PreimageByteDeposit: Balance = 1 * CENTS;
|
||||
}
|
||||
|
||||
impl democracy::Trait for Runtime {
|
||||
impl pallet_democracy::Trait for Runtime {
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
@@ -292,27 +292,27 @@ impl democracy::Trait for Runtime {
|
||||
type EmergencyVotingPeriod = EmergencyVotingPeriod;
|
||||
type MinimumDeposit = MinimumDeposit;
|
||||
/// A straight majority of the council can decide what their next motion is.
|
||||
type ExternalOrigin = collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
|
||||
type ExternalOrigin = pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
|
||||
/// A super-majority can have the next scheduled referendum be a straight majority-carries vote.
|
||||
type ExternalMajorityOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
|
||||
type ExternalMajorityOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
|
||||
/// A unanimous council can have the next scheduled referendum be a straight default-carries
|
||||
/// (NTB) vote.
|
||||
type ExternalDefaultOrigin = collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>;
|
||||
type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>;
|
||||
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
|
||||
/// be tabled immediately and with a shorter voting/enactment period.
|
||||
type FastTrackOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;
|
||||
type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;
|
||||
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
|
||||
type CancellationOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>;
|
||||
type CancellationOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>;
|
||||
// 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 = collective::EnsureMember<AccountId, TechnicalCollective>;
|
||||
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
|
||||
type CooloffPeriod = CooloffPeriod;
|
||||
type PreimageByteDeposit = PreimageByteDeposit;
|
||||
type Slash = Treasury;
|
||||
}
|
||||
|
||||
type CouncilCollective = collective::Instance1;
|
||||
impl collective::Trait<CouncilCollective> for Runtime {
|
||||
type CouncilCollective = pallet_collective::Instance1;
|
||||
impl pallet_collective::Trait<CouncilCollective> for Runtime {
|
||||
type Origin = Origin;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
@@ -326,7 +326,7 @@ parameter_types! {
|
||||
pub const DesiredRunnersUp: u32 = 7;
|
||||
}
|
||||
|
||||
impl elections_phragmen::Trait for Runtime {
|
||||
impl pallet_elections_phragmen::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type CurrencyToVote = CurrencyToVoteHandler;
|
||||
@@ -341,19 +341,19 @@ impl elections_phragmen::Trait for Runtime {
|
||||
type ChangeMembers = Council;
|
||||
}
|
||||
|
||||
type TechnicalCollective = collective::Instance2;
|
||||
impl collective::Trait<TechnicalCollective> for Runtime {
|
||||
type TechnicalCollective = pallet_collective::Instance2;
|
||||
impl pallet_collective::Trait<TechnicalCollective> for Runtime {
|
||||
type Origin = Origin;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl membership::Trait<membership::Instance1> for Runtime {
|
||||
impl pallet_membership::Trait<pallet_membership::Instance1> for Runtime {
|
||||
type Event = Event;
|
||||
type AddOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type RemoveOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type SwapOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type ResetOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type AddOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type RemoveOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type SwapOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type ResetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type MembershipInitialized = TechnicalCommittee;
|
||||
type MembershipChanged = TechnicalCommittee;
|
||||
}
|
||||
@@ -365,10 +365,10 @@ parameter_types! {
|
||||
pub const Burn: Permill = Permill::from_percent(50);
|
||||
}
|
||||
|
||||
impl treasury::Trait for Runtime {
|
||||
impl pallet_treasury::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type ApproveOrigin = collective::EnsureMembers<_4, AccountId, CouncilCollective>;
|
||||
type RejectOrigin = collective::EnsureMembers<_2, AccountId, CouncilCollective>;
|
||||
type ApproveOrigin = pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>;
|
||||
type RejectOrigin = pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>;
|
||||
type Event = Event;
|
||||
type ProposalRejection = ();
|
||||
type ProposalBond = ProposalBond;
|
||||
@@ -389,20 +389,20 @@ parameter_types! {
|
||||
pub const SurchargeReward: Balance = 150 * DOLLARS;
|
||||
}
|
||||
|
||||
impl contracts::Trait for Runtime {
|
||||
impl pallet_contracts::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type Time = Timestamp;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type Call = Call;
|
||||
type Event = Event;
|
||||
type DetermineContractAddress = contracts::SimpleAddressDeterminator<Runtime>;
|
||||
type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor<Runtime>;
|
||||
type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;
|
||||
type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminator<Runtime>;
|
||||
type ComputeDispatchFee = pallet_contracts::DefaultDispatchFeeComputor<Runtime>;
|
||||
type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;
|
||||
type GasPayment = ();
|
||||
type RentPayment = ();
|
||||
type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;
|
||||
type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;
|
||||
type TombstoneDeposit = TombstoneDeposit;
|
||||
type StorageSizeOffset = contracts::DefaultStorageSizeOffset;
|
||||
type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;
|
||||
type RentByteFee = RentByteFee;
|
||||
type RentDepositOffset = RentDepositOffset;
|
||||
type SurchargeReward = SurchargeReward;
|
||||
@@ -411,14 +411,14 @@ impl contracts::Trait for Runtime {
|
||||
type TransactionBaseFee = ContractTransactionBaseFee;
|
||||
type TransactionByteFee = ContractTransactionByteFee;
|
||||
type ContractFee = ContractFee;
|
||||
type CallBaseFee = contracts::DefaultCallBaseFee;
|
||||
type InstantiateBaseFee = contracts::DefaultInstantiateBaseFee;
|
||||
type MaxDepth = contracts::DefaultMaxDepth;
|
||||
type MaxValueSize = contracts::DefaultMaxValueSize;
|
||||
type BlockGasLimit = contracts::DefaultBlockGasLimit;
|
||||
type CallBaseFee = pallet_contracts::DefaultCallBaseFee;
|
||||
type InstantiateBaseFee = pallet_contracts::DefaultInstantiateBaseFee;
|
||||
type MaxDepth = pallet_contracts::DefaultMaxDepth;
|
||||
type MaxValueSize = pallet_contracts::DefaultMaxValueSize;
|
||||
type BlockGasLimit = pallet_contracts::DefaultBlockGasLimit;
|
||||
}
|
||||
|
||||
impl sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Proposal = Call;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ parameter_types! {
|
||||
pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _;
|
||||
}
|
||||
|
||||
impl im_online::Trait for Runtime {
|
||||
impl pallet_im_online::Trait for Runtime {
|
||||
type AuthorityId = ImOnlineId;
|
||||
type Call = Call;
|
||||
type Event = Event;
|
||||
@@ -438,15 +438,15 @@ impl im_online::Trait for Runtime {
|
||||
type SessionDuration = SessionDuration;
|
||||
}
|
||||
|
||||
impl offences::Trait for Runtime {
|
||||
impl pallet_offences::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
|
||||
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
}
|
||||
|
||||
impl authority_discovery::Trait for Runtime {}
|
||||
impl pallet_authority_discovery::Trait for Runtime {}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
impl pallet_grandpa::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ parameter_types! {
|
||||
pub const ReportLatency: BlockNumber = 1000;
|
||||
}
|
||||
|
||||
impl finality_tracker::Trait for Runtime {
|
||||
impl pallet_finality_tracker::Trait for Runtime {
|
||||
type OnFinalizationStalled = Grandpa;
|
||||
type WindowSize = WindowSize;
|
||||
type ReportLatency = ReportLatency;
|
||||
@@ -467,21 +467,21 @@ parameter_types! {
|
||||
pub const MaxLength: usize = 16;
|
||||
}
|
||||
|
||||
impl nicks::Trait for Runtime {
|
||||
impl pallet_nicks::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type ReservationFee = ReservationFee;
|
||||
type Slashed = Treasury;
|
||||
type ForceOrigin = collective::EnsureMember<AccountId, CouncilCollective>;
|
||||
type ForceOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
|
||||
type MinLength = MinLength;
|
||||
type MaxLength = MaxLength;
|
||||
}
|
||||
|
||||
impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
|
||||
impl frame_system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtime {
|
||||
type Public = <Signature as traits::Verify>::Signer;
|
||||
type Signature = Signature;
|
||||
|
||||
fn create_transaction<TSigner: system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
fn create_transaction<TSigner: frame_system::offchain::Signer<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
public: Self::Public,
|
||||
account: AccountId,
|
||||
@@ -491,12 +491,12 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
|
||||
let current_block = System::block_number().saturated_into::<u64>();
|
||||
let tip = 0;
|
||||
let extra: SignedExtra = (
|
||||
system::CheckVersion::<Runtime>::new(),
|
||||
system::CheckGenesis::<Runtime>::new(),
|
||||
system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
|
||||
system::CheckNonce::<Runtime>::from(index),
|
||||
system::CheckWeight::<Runtime>::new(),
|
||||
transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
frame_system::CheckVersion::<Runtime>::new(),
|
||||
frame_system::CheckGenesis::<Runtime>::new(),
|
||||
frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
|
||||
frame_system::CheckNonce::<Runtime>::from(index),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
Default::default(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).ok()?;
|
||||
@@ -507,6 +507,7 @@ impl system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> for Runtim
|
||||
}
|
||||
}
|
||||
|
||||
use frame_system as system;
|
||||
construct_runtime!(
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
@@ -514,30 +515,30 @@ construct_runtime!(
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{Module, Call, Storage, Config, Event},
|
||||
Utility: utility::{Module, Call, Event},
|
||||
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
||||
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
||||
Authorship: authorship::{Module, Call, Storage, Inherent},
|
||||
Indices: indices,
|
||||
Balances: balances::{default, Error},
|
||||
TransactionPayment: transaction_payment::{Module, Storage},
|
||||
Staking: staking::{default, OfflineWorker},
|
||||
Session: session::{Module, Call, Storage, Event, Config<T>},
|
||||
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
|
||||
Council: collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
|
||||
TechnicalCommittee: collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
|
||||
Elections: elections_phragmen::{Module, Call, Storage, Event<T>},
|
||||
TechnicalMembership: membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
|
||||
FinalityTracker: finality_tracker::{Module, Call, Inherent},
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
|
||||
Treasury: treasury::{Module, Call, Storage, Config, Event<T>},
|
||||
Contracts: contracts,
|
||||
Sudo: sudo,
|
||||
ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
|
||||
AuthorityDiscovery: authority_discovery::{Module, Call, Config},
|
||||
Offences: offences::{Module, Call, Storage, Event},
|
||||
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
|
||||
Nicks: nicks::{Module, Call, Storage, Event<T>},
|
||||
Utility: frame_utility::{Module, Call, Event},
|
||||
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
||||
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
|
||||
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
|
||||
Indices: pallet_indices,
|
||||
Balances: pallet_balances::{default, Error},
|
||||
TransactionPayment: pallet_transaction_payment::{Module, Storage},
|
||||
Staking: pallet_staking::{default, OfflineWorker},
|
||||
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
|
||||
Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>},
|
||||
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
|
||||
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
|
||||
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>},
|
||||
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
|
||||
FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
|
||||
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
|
||||
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
|
||||
Contracts: pallet_contracts,
|
||||
Sudo: pallet_sudo,
|
||||
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
|
||||
Offences: pallet_offences::{Module, Call, Storage, Event},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
Nicks: pallet_nicks::{Module, Call, Storage, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -553,13 +554,13 @@ pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
pub type SignedExtra = (
|
||||
system::CheckVersion<Runtime>,
|
||||
system::CheckGenesis<Runtime>,
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
contracts::CheckBlockGasLimit<Runtime>,
|
||||
frame_system::CheckVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
pallet_contracts::CheckBlockGasLimit<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
@@ -568,7 +569,7 @@ pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
pub type Executive = frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
@@ -591,7 +592,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl block_builder_api::BlockBuilder<Block> for Runtime {
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
@@ -619,7 +620,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
|
||||
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(number: NumberFor<Block>) {
|
||||
Executive::offchain_worker(number)
|
||||
}
|
||||
@@ -631,14 +632,14 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl babe_primitives::BabeApi<Block> for Runtime {
|
||||
fn configuration() -> babe_primitives::BabeConfiguration {
|
||||
impl sp_consensus_babe::BabeApi<Block> for Runtime {
|
||||
fn configuration() -> sp_consensus_babe::BabeConfiguration {
|
||||
// The choice of `c` parameter (where `1 - c` represents the
|
||||
// probability of a slot being empty), is done in accordance to the
|
||||
// slot duration and expected target block time, for safely
|
||||
// resisting network delays of maximum two seconds.
|
||||
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
||||
babe_primitives::BabeConfiguration {
|
||||
sp_consensus_babe::BabeConfiguration {
|
||||
slot_duration: Babe::slot_duration(),
|
||||
epoch_length: EpochDuration::get(),
|
||||
c: PRIMARY_PROBABILITY,
|
||||
@@ -649,19 +650,19 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
||||
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
|
||||
fn authorities() -> Vec<AuthorityDiscoveryId> {
|
||||
AuthorityDiscovery::authorities()
|
||||
}
|
||||
}
|
||||
|
||||
impl system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
|
||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Index {
|
||||
System::account_nonce(account)
|
||||
}
|
||||
}
|
||||
|
||||
impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance> for Runtime {
|
||||
impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance> for Runtime {
|
||||
fn call(
|
||||
origin: AccountId,
|
||||
dest: AccountId,
|
||||
@@ -688,10 +689,10 @@ impl_runtime_apis! {
|
||||
fn get_storage(
|
||||
address: AccountId,
|
||||
key: [u8; 32],
|
||||
) -> contracts_rpc_runtime_api::GetStorageResult {
|
||||
) -> pallet_contracts_rpc_runtime_api::GetStorageResult {
|
||||
Contracts::get_storage(address, key).map_err(|rpc_err| {
|
||||
use contracts::GetStorageError;
|
||||
use contracts_rpc_runtime_api::{GetStorageError as RpcGetStorageError};
|
||||
use pallet_contracts::GetStorageError;
|
||||
use pallet_contracts_rpc_runtime_api::{GetStorageError as RpcGetStorageError};
|
||||
/// Map the contract error into the RPC layer error.
|
||||
match rpc_err {
|
||||
GetStorageError::ContractDoesntExist => RpcGetStorageError::ContractDoesntExist,
|
||||
@@ -701,7 +702,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl transaction_payment_rpc_runtime_api::TransactionPaymentApi<
|
||||
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
|
||||
Block,
|
||||
Balance,
|
||||
UncheckedExtrinsic,
|
||||
@@ -721,7 +722,7 @@ impl_runtime_apis! {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use system::offchain::SubmitSignedTransaction;
|
||||
use frame_system::offchain::SubmitSignedTransaction;
|
||||
|
||||
fn is_submit_signed_transaction<T>(_arg: T) where
|
||||
T: SubmitSignedTransaction<
|
||||
@@ -741,7 +742,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_hooks_weight_should_not_exceed_limits() {
|
||||
use support::weights::WeighBlock;
|
||||
use frame_support::weights::WeighBlock;
|
||||
let check_for_block = |b| {
|
||||
let block_hooks_weight =
|
||||
<AllModules as WeighBlock<BlockNumber>>::on_initialize(b) +
|
||||
|
||||
@@ -6,26 +6,26 @@ description = "Test utilities for Substrate node."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
balances = { package = "pallet-balances", path = "../../../frame/balances" }
|
||||
client = { package = "sc-client", path = "../../../client/" }
|
||||
pallet-balances = { path = "../../../frame/balances" }
|
||||
sc-client = { path = "../../../client/" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
contracts = { package = "pallet-contracts", path = "../../../frame/contracts" }
|
||||
grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa" }
|
||||
indices = { package = "pallet-indices", path = "../../../frame/indices" }
|
||||
keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
|
||||
pallet-contracts = { path = "../../../frame/contracts" }
|
||||
pallet-grandpa = { path = "../../../frame/grandpa" }
|
||||
pallet-indices = { path = "../../../frame/indices" }
|
||||
sp-keyring = { path = "../../../primitives/keyring" }
|
||||
node-executor = { path = "../executor" }
|
||||
node-primitives = { path = "../primitives" }
|
||||
node-runtime = { path = "../runtime" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-io = { path = "../../../primitives/io" }
|
||||
runtime_support = { package = "frame-support", path = "../../../frame/support" }
|
||||
session = { package = "pallet-session", path = "../../../frame/session" }
|
||||
frame-support = { path = "../../../frame/support" }
|
||||
pallet-session = { path = "../../../frame/session" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
staking = { package = "pallet-staking", path = "../../../frame/staking" }
|
||||
pallet-staking = { path = "../../../frame/staking" }
|
||||
sc-executor = { path = "../../../client/executor" }
|
||||
system = { package = "frame-system", path = "../../../frame/system" }
|
||||
test-client = { package = "substrate-test-client", path = "../../../test-utils/client" }
|
||||
timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp" }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" }
|
||||
treasury = { package = "pallet-treasury", path = "../../../frame/treasury" }
|
||||
frame-system = { path = "../../../frame/system" }
|
||||
substrate-test-client = { path = "../../../test-utils/client" }
|
||||
pallet-timestamp = { path = "../../../frame/timestamp" }
|
||||
pallet-transaction-payment = { path = "../../../frame/transaction-payment" }
|
||||
pallet-treasury = { path = "../../../frame/treasury" }
|
||||
wabt = "0.9.2"
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
use sp_runtime::BuildStorage;
|
||||
|
||||
/// Re-export test-client utilities.
|
||||
pub use test_client::*;
|
||||
pub use substrate_test_client::*;
|
||||
|
||||
/// Call executor for `node-runtime` `TestClient`.
|
||||
pub type Executor = sc_executor::NativeExecutor<node_executor::Executor>;
|
||||
|
||||
/// Default backend type.
|
||||
pub type Backend = client_db::Backend<node_primitives::Block>;
|
||||
pub type Backend = sc_client_db::Backend<node_primitives::Block>;
|
||||
|
||||
/// Test client type.
|
||||
pub type Client = client::Client<
|
||||
pub type Client = sc_client::Client<
|
||||
Backend,
|
||||
client::LocalCallExecutor<Backend, Executor>,
|
||||
sc_client::LocalCallExecutor<Backend, Executor>,
|
||||
node_primitives::Block,
|
||||
node_runtime::RuntimeApi,
|
||||
>;
|
||||
@@ -41,7 +41,7 @@ pub struct GenesisParameters {
|
||||
support_changes_trie: bool,
|
||||
}
|
||||
|
||||
impl test_client::GenesisInit for GenesisParameters {
|
||||
impl substrate_test_client::GenesisInit for GenesisParameters {
|
||||
fn genesis_storage(&self) -> Storage {
|
||||
crate::genesis::config(self.support_changes_trie, None).build_storage().unwrap()
|
||||
}
|
||||
@@ -56,8 +56,8 @@ pub trait TestClientBuilderExt: Sized {
|
||||
fn build(self) -> Client;
|
||||
}
|
||||
|
||||
impl TestClientBuilderExt for test_client::TestClientBuilder<
|
||||
client::LocalCallExecutor<Backend, Executor>,
|
||||
impl TestClientBuilderExt for substrate_test_client::TestClientBuilder<
|
||||
sc_client::LocalCallExecutor<Backend, Executor>,
|
||||
Backend,
|
||||
GenesisParameters,
|
||||
> {
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
//! Genesis Configuration.
|
||||
|
||||
use crate::keyring::*;
|
||||
use keyring::{Ed25519Keyring, Sr25519Keyring};
|
||||
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
|
||||
use node_runtime::{
|
||||
GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, SystemConfig,
|
||||
GrandpaConfig, IndicesConfig, ContractsConfig, WASM_BINARY,
|
||||
};
|
||||
use node_runtime::constants::currency::*;
|
||||
use primitives::ChangesTrieConfiguration;
|
||||
use sp_core::ChangesTrieConfiguration;
|
||||
use sp_runtime::Perbill;
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig
|
||||
}) } else { None },
|
||||
code: code.map(|x| x.to_vec()).unwrap_or_else(|| WASM_BINARY.to_vec()),
|
||||
}),
|
||||
indices: Some(IndicesConfig {
|
||||
pallet_indices: Some(IndicesConfig {
|
||||
ids: vec![alice(), bob(), charlie(), dave(), eve(), ferdie()],
|
||||
}),
|
||||
balances: Some(BalancesConfig {
|
||||
pallet_balances: Some(BalancesConfig {
|
||||
balances: vec![
|
||||
(alice(), 111 * DOLLARS),
|
||||
(bob(), 100 * DOLLARS),
|
||||
@@ -51,7 +51,7 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig
|
||||
],
|
||||
vesting: vec![],
|
||||
}),
|
||||
session: Some(SessionConfig {
|
||||
pallet_session: Some(SessionConfig {
|
||||
keys: vec![
|
||||
(alice(), to_session_keys(
|
||||
&Ed25519Keyring::Alice,
|
||||
@@ -67,12 +67,12 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig
|
||||
)),
|
||||
]
|
||||
}),
|
||||
staking: Some(StakingConfig {
|
||||
pallet_staking: Some(StakingConfig {
|
||||
current_era: 0,
|
||||
stakers: vec![
|
||||
(dave(), alice(), 111 * DOLLARS, staking::StakerStatus::Validator),
|
||||
(eve(), bob(), 100 * DOLLARS, staking::StakerStatus::Validator),
|
||||
(ferdie(), charlie(), 100 * DOLLARS, staking::StakerStatus::Validator)
|
||||
(dave(), alice(), 111 * DOLLARS, pallet_staking::StakerStatus::Validator),
|
||||
(eve(), bob(), 100 * DOLLARS, pallet_staking::StakerStatus::Validator),
|
||||
(ferdie(), charlie(), 100 * DOLLARS, pallet_staking::StakerStatus::Validator)
|
||||
],
|
||||
validator_count: 3,
|
||||
minimum_validator_count: 0,
|
||||
@@ -80,21 +80,21 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig
|
||||
invulnerables: vec![alice(), bob(), charlie()],
|
||||
.. Default::default()
|
||||
}),
|
||||
contracts: Some(ContractsConfig {
|
||||
pallet_contracts: Some(ContractsConfig {
|
||||
current_schedule: Default::default(),
|
||||
gas_price: 1 * MILLICENTS,
|
||||
}),
|
||||
babe: Some(Default::default()),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
pallet_babe: Some(Default::default()),
|
||||
pallet_grandpa: Some(GrandpaConfig {
|
||||
authorities: vec![],
|
||||
}),
|
||||
im_online: Some(Default::default()),
|
||||
authority_discovery: Some(Default::default()),
|
||||
democracy: Some(Default::default()),
|
||||
collective_Instance1: Some(Default::default()),
|
||||
collective_Instance2: Some(Default::default()),
|
||||
membership_Instance1: Some(Default::default()),
|
||||
sudo: Some(Default::default()),
|
||||
treasury: Some(Default::default()),
|
||||
pallet_im_online: Some(Default::default()),
|
||||
pallet_authority_discovery: Some(Default::default()),
|
||||
pallet_democracy: Some(Default::default()),
|
||||
pallet_collective_Instance1: Some(Default::default()),
|
||||
pallet_collective_Instance2: Some(Default::default()),
|
||||
pallet_membership_Instance1: Some(Default::default()),
|
||||
pallet_sudo: Some(Default::default()),
|
||||
pallet_treasury: Some(Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Test accounts.
|
||||
|
||||
use keyring::{AccountKeyring, Sr25519Keyring, Ed25519Keyring};
|
||||
use sp_keyring::{AccountKeyring, Sr25519Keyring, Ed25519Keyring};
|
||||
use node_primitives::{AccountId, Balance, Index};
|
||||
use node_runtime::{CheckedExtrinsic, UncheckedExtrinsic, SessionKeys, SignedExtra};
|
||||
use sp_runtime::generic::Era;
|
||||
@@ -66,12 +66,12 @@ pub fn to_session_keys(
|
||||
/// Returns transaction extra.
|
||||
pub fn signed_extra(nonce: Index, extra_fee: Balance) -> SignedExtra {
|
||||
(
|
||||
system::CheckVersion::new(),
|
||||
system::CheckGenesis::new(),
|
||||
system::CheckEra::from(Era::mortal(256, 0)),
|
||||
system::CheckNonce::from(nonce),
|
||||
system::CheckWeight::new(),
|
||||
transaction_payment::ChargeTransactionPayment::from(extra_fee),
|
||||
frame_system::CheckVersion::new(),
|
||||
frame_system::CheckGenesis::new(),
|
||||
frame_system::CheckEra::from(Era::mortal(256, 0)),
|
||||
frame_system::CheckNonce::from(nonce),
|
||||
frame_system::CheckWeight::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::from(extra_fee),
|
||||
Default::default(),
|
||||
)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ pub fn sign(xt: CheckedExtrinsic, version: u32, genesis_hash: [u8; 32]) -> Unche
|
||||
}
|
||||
}).into();
|
||||
UncheckedExtrinsic {
|
||||
signature: Some((indices::address::Address::Id(signed), signature, extra)),
|
||||
signature: Some((pallet_indices::address::Address::Id(signed), signature, extra)),
|
||||
function: payload.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" }
|
||||
cli = { package = "sc-cli", path = "../../../client/cli" }
|
||||
client-api = { package = "sc-client-api", path = "../../../client/api" }
|
||||
client = { package = "sc-client", path = "../../../client" }
|
||||
sp-block-builder = { path = "../../../primitives/block-builder" }
|
||||
sc-cli = { path = "../../../client/cli" }
|
||||
sc-client-api = { path = "../../../client/api" }
|
||||
sc-client = { path = "../../../client" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
log = "0.4.8"
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-api = { path = "../../../primitives/api" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
sc-service = { path = "../../../client/service" }
|
||||
|
||||
@@ -41,10 +41,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use log::info;
|
||||
use client::Client;
|
||||
use block_builder_api::BlockBuilder;
|
||||
use sc_client::Client;
|
||||
use sp_block_builder::BlockBuilder;
|
||||
use sp_api::ConstructRuntimeApi;
|
||||
use primitives::{Blake2Hasher, Hasher};
|
||||
use sp_core::{Blake2Hasher, Hasher};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi, One, Zero};
|
||||
|
||||
@@ -60,8 +60,8 @@ pub fn next<RA, Backend, Exec, Block, RtApi>(
|
||||
) -> Option<Block>
|
||||
where
|
||||
Block: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
|
||||
Exec: client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Exec: sc_client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
|
||||
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
|
||||
BlockBuilder<Block, Error = sp_blockchain::Error>,
|
||||
|
||||
@@ -26,16 +26,16 @@ use std::fmt::Display;
|
||||
|
||||
use log::info;
|
||||
|
||||
use client::Client;
|
||||
use block_builder_api::BlockBuilder;
|
||||
use sc_client::Client;
|
||||
use sp_block_builder::BlockBuilder;
|
||||
use sp_api::ConstructRuntimeApi;
|
||||
use consensus_common::{
|
||||
use sp_consensus::{
|
||||
BlockOrigin, BlockImportParams, InherentData, ForkChoiceStrategy,
|
||||
SelectChain
|
||||
};
|
||||
use consensus_common::block_import::BlockImport;
|
||||
use sp_consensus::block_import::BlockImport;
|
||||
use codec::{Decode, Encode};
|
||||
use primitives::{Blake2Hasher, Hasher};
|
||||
use sp_core::{Blake2Hasher, Hasher};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{
|
||||
Block as BlockT, Header as HeaderT, ProvideRuntimeApi, SimpleArithmetic,
|
||||
@@ -98,25 +98,25 @@ pub fn factory<RA, Backend, Exec, Block, RtApi, Sc>(
|
||||
mut factory_state: RA,
|
||||
client: &Arc<Client<Backend, Exec, Block, RtApi>>,
|
||||
select_chain: &Sc,
|
||||
) -> cli::error::Result<()>
|
||||
) -> sc_cli::error::Result<()>
|
||||
where
|
||||
Block: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
|
||||
Exec: client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Exec: sc_client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
|
||||
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
|
||||
BlockBuilder<Block, Error = sp_blockchain::Error>,
|
||||
RtApi: ConstructRuntimeApi<Block, Client<Backend, Exec, Block, RtApi>> + Send + Sync,
|
||||
Sc: SelectChain<Block>,
|
||||
RA: RuntimeAdapter,
|
||||
<<RA as RuntimeAdapter>::Block as BlockT>::Hash: From<primitives::H256>,
|
||||
<<RA as RuntimeAdapter>::Block as BlockT>::Hash: From<sp_core::H256>,
|
||||
{
|
||||
if *factory_state.mode() != Mode::MasterToNToM && factory_state.rounds() > RA::Number::one() {
|
||||
let msg = "The factory can only be used with rounds set to 1 in this mode.".into();
|
||||
return Err(cli::error::Error::Input(msg));
|
||||
return Err(sc_cli::error::Error::Input(msg));
|
||||
}
|
||||
|
||||
let best_header: Result<<Block as BlockT>::Header, cli::error::Error> =
|
||||
let best_header: Result<<Block as BlockT>::Header, sc_cli::error::Error> =
|
||||
select_chain.best_chain().map_err(|e| format!("{:?}", e).into());
|
||||
let mut best_hash = best_header?.hash();
|
||||
let mut best_block_id = BlockId::<Block>::hash(best_hash);
|
||||
@@ -160,8 +160,8 @@ pub fn create_block<RA, Backend, Exec, Block, RtApi>(
|
||||
) -> Block
|
||||
where
|
||||
Block: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
|
||||
Exec: client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Exec: sc_client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
|
||||
RtApi: ConstructRuntimeApi<Block, Client<Backend, Exec, Block, RtApi>> + Send + Sync,
|
||||
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
|
||||
@@ -186,8 +186,8 @@ fn import_block<Backend, Exec, Block, RtApi>(
|
||||
block: Block
|
||||
) -> () where
|
||||
Block: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
|
||||
Exec: client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Exec: sc_client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
{
|
||||
let import = BlockImportParams {
|
||||
origin: BlockOrigin::File,
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use log::info;
|
||||
use client::Client;
|
||||
use block_builder_api::BlockBuilder;
|
||||
use sc_client::Client;
|
||||
use sp_block_builder::BlockBuilder;
|
||||
use sp_api::ConstructRuntimeApi;
|
||||
use primitives::{Blake2Hasher, Hasher};
|
||||
use sp_core::{Blake2Hasher, Hasher};
|
||||
use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi, One};
|
||||
use sp_runtime::generic::BlockId;
|
||||
|
||||
@@ -55,8 +55,8 @@ pub fn next<RA, Backend, Exec, Block, RtApi>(
|
||||
) -> Option<Block>
|
||||
where
|
||||
Block: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
|
||||
Exec: client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Exec: sc_client::CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
|
||||
Backend: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send,
|
||||
Client<Backend, Exec, Block, RtApi>: ProvideRuntimeApi,
|
||||
<Client<Backend, Exec, Block, RtApi> as ProvideRuntimeApi>::Api:
|
||||
BlockBuilder<Block, Error = sp_blockchain::Error>,
|
||||
|
||||
@@ -7,8 +7,8 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.12.1"
|
||||
keystore = { package = "sc-keystore", path = "../../../client/keystore" }
|
||||
sc-keystore = { path = "../../../client/keystore" }
|
||||
node-cli = { path = "../../node/cli" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
rand = "0.7.2"
|
||||
structopt = "0.3.3"
|
||||
|
||||
@@ -20,9 +20,9 @@ use ansi_term::Style;
|
||||
use rand::{Rng, distributions::Alphanumeric, rngs::OsRng};
|
||||
use structopt::StructOpt;
|
||||
|
||||
use keystore::{Store as Keystore};
|
||||
use sc_keystore::{Store as Keystore};
|
||||
use node_cli::chain_spec::{self, AccountId};
|
||||
use primitives::{sr25519, crypto::{Public, Ss58Codec}, traits::BareCryptoStore};
|
||||
use sp_core::{sr25519, crypto::{Public, Ss58Codec}, traits::BareCryptoStore};
|
||||
|
||||
/// A utility to easily create a testnet chain spec definition with a given set
|
||||
/// of authorities and endowed accounts and/or generate random accounts.
|
||||
@@ -153,22 +153,22 @@ fn generate_authority_keys_and_store(
|
||||
};
|
||||
|
||||
insert_key(
|
||||
primitives::crypto::key_types::BABE,
|
||||
sp_core::crypto::key_types::BABE,
|
||||
babe.as_slice(),
|
||||
)?;
|
||||
|
||||
insert_key(
|
||||
primitives::crypto::key_types::GRANDPA,
|
||||
sp_core::crypto::key_types::GRANDPA,
|
||||
grandpa.as_slice(),
|
||||
)?;
|
||||
|
||||
insert_key(
|
||||
primitives::crypto::key_types::IM_ONLINE,
|
||||
sp_core::crypto::key_types::IM_ONLINE,
|
||||
im_online.as_slice(),
|
||||
)?;
|
||||
|
||||
insert_key(
|
||||
primitives::crypto::key_types::AUTHORITY_DISCOVERY,
|
||||
sp_core::crypto::key_types::AUTHORITY_DISCOVERY,
|
||||
authority_discovery.as_slice(),
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "sp-core", version = "*", path = "../../../primitives/core" }
|
||||
sp-core = { version = "*", path = "../../../primitives/core" }
|
||||
node-runtime = { version = "*", path = "../../node/runtime" }
|
||||
node-primitives = { version = "*", path = "../../node/primitives" }
|
||||
sp-runtime = { version = "*", path = "../../../primitives/runtime" }
|
||||
@@ -17,9 +17,9 @@ substrate-bip39 = "0.3.1"
|
||||
hex = "0.4.0"
|
||||
hex-literal = "0.2.1"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
system = { package = "frame-system", path = "../../../frame/system" }
|
||||
balances = { package = "pallet-balances", path = "../../../frame/balances" }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" }
|
||||
frame-system = { path = "../../../frame/system" }
|
||||
pallet-balances = { path = "../../../frame/balances" }
|
||||
pallet-transaction-payment = { path = "../../../frame/transaction-payment" }
|
||||
|
||||
[features]
|
||||
bench = []
|
||||
|
||||
@@ -24,7 +24,7 @@ use codec::{Decode, Encode};
|
||||
use hex_literal::hex;
|
||||
use node_primitives::{Balance, Hash, Index, AccountId, Signature};
|
||||
use node_runtime::{BalancesCall, Call, Runtime, SignedPayload, UncheckedExtrinsic, VERSION};
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
crypto::{set_default_ss58_version, Ss58AddressFormat, Ss58Codec},
|
||||
ed25519, sr25519, ecdsa, Pair, Public, H256, hexdisplay::HexDisplay,
|
||||
};
|
||||
@@ -197,7 +197,7 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
|
||||
-s, --suri <suri> 'The secret key URI.'
|
||||
"),
|
||||
SubCommand::with_name("transfer")
|
||||
.about("Author and sign a Node balances::Transfer transaction with a given (secret) key")
|
||||
.about("Author and sign a Node pallet_balances::Transfer transaction with a given (secret) key")
|
||||
.args_from_usage("
|
||||
<genesis> -g, --genesis <genesis> 'The genesis hash or a recognised \
|
||||
chain identifier (dev, elm, alex).'
|
||||
@@ -484,12 +484,12 @@ fn create_extrinsic<C: Crypto>(
|
||||
{
|
||||
let extra = |i: Index, f: Balance| {
|
||||
(
|
||||
system::CheckVersion::<Runtime>::new(),
|
||||
system::CheckGenesis::<Runtime>::new(),
|
||||
system::CheckEra::<Runtime>::from(Era::Immortal),
|
||||
system::CheckNonce::<Runtime>::from(i),
|
||||
system::CheckWeight::<Runtime>::new(),
|
||||
transaction_payment::ChargeTransactionPayment::<Runtime>::from(f),
|
||||
frame_system::CheckVersion::<Runtime>::new(),
|
||||
frame_system::CheckGenesis::<Runtime>::new(),
|
||||
frame_system::CheckEra::<Runtime>::from(Era::Immortal),
|
||||
frame_system::CheckNonce::<Runtime>::from(i),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(f),
|
||||
Default::default(),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::{PublicOf, PublicT, Crypto};
|
||||
use primitives::Pair;
|
||||
use sp_core::Pair;
|
||||
use rand::{rngs::OsRng, RngCore};
|
||||
|
||||
fn good_waypoint(done: u64) -> u64 {
|
||||
@@ -110,7 +110,7 @@ pub(super) fn generate_key<C: Crypto>(desired: &str) -> Result<KeyPair<C>, &str>
|
||||
mod tests {
|
||||
use super::super::Ed25519;
|
||||
use super::*;
|
||||
use primitives::{crypto::Ss58Codec, Pair};
|
||||
use sp_core::{crypto::Ss58Codec, Pair};
|
||||
#[cfg(feature = "bench")]
|
||||
use test::Bencher;
|
||||
|
||||
|
||||
+13
-13
@@ -5,36 +5,36 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
block-builder = { package = "sc-block-builder", path = "block-builder" }
|
||||
client-api = { package = "sc-client-api", path = "api" }
|
||||
sc-block-builder = { path = "block-builder" }
|
||||
sc-client-api = { path = "api" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
consensus = { package = "sp-consensus", path = "../primitives/consensus/common" }
|
||||
sp-consensus = { path = "../primitives/consensus/common" }
|
||||
derive_more = { version = "0.99.2" }
|
||||
executor = { package = "sc-executor", path = "executor" }
|
||||
externalities = { package = "sp-externalities", path = "../primitives/externalities" }
|
||||
sc-executor = { path = "executor" }
|
||||
sp-externalities = { path = "../primitives/externalities" }
|
||||
fnv = { version = "1.0.6" }
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
hash-db = { version = "0.15.2" }
|
||||
hex-literal = { version = "0.2.1" }
|
||||
inherents = { package = "sp-inherents", path = "../primitives/inherents" }
|
||||
keyring = { package = "sp-keyring", path = "../primitives/keyring" }
|
||||
sp-inherents = { path = "../primitives/inherents" }
|
||||
sp-keyring = { path = "../primitives/keyring" }
|
||||
kvdb = "0.1.1"
|
||||
log = { version = "0.4.8" }
|
||||
parking_lot = { version = "0.9.0" }
|
||||
primitives = { package = "sp-core", path = "../primitives/core" }
|
||||
sp-core = { path = "../primitives/core" }
|
||||
sp-std = { path = "../primitives/std" }
|
||||
runtime-version = { package = "sp-version", path = "../primitives/version" }
|
||||
sp-version = { path = "../primitives/version" }
|
||||
sp-api = { path = "../primitives/api" }
|
||||
sp-runtime = { path = "../primitives/runtime" }
|
||||
sp-blockchain = { path = "../primitives/blockchain" }
|
||||
state-machine = { package = "sp-state-machine", path = "../primitives/state-machine" }
|
||||
sp-state-machine = { path = "../primitives/state-machine" }
|
||||
sc-telemetry = { path = "telemetry" }
|
||||
trie = { package = "sp-trie", path = "../primitives/trie" }
|
||||
sp-trie = { path = "../primitives/trie" }
|
||||
tracing = "0.1.10"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.7.0"
|
||||
tempfile = "3.1.0"
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../test-utils/runtime/client" }
|
||||
substrate-test-runtime-client = { path = "../test-utils/runtime/client" }
|
||||
kvdb-memorydb = "0.1.2"
|
||||
panic-handler = { package = "sp-panic-handler", path = "../primitives/panic-handler" }
|
||||
sp-panic-handler = { path = "../primitives/panic-handler" }
|
||||
|
||||
@@ -6,29 +6,29 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" }
|
||||
sp-consensus = { path = "../../primitives/consensus/common" }
|
||||
derive_more = { version = "0.99.2" }
|
||||
executor = { package = "sc-executor", path = "../executor" }
|
||||
externalities = { package = "sp-externalities", path = "../../primitives/externalities" }
|
||||
sc-executor = { path = "../executor" }
|
||||
sp-externalities = { path = "../../primitives/externalities" }
|
||||
fnv = { version = "1.0.6" }
|
||||
futures = { version = "0.3.1" }
|
||||
hash-db = { version = "0.15.2", default-features = false }
|
||||
sp-blockchain = { path = "../../primitives/blockchain" }
|
||||
hex-literal = { version = "0.2.1" }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
keyring = { package = "sp-keyring", path = "../../primitives/keyring" }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
sp-keyring = { path = "../../primitives/keyring" }
|
||||
kvdb = "0.1.1"
|
||||
log = { version = "0.4.8" }
|
||||
parking_lot = { version = "0.9.0" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
runtime-version = { package = "sp-version", path = "../../primitives/version", default-features = false }
|
||||
sp-version = { path = "../../primitives/version", default-features = false }
|
||||
sp-api = { path = "../../primitives/api" }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
sp-state-machine = { path = "../../primitives/state-machine" }
|
||||
sc-telemetry = { path = "../telemetry" }
|
||||
trie = { package = "sp-trie", path = "../../primitives/trie" }
|
||||
txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" }
|
||||
sp-trie = { path = "../../primitives/trie" }
|
||||
sp-transaction-pool = { path = "../../primitives/transaction-pool" }
|
||||
|
||||
[dev-dependencies]
|
||||
test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" }
|
||||
sp-test-primitives = { path = "../../primitives/test-primitives" }
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::collections::HashMap;
|
||||
use primitives::ChangesTrieConfiguration;
|
||||
use primitives::offchain::OffchainStorage;
|
||||
use sp_core::ChangesTrieConfiguration;
|
||||
use sp_core::offchain::OffchainStorage;
|
||||
use sp_runtime::{generic::BlockId, Justification, Storage};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use state_machine::backend::Backend as StateBackend;
|
||||
use state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction};
|
||||
use sp_state_machine::backend::Backend as StateBackend;
|
||||
use sp_state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction};
|
||||
use crate::{
|
||||
blockchain::{
|
||||
Backend as BlockchainBackend, well_known_cache_keys
|
||||
@@ -31,7 +31,7 @@ use crate::{
|
||||
light::RemoteBlockchain,
|
||||
};
|
||||
use sp_blockchain;
|
||||
use consensus::BlockOrigin;
|
||||
use sp_consensus::BlockOrigin;
|
||||
use hash_db::Hasher;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ use codec::{Encode, Decode};
|
||||
use sp_runtime::{
|
||||
generic::BlockId, traits::Block as BlockT, traits::NumberFor,
|
||||
};
|
||||
use state_machine::{
|
||||
use sp_state_machine::{
|
||||
self, OverlayedChanges, ExecutionManager, ExecutionStrategy,
|
||||
ChangesTrieTransaction, StorageProof,
|
||||
};
|
||||
use executor::{RuntimeVersion, NativeVersion};
|
||||
use externalities::Extensions;
|
||||
use sc_executor::{RuntimeVersion, NativeVersion};
|
||||
use sp_externalities::Extensions;
|
||||
use hash_db::Hasher;
|
||||
use primitives::{Blake2Hasher, NativeOrEncoded};
|
||||
use sp_core::{Blake2Hasher, NativeOrEncoded};
|
||||
|
||||
use sp_api::{ProofRecorder, InitializeBlock};
|
||||
use sp_blockchain;
|
||||
@@ -41,7 +41,7 @@ where
|
||||
H::Out: Ord,
|
||||
{
|
||||
/// Externalities error type.
|
||||
type Error: state_machine::Error;
|
||||
type Error: sp_state_machine::Error;
|
||||
|
||||
/// Execute a call to a contract on top of state in a block of given hash.
|
||||
///
|
||||
@@ -92,7 +92,7 @@ where
|
||||
///
|
||||
/// No changes are made.
|
||||
fn call_at_state<
|
||||
S: state_machine::Backend<H>,
|
||||
S: sp_state_machine::Backend<H>,
|
||||
F: FnOnce(
|
||||
Result<NativeOrEncoded<R>, Self::Error>,
|
||||
Result<NativeOrEncoded<R>, Self::Error>,
|
||||
@@ -119,7 +119,7 @@ where
|
||||
/// Execute a call to a contract on top of given state, gathering execution proof.
|
||||
///
|
||||
/// No changes are made.
|
||||
fn prove_at_state<S: state_machine::Backend<H>>(
|
||||
fn prove_at_state<S: sp_state_machine::Backend<H>>(
|
||||
&self,
|
||||
mut state: S,
|
||||
overlay: &mut OverlayedChanges,
|
||||
@@ -128,8 +128,8 @@ where
|
||||
) -> Result<(Vec<u8>, StorageProof), sp_blockchain::Error> {
|
||||
let trie_state = state.as_trie_backend()
|
||||
.ok_or_else(||
|
||||
Box::new(state_machine::ExecutionError::UnableToGenerateProof)
|
||||
as Box<dyn state_machine::Error>
|
||||
Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof)
|
||||
as Box<dyn sp_state_machine::Error>
|
||||
)?;
|
||||
self.prove_at_trie_state(trie_state, overlay, method, call_data)
|
||||
}
|
||||
@@ -137,9 +137,9 @@ where
|
||||
/// Execute a call to a contract on top of given trie state, gathering execution proof.
|
||||
///
|
||||
/// No changes are made.
|
||||
fn prove_at_trie_state<S: state_machine::TrieBackendStorage<H>>(
|
||||
fn prove_at_trie_state<S: sp_state_machine::TrieBackendStorage<H>>(
|
||||
&self,
|
||||
trie_state: &state_machine::TrieBackend<S, H>,
|
||||
trie_state: &sp_state_machine::TrieBackend<S, H>,
|
||||
overlay: &mut OverlayedChanges,
|
||||
method: &str,
|
||||
call_data: &[u8]
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use futures::channel::mpsc;
|
||||
use primitives::storage::StorageKey;
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_runtime::{
|
||||
traits::{Block as BlockT, NumberFor},
|
||||
generic::BlockId
|
||||
};
|
||||
use consensus::BlockOrigin;
|
||||
use sp_consensus::BlockOrigin;
|
||||
|
||||
use crate::blockchain::Info;
|
||||
use crate::notifications::StorageEventStream;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
use std::sync::{Weak, Arc};
|
||||
use codec::Decode;
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
ExecutionContext,
|
||||
offchain::{self, OffchainExt, TransactionPoolExt},
|
||||
traits::{BareCryptoStorePtr, KeystoreExt},
|
||||
@@ -31,8 +31,8 @@ use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits,
|
||||
};
|
||||
use state_machine::{ExecutionStrategy, ExecutionManager, DefaultHandler};
|
||||
use externalities::Extensions;
|
||||
use sp_state_machine::{ExecutionStrategy, ExecutionManager, DefaultHandler};
|
||||
use sp_externalities::Extensions;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
/// Execution strategies settings.
|
||||
@@ -70,7 +70,7 @@ impl Default for ExecutionStrategies {
|
||||
pub struct ExecutionExtensions<Block: traits::Block> {
|
||||
strategies: ExecutionStrategies,
|
||||
keystore: Option<BareCryptoStorePtr>,
|
||||
transaction_pool: RwLock<Option<Weak<dyn txpool_api::OffchainSubmitTransaction<Block>>>>,
|
||||
transaction_pool: RwLock<Option<Weak<dyn sp_transaction_pool::OffchainSubmitTransaction<Block>>>>,
|
||||
}
|
||||
|
||||
impl<Block: traits::Block> Default for ExecutionExtensions<Block> {
|
||||
@@ -104,7 +104,7 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
|
||||
/// extension to be a `Weak` reference.
|
||||
/// That's also the reason why it's being registered lazily instead of
|
||||
/// during initialisation.
|
||||
pub fn register_transaction_pool(&self, pool: Weak<dyn txpool_api::OffchainSubmitTransaction<Block>>) {
|
||||
pub fn register_transaction_pool(&self, pool: Weak<dyn sp_transaction_pool::OffchainSubmitTransaction<Block>>) {
|
||||
*self.transaction_pool.write() = Some(pool);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
|
||||
/// A wrapper type to pass `BlockId` to the actual transaction pool.
|
||||
struct TransactionPoolAdapter<Block: traits::Block> {
|
||||
at: BlockId<Block>,
|
||||
pool: Arc<dyn txpool_api::OffchainSubmitTransaction<Block>>,
|
||||
pool: Arc<dyn sp_transaction_pool::OffchainSubmitTransaction<Block>>,
|
||||
}
|
||||
|
||||
impl<Block: traits::Block> offchain::TransactionPool for TransactionPoolAdapter<Block> {
|
||||
|
||||
@@ -32,13 +32,13 @@ pub use client::*;
|
||||
pub use light::*;
|
||||
pub use notifications::*;
|
||||
|
||||
pub use state_machine::{StorageProof, ExecutionStrategy};
|
||||
pub use sp_state_machine::{StorageProof, ExecutionStrategy};
|
||||
|
||||
|
||||
/// Utility methods for the client.
|
||||
pub mod utils {
|
||||
use sp_blockchain::{HeaderBackend, HeaderMetadata, Error};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::traits::{Block as BlockT};
|
||||
use std::borrow::Borrow;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ use sp_runtime::{
|
||||
},
|
||||
generic::BlockId
|
||||
};
|
||||
use primitives::ChangesTrieConfiguration;
|
||||
use state_machine::StorageProof;
|
||||
use sp_core::ChangesTrieConfiguration;
|
||||
use sp_state_machine::StorageProof;
|
||||
use sp_blockchain::{
|
||||
HeaderMetadata, well_known_cache_keys, HeaderBackend, Cache as BlockchainCache,
|
||||
Error as ClientError, Result as ClientResult,
|
||||
@@ -304,7 +304,7 @@ pub mod tests {
|
||||
use futures::future::Ready;
|
||||
use parking_lot::Mutex;
|
||||
use sp_blockchain::Error as ClientError;
|
||||
use test_primitives::{Block, Header, Extrinsic};
|
||||
use sp_test_primitives::{Block, Header, Extrinsic};
|
||||
use super::*;
|
||||
|
||||
pub type OkCallFetcher = Mutex<Vec<u8>>;
|
||||
|
||||
@@ -23,7 +23,7 @@ use std::{
|
||||
|
||||
use fnv::{FnvHashSet, FnvHashMap};
|
||||
use futures::channel::mpsc;
|
||||
use primitives::storage::{StorageKey, StorageData};
|
||||
use sp_core::storage::{StorageKey, StorageData};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
|
||||
/// Storage change set
|
||||
|
||||
@@ -9,18 +9,18 @@ build = "build.rs"
|
||||
prost-build = "0.5.0"
|
||||
|
||||
[dependencies]
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery" }
|
||||
sp-authority-discovery = { path = "../../primitives/authority-discovery" }
|
||||
bytes = "0.4.12"
|
||||
client-api = { package = "sc-client-api", path = "../api" }
|
||||
sc-client-api = { path = "../api" }
|
||||
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
|
||||
derive_more = "0.99.2"
|
||||
futures = "0.3.1"
|
||||
futures-timer = "2.0"
|
||||
keystore = { package = "sc-keystore", path = "../keystore" }
|
||||
sc-keystore = { path = "../keystore" }
|
||||
libp2p = { version = "0.13.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
|
||||
log = "0.4.8"
|
||||
network = { package = "sc-network", path = "../network" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sc-network = { path = "../network" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-blockchain = { path = "../../primitives/blockchain" }
|
||||
prost = "0.5.0"
|
||||
serde_json = "1.0.41"
|
||||
@@ -29,6 +29,6 @@ sp-runtime = { path = "../../primitives/runtime" }
|
||||
[dev-dependencies]
|
||||
env_logger = "0.7.0"
|
||||
parking_lot = "0.9.0"
|
||||
peerset = { package = "sc-peerset", path = "../peerset" }
|
||||
sc-peerset = { path = "../peerset" }
|
||||
sp-test-primitives = { path = "../../primitives/test-primitives" }
|
||||
sp-api = { path = "../../primitives/api" }
|
||||
|
||||
@@ -55,18 +55,18 @@ use futures::task::{Context, Poll};
|
||||
use futures::{Future, FutureExt, Stream, StreamExt};
|
||||
use futures_timer::Delay;
|
||||
|
||||
use authority_discovery_primitives::{
|
||||
use sp_authority_discovery::{
|
||||
AuthorityDiscoveryApi, AuthorityId, AuthoritySignature, AuthorityPair
|
||||
};
|
||||
use client_api::blockchain::HeaderBackend;
|
||||
use sc_client_api::blockchain::HeaderBackend;
|
||||
use codec::{Decode, Encode};
|
||||
use error::{Error, Result};
|
||||
use log::{debug, error, log_enabled, warn};
|
||||
use libp2p::Multiaddr;
|
||||
use network::specialization::NetworkSpecialization;
|
||||
use network::{DhtEvent, ExHashT};
|
||||
use primitives::crypto::{key_types, Pair};
|
||||
use primitives::traits::BareCryptoStorePtr;
|
||||
use sc_network::specialization::NetworkSpecialization;
|
||||
use sc_network::{DhtEvent, ExHashT};
|
||||
use sp_core::crypto::{key_types, Pair};
|
||||
use sp_core::traits::BareCryptoStorePtr;
|
||||
use prost::Message;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi};
|
||||
@@ -501,7 +501,7 @@ pub trait NetworkProvider {
|
||||
fn get_value(&self, key: &libp2p::kad::record::Key);
|
||||
}
|
||||
|
||||
impl<B, S, H> NetworkProvider for network::NetworkService<B, S, H>
|
||||
impl<B, S, H> NetworkProvider for sc_network::NetworkService<B, S, H>
|
||||
where
|
||||
B: BlockT + 'static,
|
||||
S: NetworkSpecialization<B>,
|
||||
@@ -551,7 +551,7 @@ mod tests {
|
||||
use futures::channel::mpsc::channel;
|
||||
use futures::executor::block_on;
|
||||
use futures::future::poll_fn;
|
||||
use primitives::{ExecutionContext, NativeOrEncoded, testing::KeyStore};
|
||||
use sp_core::{ExecutionContext, NativeOrEncoded, testing::KeyStore};
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_runtime::traits::{ApiRef, Block as BlockT, NumberFor, ProvideRuntimeApi};
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -642,8 +642,8 @@ mod tests {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn info(&self) -> client_api::blockchain::Info<Block> {
|
||||
client_api::blockchain::Info {
|
||||
fn info(&self) -> sc_client_api::blockchain::Info<Block> {
|
||||
sc_client_api::blockchain::Info {
|
||||
best_hash: Default::default(),
|
||||
best_number: Zero::zero(),
|
||||
finalized_hash: Default::default(),
|
||||
@@ -655,8 +655,8 @@ mod tests {
|
||||
fn status(
|
||||
&self,
|
||||
_id: BlockId<Block>,
|
||||
) -> std::result::Result<client_api::blockchain::BlockStatus, sp_blockchain::Error> {
|
||||
Ok(client_api::blockchain::BlockStatus::Unknown)
|
||||
) -> std::result::Result<sc_client_api::blockchain::BlockStatus, sp_blockchain::Error> {
|
||||
Ok(sc_client_api::blockchain::BlockStatus::Unknown)
|
||||
}
|
||||
|
||||
fn number(
|
||||
@@ -865,7 +865,7 @@ mod tests {
|
||||
.encode(&mut signed_addresses)
|
||||
.unwrap();
|
||||
|
||||
let dht_event = network::DhtEvent::ValueFound(vec![(authority_id_1, signed_addresses)]);
|
||||
let dht_event = sc_network::DhtEvent::ValueFound(vec![(authority_id_1, signed_addresses)]);
|
||||
dht_event_tx.try_send(dht_event).unwrap();
|
||||
|
||||
// Make authority discovery handle the event.
|
||||
|
||||
@@ -9,18 +9,18 @@ log = "0.4.8"
|
||||
futures = "0.3.1"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
sp-runtime = { path = "../../primitives/runtime" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-blockchain = { path = "../../primitives/blockchain" }
|
||||
client = { package = "sc-client", path = "../" }
|
||||
client-api = { package = "sc-client-api", path = "../api" }
|
||||
consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents" }
|
||||
sc-client = { path = "../" }
|
||||
sc-client-api = { path = "../api" }
|
||||
sp-consensus = { path = "../../primitives/consensus/common" }
|
||||
sp-inherents = { path = "../../primitives/inherents" }
|
||||
sc-telemetry = { path = "../telemetry" }
|
||||
txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" }
|
||||
block-builder = { package = "sc-block-builder", path = "../block-builder" }
|
||||
sp-transaction-pool = { path = "../../primitives/transaction-pool" }
|
||||
sc-block-builder = { path = "../block-builder" }
|
||||
tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] }
|
||||
|
||||
[dev-dependencies]
|
||||
txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" }
|
||||
sc-transaction-pool = { path = "../../client/transaction-pool" }
|
||||
substrate-test-runtime-client = { path = "../../test-utils/runtime/client" }
|
||||
parking_lot = "0.9"
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
// FIXME #1021 move this into sp-consensus
|
||||
|
||||
use std::{time, sync::Arc};
|
||||
use client_api::CallExecutor;
|
||||
use sc_client_api::CallExecutor;
|
||||
use sp_blockchain;
|
||||
use client::Client as SubstrateClient;
|
||||
use sc_client::Client as SubstrateClient;
|
||||
use codec::Decode;
|
||||
use consensus_common::{evaluation};
|
||||
use inherents::InherentData;
|
||||
use sp_consensus::{evaluation};
|
||||
use sp_inherents::InherentData;
|
||||
use log::{error, info, debug, trace};
|
||||
use primitives::{H256, Blake2Hasher, ExecutionContext};
|
||||
use sp_core::{H256, Blake2Hasher, ExecutionContext};
|
||||
use sp_runtime::{
|
||||
traits::{
|
||||
Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, DigestFor, BlakeTwo256
|
||||
},
|
||||
generic::BlockId,
|
||||
};
|
||||
use txpool_api::{TransactionPool, InPoolTransaction};
|
||||
use sp_transaction_pool::{TransactionPool, InPoolTransaction};
|
||||
use sc_telemetry::{telemetry, CONSENSUS_INFO};
|
||||
use block_builder::BlockBuilderApi;
|
||||
use sc_block_builder::BlockBuilderApi;
|
||||
|
||||
/// Proposer factory.
|
||||
pub struct ProposerFactory<C, A> where A: TransactionPool {
|
||||
@@ -48,7 +48,7 @@ pub struct ProposerFactory<C, A> where A: TransactionPool {
|
||||
impl<B, E, Block, RA, A> ProposerFactory<SubstrateClient<B, E, Block, RA>, A>
|
||||
where
|
||||
A: TransactionPool<Block=Block> + 'static,
|
||||
B: client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
B: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone + 'static,
|
||||
Block: BlockT<Hash=H256>,
|
||||
RA: Send + Sync + 'static,
|
||||
@@ -82,11 +82,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA, A> consensus_common::Environment<Block> for
|
||||
impl<B, E, Block, RA, A> sp_consensus::Environment<Block> for
|
||||
ProposerFactory<SubstrateClient<B, E, Block, RA>, A>
|
||||
where
|
||||
A: TransactionPool<Block=Block> + 'static,
|
||||
B: client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
B: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone + 'static,
|
||||
Block: BlockT<Hash=H256>,
|
||||
RA: Send + Sync + 'static,
|
||||
@@ -120,11 +120,11 @@ struct ProposerInner<Block: BlockT, C, A: TransactionPool> {
|
||||
now: Box<dyn Fn() -> time::Instant + Send + Sync>,
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA, A> consensus_common::Proposer<Block> for
|
||||
impl<B, E, Block, RA, A> sp_consensus::Proposer<Block> for
|
||||
Proposer<Block, SubstrateClient<B, E, Block, RA>, A>
|
||||
where
|
||||
A: TransactionPool<Block=Block> + 'static,
|
||||
B: client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
B: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone + 'static,
|
||||
Block: BlockT<Hash=H256>,
|
||||
RA: Send + Sync + 'static,
|
||||
@@ -152,7 +152,7 @@ where
|
||||
|
||||
impl<Block, B, E, RA, A> ProposerInner<Block, SubstrateClient<B, E, Block, RA>, A> where
|
||||
A: TransactionPool<Block=Block> + 'static,
|
||||
B: client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
B: sc_client_api::backend::Backend<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone + 'static,
|
||||
Block: BlockT<Hash=H256>,
|
||||
RA: Send + Sync + 'static,
|
||||
@@ -201,7 +201,7 @@ impl<Block, B, E, RA, A> ProposerInner<Block, SubstrateClient<B, E, Block, RA>,
|
||||
let pending_tx_data = pending_tx.data().clone();
|
||||
let pending_tx_hash = pending_tx.hash().clone();
|
||||
trace!("[{:?}] Pushing to the block.", pending_tx_hash);
|
||||
match block_builder::BlockBuilder::push(&mut block_builder, pending_tx_data) {
|
||||
match sc_block_builder::BlockBuilder::push(&mut block_builder, pending_tx_data) {
|
||||
Ok(()) => {
|
||||
debug!("[{:?}] Pushed to the block.", pending_tx_hash);
|
||||
}
|
||||
@@ -266,9 +266,9 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use consensus_common::Proposer;
|
||||
use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring};
|
||||
use txpool::{BasicPool, FullChainApi};
|
||||
use sp_consensus::Proposer;
|
||||
use substrate_test_runtime_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring};
|
||||
use sc_transaction_pool::{BasicPool, FullChainApi};
|
||||
|
||||
fn extrinsic(nonce: u64) -> Extrinsic {
|
||||
Transfer {
|
||||
@@ -282,7 +282,7 @@ mod tests {
|
||||
#[test]
|
||||
fn should_cease_building_block_when_deadline_is_reached() {
|
||||
// given
|
||||
let client = Arc::new(test_client::new());
|
||||
let client = Arc::new(substrate_test_runtime_client::new());
|
||||
let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone())));
|
||||
|
||||
futures::executor::block_on(
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
//!
|
||||
//! ```
|
||||
//! # use sc_basic_authority::ProposerFactory;
|
||||
//! # use consensus_common::{Environment, Proposer};
|
||||
//! # use sp_consensus::{Environment, Proposer};
|
||||
//! # use sp_runtime::generic::BlockId;
|
||||
//! # use std::{sync::Arc, time::Duration};
|
||||
//! # use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring};
|
||||
//! # use txpool::{BasicPool, FullChainApi};
|
||||
//! # let client = Arc::new(test_client::new());
|
||||
//! # use substrate_test_runtime_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring};
|
||||
//! # use sc_transaction_pool::{BasicPool, FullChainApi};
|
||||
//! # let client = Arc::new(substrate_test_runtime_client::new());
|
||||
//! # let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone())));
|
||||
//! // The first step is to create a `ProposerFactory`.
|
||||
//! let mut proposer_factory = ProposerFactory {
|
||||
|
||||
@@ -5,10 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
sp-state-machine = { path = "../../primitives/state-machine" }
|
||||
sp-runtime = { path = "../../primitives/runtime" }
|
||||
sp-blockchain = { path = "../../primitives/blockchain" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] }
|
||||
runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder" }
|
||||
sp-block-builder = { path = "../../primitives/block-builder" }
|
||||
sp-api = { path = "../../primitives/api" }
|
||||
|
||||
@@ -34,11 +34,11 @@ use sp_runtime::{
|
||||
}
|
||||
};
|
||||
use sp_blockchain::{ApplyExtrinsicFailed, Error};
|
||||
use primitives::ExecutionContext;
|
||||
use state_machine::StorageProof;
|
||||
use sp_core::ExecutionContext;
|
||||
use sp_state_machine::StorageProof;
|
||||
use sp_api::{Core, ApiExt, ApiErrorFor};
|
||||
|
||||
pub use runtime_api::BlockBuilder as BlockBuilderApi;
|
||||
pub use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
|
||||
|
||||
/// Utility for building new (valid) blocks from a stream of extrinsics.
|
||||
|
||||
@@ -7,9 +7,9 @@ edition = "2018"
|
||||
[dependencies]
|
||||
sc-chain-spec-derive = { path = "./derive" }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
network = { package = "sc-network", path = "../network" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sc-network = { path = "../network" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
serde = { version = "1.0.101", features = ["derive"] }
|
||||
serde_json = "1.0.41"
|
||||
sp-runtime = { path = "../../primitives/runtime" }
|
||||
tel = { package = "sc-telemetry", path = "../telemetry" }
|
||||
sc-telemetry = { path = "../telemetry" }
|
||||
|
||||
@@ -22,12 +22,12 @@ use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use primitives::storage::{StorageKey, StorageData, ChildInfo, Storage, StorageChild};
|
||||
use sp_core::storage::{StorageKey, StorageData, ChildInfo, Storage, StorageChild};
|
||||
use sp_runtime::BuildStorage;
|
||||
use serde_json as json;
|
||||
use crate::RuntimeGenesis;
|
||||
use network::Multiaddr;
|
||||
use tel::TelemetryEndpoints;
|
||||
use sc_network::Multiaddr;
|
||||
use sc_telemetry::TelemetryEndpoints;
|
||||
|
||||
enum GenesisSource<G> {
|
||||
File(PathBuf),
|
||||
@@ -77,7 +77,7 @@ impl<'a, G: RuntimeGenesis, E> BuildStorage for &'a ChainSpec<G, E> {
|
||||
Genesis::Raw(RawGenesis { top: map, children: children_map }) => Ok(Storage {
|
||||
top: map.into_iter().map(|(k, v)| (k.0, v.0)).collect(),
|
||||
children: children_map.into_iter().map(|(sk, child_content)| {
|
||||
let child_info = ChildInfo::resolve_child_info(
|
||||
let child_info = ChildInfo::resolve_child_info(
|
||||
child_content.child_type,
|
||||
child_content.child_info.as_slice(),
|
||||
).expect("chainspec contains correct content").to_owned();
|
||||
@@ -292,7 +292,7 @@ impl<G: RuntimeGenesis, E: serde::Serialize> ChainSpec<G, E> {
|
||||
StorageKey(sk),
|
||||
ChildRawStorage {
|
||||
data: child.data.into_iter()
|
||||
.map(|(k, v)| (StorageKey(k), StorageData(v)))
|
||||
.map(|(k, v)| (StorageKey(k), StorageData(v)))
|
||||
.collect(),
|
||||
child_info: info.to_vec(),
|
||||
child_type: ci_type,
|
||||
|
||||
@@ -20,19 +20,19 @@ tokio = "0.2.1"
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
fdlimit = "0.1.1"
|
||||
serde_json = "1.0.41"
|
||||
panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" }
|
||||
client-api = { package = "sc-client-api", path = "../api" }
|
||||
sp-panic-handler = { path = "../../primitives/panic-handler" }
|
||||
sc-client-api = { path = "../api" }
|
||||
sp-blockchain = { path = "../../primitives/blockchain" }
|
||||
network = { package = "sc-network", path = "../network" }
|
||||
sc-network = { path = "../network" }
|
||||
sp-runtime = { path = "../../primitives/runtime" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
service = { package = "sc-service", path = "../service", default-features = false }
|
||||
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sc-service = { path = "../service", default-features = false }
|
||||
sp-state-machine = { path = "../../primitives/state-machine" }
|
||||
sc-telemetry = { path = "../telemetry" }
|
||||
keyring = { package = "sp-keyring", path = "../../primitives/keyring" }
|
||||
sp-keyring = { path = "../../primitives/keyring" }
|
||||
names = "0.11.0"
|
||||
structopt = "0.3.3"
|
||||
sc-tracing = { package = "sc-tracing", path = "../tracing" }
|
||||
sc-tracing = { path = "../tracing" }
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
rpassword = "4.0.1"
|
||||
@@ -42,5 +42,5 @@ tempfile = "3.1.0"
|
||||
|
||||
[features]
|
||||
wasmtime = [
|
||||
"service/wasmtime",
|
||||
"sc-service/wasmtime",
|
||||
]
|
||||
|
||||
@@ -27,7 +27,7 @@ pub enum Error {
|
||||
/// Cli error
|
||||
Cli(clap::Error),
|
||||
/// Service error
|
||||
Service(service::Error),
|
||||
Service(sc_service::Error),
|
||||
/// Client error
|
||||
Client(sp_blockchain::Error),
|
||||
/// Input error
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
//! Console informant. Prints sync progress and block events. Runs on the calling thread.
|
||||
|
||||
use client_api::BlockchainEvents;
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use futures::{StreamExt, TryStreamExt, FutureExt, future, compat::Stream01CompatExt};
|
||||
use log::{info, warn};
|
||||
use sp_runtime::traits::Header;
|
||||
use service::AbstractService;
|
||||
use sc_service::AbstractService;
|
||||
use std::time::Duration;
|
||||
|
||||
mod display;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ansi_term::Colour;
|
||||
use client_api::ClientInfo;
|
||||
use sc_client_api::ClientInfo;
|
||||
use log::info;
|
||||
use network::SyncState;
|
||||
use sc_network::SyncState;
|
||||
use sp_runtime::traits::{Block as BlockT, CheckedDiv, NumberFor, Zero, Saturating};
|
||||
use service::NetworkStatus;
|
||||
use sc_service::NetworkStatus;
|
||||
use std::{convert::{TryFrom, TryInto}, fmt, time};
|
||||
|
||||
/// State of the informant display system.
|
||||
|
||||
@@ -26,20 +26,20 @@ mod execution_strategy;
|
||||
pub mod error;
|
||||
pub mod informant;
|
||||
|
||||
use client_api::execution_extensions::ExecutionStrategies;
|
||||
use service::{
|
||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||
use sc_service::{
|
||||
config::{Configuration, DatabaseConfig},
|
||||
ServiceBuilderCommand,
|
||||
RuntimeGenesis, ChainSpecExtension, PruningMode, ChainSpec,
|
||||
};
|
||||
use network::{
|
||||
use sc_network::{
|
||||
self,
|
||||
multiaddr::Protocol,
|
||||
config::{
|
||||
NetworkConfiguration, TransportConfig, NonReservedPeerMode, NodeKeyConfig, build_multiaddr
|
||||
},
|
||||
};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
|
||||
use std::{
|
||||
io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File},
|
||||
@@ -200,12 +200,12 @@ where
|
||||
I: IntoIterator,
|
||||
<I as IntoIterator>::Item: Into<std::ffi::OsString> + Clone,
|
||||
{
|
||||
let full_version = service::config::full_version_from_strs(
|
||||
let full_version = sc_service::config::full_version_from_strs(
|
||||
version.version,
|
||||
version.commit
|
||||
);
|
||||
|
||||
panic_handler::set(version.support_url, &full_version);
|
||||
sp_panic_handler::set(version.support_url, &full_version);
|
||||
let matches = CoreParams::<CC, RP>::clap()
|
||||
.name(version.executable_name)
|
||||
.author(version.author)
|
||||
@@ -333,7 +333,7 @@ impl<'a> ParseAndPrepareBuildSpec<'a> {
|
||||
|
||||
if spec.boot_nodes().is_empty() && !self.params.disable_default_bootnode {
|
||||
let base_path = base_path(&self.params.shared_params, self.version);
|
||||
let cfg = service::Configuration::<C,_,_>::default_with_spec_and_base_path(spec.clone(), Some(base_path));
|
||||
let cfg = sc_service::Configuration::<C,_,_>::default_with_spec_and_base_path(spec.clone(), Some(base_path));
|
||||
let node_key = node_key_config(
|
||||
self.params.node_key_params,
|
||||
&Some(cfg.in_chain_config_dir(DEFAULT_NETWORK_CONFIG_PATH).expect("We provided a base_path"))
|
||||
@@ -348,7 +348,7 @@ impl<'a> ParseAndPrepareBuildSpec<'a> {
|
||||
spec.add_boot_node(addr)
|
||||
}
|
||||
|
||||
let json = service::chain_ops::build_spec(spec, raw_output)?;
|
||||
let json = sc_service::chain_ops::build_spec(spec, raw_output)?;
|
||||
|
||||
print!("{}", json);
|
||||
|
||||
@@ -440,7 +440,7 @@ impl<'a> ParseAndPrepareImport<'a> {
|
||||
Exit: IntoExit
|
||||
{
|
||||
let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?;
|
||||
fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?;
|
||||
fill_import_params(&mut config, &self.params.import_params, sc_service::Roles::FULL)?;
|
||||
|
||||
let file: Box<dyn ReadPlusSeek + Send> = match self.params.input {
|
||||
Some(filename) => Box::new(File::open(filename)?),
|
||||
@@ -500,7 +500,7 @@ impl<'a> CheckBlock<'a> {
|
||||
Exit: IntoExit
|
||||
{
|
||||
let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?;
|
||||
fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?;
|
||||
fill_import_params(&mut config, &self.params.import_params, sc_service::Roles::FULL)?;
|
||||
|
||||
let input = if self.params.input.starts_with("0x") { &self.params.input[2..] } else { &self.params.input[..] };
|
||||
let block_id = match FromStr::from_str(input) {
|
||||
@@ -621,8 +621,8 @@ where
|
||||
params.node_key.as_ref().map(parse_ed25519_secret).unwrap_or_else(||
|
||||
Ok(params.node_key_file
|
||||
.or_else(|| net_config_file(net_config_dir, NODE_KEY_ED25519_FILE))
|
||||
.map(network::config::Secret::File)
|
||||
.unwrap_or(network::config::Secret::New)))
|
||||
.map(sc_network::config::Secret::File)
|
||||
.unwrap_or(sc_network::config::Secret::New)))
|
||||
.map(NodeKeyConfig::Ed25519)
|
||||
}
|
||||
}
|
||||
@@ -639,11 +639,11 @@ fn invalid_node_key(e: impl std::fmt::Display) -> error::Error {
|
||||
error::Error::Input(format!("Invalid node key: {}", e))
|
||||
}
|
||||
|
||||
/// Parse a Ed25519 secret key from a hex string into a `network::Secret`.
|
||||
fn parse_ed25519_secret(hex: &String) -> error::Result<network::config::Ed25519Secret> {
|
||||
/// Parse a Ed25519 secret key from a hex string into a `sc_network::Secret`.
|
||||
fn parse_ed25519_secret(hex: &String) -> error::Result<sc_network::config::Ed25519Secret> {
|
||||
H256::from_str(&hex).map_err(invalid_node_key).and_then(|bytes|
|
||||
network::config::identity::ed25519::SecretKey::from_bytes(bytes)
|
||||
.map(network::config::Secret::Input)
|
||||
sc_network::config::identity::ed25519::SecretKey::from_bytes(bytes)
|
||||
.map(sc_network::config::Secret::Input)
|
||||
.map_err(invalid_node_key))
|
||||
}
|
||||
|
||||
@@ -728,7 +728,7 @@ fn input_keystore_password() -> Result<String, String> {
|
||||
|
||||
/// Fill the password field of the given config instance.
|
||||
fn fill_config_keystore_password<C, G, E>(
|
||||
config: &mut service::Configuration<C, G, E>,
|
||||
config: &mut sc_service::Configuration<C, G, E>,
|
||||
cli: &RunCmd,
|
||||
) -> Result<(), String> {
|
||||
config.keystore_password = if cli.password_interactive {
|
||||
@@ -753,7 +753,7 @@ fn fill_config_keystore_password<C, G, E>(
|
||||
pub fn fill_import_params<C, G, E>(
|
||||
config: &mut Configuration<C, G, E>,
|
||||
cli: &ImportParams,
|
||||
role: service::Roles,
|
||||
role: sc_service::Roles,
|
||||
) -> error::Result<()>
|
||||
where
|
||||
C: Default,
|
||||
@@ -774,10 +774,10 @@ pub fn fill_import_params<C, G, E>(
|
||||
// unless `unsafe_pruning` is set.
|
||||
config.pruning = match &cli.pruning {
|
||||
Some(ref s) if s == "archive" => PruningMode::ArchiveAll,
|
||||
None if role == service::Roles::AUTHORITY => PruningMode::ArchiveAll,
|
||||
None if role == sc_service::Roles::AUTHORITY => PruningMode::ArchiveAll,
|
||||
None => PruningMode::default(),
|
||||
Some(s) => {
|
||||
if role == service::Roles::AUTHORITY && !cli.unsafe_pruning {
|
||||
if role == sc_service::Roles::AUTHORITY && !cli.unsafe_pruning {
|
||||
return Err(error::Error::Input(
|
||||
"Validators should run with state pruning disabled (i.e. archive). \
|
||||
You can ignore this check with `--unsafe-pruning`.".to_string()
|
||||
@@ -821,11 +821,11 @@ where
|
||||
let is_authority = cli.validator || cli.sentry || is_dev || cli.keyring.account.is_some();
|
||||
let role =
|
||||
if cli.light {
|
||||
service::Roles::LIGHT
|
||||
sc_service::Roles::LIGHT
|
||||
} else if is_authority {
|
||||
service::Roles::AUTHORITY
|
||||
sc_service::Roles::AUTHORITY
|
||||
} else {
|
||||
service::Roles::FULL
|
||||
sc_service::Roles::FULL
|
||||
};
|
||||
|
||||
fill_import_params(&mut config, &cli.import_params, role)?;
|
||||
@@ -856,7 +856,7 @@ where
|
||||
config.sentry_mode = cli.sentry;
|
||||
|
||||
config.offchain_worker = match (cli.offchain_worker, role) {
|
||||
(params::OffchainWorkerEnabled::WhenValidating, service::Roles::AUTHORITY) => true,
|
||||
(params::OffchainWorkerEnabled::WhenValidating, sc_service::Roles::AUTHORITY) => true,
|
||||
(params::OffchainWorkerEnabled::Always, _) => true,
|
||||
(params::OffchainWorkerEnabled::Never, _) => false,
|
||||
(params::OffchainWorkerEnabled::WhenValidating, _) => false,
|
||||
@@ -939,7 +939,7 @@ where
|
||||
let spec = load_spec(cli, spec_factory)?;
|
||||
let base_path = base_path(cli, version);
|
||||
|
||||
let mut config = service::Configuration::default_with_spec_and_base_path(
|
||||
let mut config = sc_service::Configuration::default_with_spec_and_base_path(
|
||||
spec.clone(),
|
||||
Some(base_path),
|
||||
);
|
||||
@@ -1043,7 +1043,7 @@ fn kill_color(s: &str) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use network::config::identity::ed25519;
|
||||
use sc_network::config::identity::ed25519;
|
||||
|
||||
#[test]
|
||||
fn tests_node_name_good() {
|
||||
@@ -1074,7 +1074,7 @@ mod tests {
|
||||
node_key_file: None
|
||||
};
|
||||
node_key_config(params, &net_config_dir).and_then(|c| match c {
|
||||
NodeKeyConfig::Ed25519(network::config::Secret::Input(ref ski))
|
||||
NodeKeyConfig::Ed25519(sc_network::config::Secret::Input(ref ski))
|
||||
if node_key_type == NodeKeyType::Ed25519 &&
|
||||
&sk[..] == ski.as_ref() => Ok(()),
|
||||
_ => Err(error::Error::Input("Unexpected node key config".into()))
|
||||
@@ -1099,7 +1099,7 @@ mod tests {
|
||||
node_key_file: Some(file.clone())
|
||||
};
|
||||
node_key_config(params, &net_config_dir).and_then(|c| match c {
|
||||
NodeKeyConfig::Ed25519(network::config::Secret::File(ref f))
|
||||
NodeKeyConfig::Ed25519(sc_network::config::Secret::File(ref f))
|
||||
if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()),
|
||||
_ => Err(error::Error::Input("Unexpected node key config".into()))
|
||||
})
|
||||
@@ -1131,7 +1131,7 @@ mod tests {
|
||||
let typ = params.node_key_type;
|
||||
node_key_config::<String>(params, &None)
|
||||
.and_then(|c| match c {
|
||||
NodeKeyConfig::Ed25519(network::config::Secret::New)
|
||||
NodeKeyConfig::Ed25519(sc_network::config::Secret::New)
|
||||
if typ == NodeKeyType::Ed25519 => Ok(()),
|
||||
_ => Err(error::Error::Input("Unexpected node key config".into()))
|
||||
})
|
||||
@@ -1144,7 +1144,7 @@ mod tests {
|
||||
let typ = params.node_key_type;
|
||||
node_key_config(params, &Some(net_config_dir.clone()))
|
||||
.and_then(move |c| match c {
|
||||
NodeKeyConfig::Ed25519(network::config::Secret::File(ref f))
|
||||
NodeKeyConfig::Ed25519(sc_network::config::Secret::File(ref f))
|
||||
if typ == NodeKeyType::Ed25519 &&
|
||||
f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()),
|
||||
_ => Err(error::Error::Input("Unexpected node key config".into()))
|
||||
|
||||
@@ -32,13 +32,13 @@ macro_rules! impl_get_log_filter {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<client_api::ExecutionStrategy> for ExecutionStrategy {
|
||||
fn into(self) -> client_api::ExecutionStrategy {
|
||||
impl Into<sc_client_api::ExecutionStrategy> for ExecutionStrategy {
|
||||
fn into(self) -> sc_client_api::ExecutionStrategy {
|
||||
match self {
|
||||
ExecutionStrategy::Native => client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
ExecutionStrategy::Wasm => client_api::ExecutionStrategy::AlwaysWasm,
|
||||
ExecutionStrategy::Both => client_api::ExecutionStrategy::Both,
|
||||
ExecutionStrategy::NativeElseWasm => client_api::ExecutionStrategy::NativeElseWasm,
|
||||
ExecutionStrategy::Native => sc_client_api::ExecutionStrategy::NativeWhenPossible,
|
||||
ExecutionStrategy::Wasm => sc_client_api::ExecutionStrategy::AlwaysWasm,
|
||||
ExecutionStrategy::Both => sc_client_api::ExecutionStrategy::Both,
|
||||
ExecutionStrategy::NativeElseWasm => sc_client_api::ExecutionStrategy::NativeElseWasm,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,12 +66,12 @@ impl WasmExecutionMethod {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<service::config::WasmExecutionMethod> for WasmExecutionMethod {
|
||||
fn into(self) -> service::config::WasmExecutionMethod {
|
||||
impl Into<sc_service::config::WasmExecutionMethod> for WasmExecutionMethod {
|
||||
fn into(self) -> sc_service::config::WasmExecutionMethod {
|
||||
match self {
|
||||
WasmExecutionMethod::Interpreted => service::config::WasmExecutionMethod::Interpreted,
|
||||
WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted,
|
||||
#[cfg(feature = "wasmtime")]
|
||||
WasmExecutionMethod::Compiled => service::config::WasmExecutionMethod::Compiled,
|
||||
WasmExecutionMethod::Compiled => sc_service::config::WasmExecutionMethod::Compiled,
|
||||
#[cfg(not(feature = "wasmtime"))]
|
||||
WasmExecutionMethod::Compiled => panic!(
|
||||
"Substrate must be compiled with \"wasmtime\" feature for compiled Wasm execution"
|
||||
@@ -584,19 +584,19 @@ struct KeyringTestAccountCliValues {
|
||||
help: String,
|
||||
conflicts_with: Vec<String>,
|
||||
name: String,
|
||||
variant: keyring::Sr25519Keyring,
|
||||
variant: sp_keyring::Sr25519Keyring,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
/// The Cli values for all test accounts.
|
||||
static ref TEST_ACCOUNTS_CLI_VALUES: Vec<KeyringTestAccountCliValues> = {
|
||||
keyring::Sr25519Keyring::iter().map(|a| {
|
||||
sp_keyring::Sr25519Keyring::iter().map(|a| {
|
||||
let help = format!(
|
||||
"Shortcut for `--name {} --validator` with session keys for `{}` added to keystore.",
|
||||
a,
|
||||
a,
|
||||
);
|
||||
let conflicts_with = keyring::Sr25519Keyring::iter()
|
||||
let conflicts_with = sp_keyring::Sr25519Keyring::iter()
|
||||
.filter(|b| a != *b)
|
||||
.map(|b| b.to_string().to_lowercase())
|
||||
.chain(std::iter::once("name".to_string()))
|
||||
@@ -616,7 +616,7 @@ lazy_static::lazy_static! {
|
||||
/// Wrapper for exposing the keyring test accounts into the Cli.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Keyring {
|
||||
pub account: Option<keyring::Sr25519Keyring>,
|
||||
pub account: Option<sp_keyring::Sr25519Keyring>,
|
||||
}
|
||||
|
||||
impl StructOpt for Keyring {
|
||||
|
||||
@@ -6,38 +6,38 @@ description = "Aura consensus algorithm for substrate"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" }
|
||||
aura_primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura" }
|
||||
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" }
|
||||
client = { package = "sc-client", path = "../../" }
|
||||
client-api = { package = "sc-client-api", path = "../../api" }
|
||||
sp-application-crypto = { path = "../../../primitives/application-crypto" }
|
||||
sp-consensus-aura = { path = "../../../primitives/consensus/aura" }
|
||||
sp-block-builder = { path = "../../../primitives/block-builder" }
|
||||
sc-client = { path = "../../" }
|
||||
sc-client-api = { path = "../../api" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
derive_more = "0.99.2"
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1" }
|
||||
futures-timer = "0.4.0"
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents" }
|
||||
keystore = { package = "sc-keystore", path = "../../keystore" }
|
||||
sp-inherents = { path = "../../../primitives/inherents" }
|
||||
sc-keystore = { path = "../../keystore" }
|
||||
log = "0.4.8"
|
||||
parking_lot = "0.9.0"
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" }
|
||||
sp-io = { path = "../../../primitives/io" }
|
||||
runtime_version = { package = "sp-version", path = "../../../primitives/version" }
|
||||
slots = { package = "sc-consensus-slots", path = "../slots" }
|
||||
sp-version = { path = "../../../primitives/version" }
|
||||
sc-consensus-slots = { path = "../slots" }
|
||||
sp-api = { path = "../../../primitives/api" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
sp-timestamp = { path = "../../../primitives/timestamp" }
|
||||
sc-telemetry = { path = "../../telemetry" }
|
||||
|
||||
[dev-dependencies]
|
||||
keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
|
||||
sp-keyring = { path = "../../../primitives/keyring" }
|
||||
sc-executor = { path = "../../executor" }
|
||||
sc-network = { path = "../../network" }
|
||||
sc-network-test = { path = "../../network/test" }
|
||||
service = { package = "sc-service", path = "../../service" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
|
||||
sc-service = { path = "../../service" }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
|
||||
tokio = "0.1.22"
|
||||
env_logger = "0.7.0"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
//! This implements the digests for AuRa, to allow the private
|
||||
//! `CompatibleDigestItem` trait to appear in public interfaces.
|
||||
|
||||
use primitives::Pair;
|
||||
use aura_primitives::AURA_ENGINE_ID;
|
||||
use sp_core::Pair;
|
||||
use sp_consensus_aura::AURA_ENGINE_ID;
|
||||
use sp_runtime::generic::{DigestItem, OpaqueDigestItemId};
|
||||
use codec::{Encode, Codec};
|
||||
use std::fmt::Debug;
|
||||
|
||||
@@ -31,28 +31,28 @@
|
||||
use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fmt::Debug, pin::Pin};
|
||||
|
||||
use codec::{Encode, Decode, Codec};
|
||||
use consensus_common::{
|
||||
use sp_consensus::{
|
||||
self, BlockImport, Environment, Proposer, CanAuthorWith, ForkChoiceStrategy, BlockImportParams,
|
||||
BlockOrigin, Error as ConsensusError, SelectChain, SlotData,
|
||||
};
|
||||
use consensus_common::import_queue::{
|
||||
use sp_consensus::import_queue::{
|
||||
Verifier, BasicQueue, BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
use client_api::backend::AuxStore;
|
||||
use client::{
|
||||
use sc_client_api::backend::AuxStore;
|
||||
use sc_client::{
|
||||
blockchain::ProvideCache, BlockOf
|
||||
};
|
||||
use sp_blockchain::{
|
||||
Result as CResult, well_known_cache_keys::{self, Id as CacheKeyId},
|
||||
};
|
||||
|
||||
use block_builder_api::BlockBuilder as BlockBuilderApi;
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
|
||||
use sp_runtime::{generic::{BlockId, OpaqueDigestItemId}, Justification};
|
||||
use sp_runtime::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member};
|
||||
|
||||
use primitives::crypto::Pair;
|
||||
use inherents::{InherentDataProviders, InherentData};
|
||||
use sp_core::crypto::Pair;
|
||||
use sp_inherents::{InherentDataProviders, InherentData};
|
||||
|
||||
use futures::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
@@ -65,21 +65,21 @@ use sp_timestamp::{
|
||||
|
||||
use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_INFO};
|
||||
|
||||
use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible};
|
||||
use slots::check_equivocation;
|
||||
use sc_consensus_slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible};
|
||||
use sc_consensus_slots::check_equivocation;
|
||||
|
||||
use keystore::KeyStorePtr;
|
||||
use sc_keystore::KeyStorePtr;
|
||||
|
||||
use sp_api::ApiExt;
|
||||
|
||||
pub use aura_primitives::{
|
||||
pub use sp_consensus_aura::{
|
||||
ConsensusLog, AuraApi, AURA_ENGINE_ID,
|
||||
inherents::{
|
||||
InherentType as AuraInherent,
|
||||
AuraInherentData, INHERENT_IDENTIFIER, InherentDataProvider,
|
||||
},
|
||||
};
|
||||
pub use consensus_common::SyncOracle;
|
||||
pub use sp_consensus::SyncOracle;
|
||||
pub use digest::CompatibleDigestItem;
|
||||
|
||||
mod digest;
|
||||
@@ -88,7 +88,7 @@ type AuthorityId<P> = <P as Pair>::Public;
|
||||
|
||||
/// A slot duration. Create with `get_or_compute`.
|
||||
#[derive(Clone, Copy, Debug, Encode, Decode, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||
pub struct SlotDuration(slots::SlotDuration<u64>);
|
||||
pub struct SlotDuration(sc_consensus_slots::SlotDuration<u64>);
|
||||
|
||||
impl SlotDuration {
|
||||
/// Either fetch the slot duration from disk or compute it from the genesis
|
||||
@@ -100,7 +100,7 @@ impl SlotDuration {
|
||||
C: AuxStore + ProvideRuntimeApi,
|
||||
C::Api: AuraApi<B, A, Error = sp_blockchain::Error>,
|
||||
{
|
||||
slots::SlotDuration::get_or_compute(client, |a, b| a.slot_duration(b)).map(Self)
|
||||
sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| a.slot_duration(b)).map(Self)
|
||||
}
|
||||
|
||||
/// Get the slot duration in milliseconds.
|
||||
@@ -133,11 +133,11 @@ impl SlotCompatible for AuraSlotCompatible {
|
||||
fn extract_timestamp_and_slot(
|
||||
&self,
|
||||
data: &InherentData
|
||||
) -> Result<(TimestampInherent, AuraInherent, std::time::Duration), consensus_common::Error> {
|
||||
) -> Result<(TimestampInherent, AuraInherent, std::time::Duration), sp_consensus::Error> {
|
||||
data.timestamp_inherent_data()
|
||||
.and_then(|t| data.aura_inherent_data().map(|a| (t, a)))
|
||||
.map_err(Into::into)
|
||||
.map_err(consensus_common::Error::InherentData)
|
||||
.map_err(sp_consensus::Error::InherentData)
|
||||
.map(|(x, y)| (x, y, Default::default()))
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ pub fn start_aura<B, C, SC, E, I, P, SO, CAW, Error, H>(
|
||||
force_authoring: bool,
|
||||
keystore: KeyStorePtr,
|
||||
can_author_with: CAW,
|
||||
) -> Result<impl futures01::Future<Item = (), Error = ()>, consensus_common::Error> where
|
||||
) -> Result<impl futures01::Future<Item = (), Error = ()>, sp_consensus::Error> where
|
||||
B: BlockT<Header=H>,
|
||||
C: ProvideRuntimeApi + BlockOf + ProvideCache<B> + AuxStore + Send + Sync,
|
||||
C::Api: AuraApi<B, AuthorityId<P>>,
|
||||
@@ -167,7 +167,7 @@ pub fn start_aura<B, C, SC, E, I, P, SO, CAW, Error, H>(
|
||||
P::Signature: Hash + Member + Encode + Decode,
|
||||
H: Header<Hash=B::Hash>,
|
||||
I: BlockImport<B> + Send + Sync + 'static,
|
||||
Error: ::std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
Error: ::std::error::Error + Send + From<::sp_consensus::Error> + From<I::Error> + 'static,
|
||||
SO: SyncOracle + Send + Sync + Clone,
|
||||
CAW: CanAuthorWith<B> + Send,
|
||||
{
|
||||
@@ -184,7 +184,7 @@ pub fn start_aura<B, C, SC, E, I, P, SO, CAW, Error, H>(
|
||||
&inherent_data_providers,
|
||||
slot_duration.0.slot_duration()
|
||||
)?;
|
||||
Ok(slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>(
|
||||
Ok(sc_consensus_slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>(
|
||||
slot_duration.0,
|
||||
select_chain,
|
||||
worker,
|
||||
@@ -205,7 +205,7 @@ struct AuraWorker<C, E, I, P, SO> {
|
||||
_key_type: PhantomData<P>,
|
||||
}
|
||||
|
||||
impl<H, B, C, E, I, P, Error, SO> slots::SimpleSlotWorker<B> for AuraWorker<C, E, I, P, SO> where
|
||||
impl<H, B, C, E, I, P, Error, SO> sc_consensus_slots::SimpleSlotWorker<B> for AuraWorker<C, E, I, P, SO> where
|
||||
B: BlockT<Header=H>,
|
||||
C: ProvideRuntimeApi + BlockOf + ProvideCache<B> + Sync,
|
||||
C::Api: AuraApi<B, AuthorityId<P>>,
|
||||
@@ -218,7 +218,7 @@ impl<H, B, C, E, I, P, Error, SO> slots::SimpleSlotWorker<B> for AuraWorker<C, E
|
||||
P::Public: Member + Encode + Decode + Hash,
|
||||
P::Signature: Member + Encode + Decode + Hash + Debug,
|
||||
SO: SyncOracle + Send + Clone,
|
||||
Error: ::std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
Error: ::std::error::Error + Send + From<::sp_consensus::Error> + From<I::Error> + 'static,
|
||||
{
|
||||
type EpochData = Vec<AuthorityId<P>>;
|
||||
type Claim = P;
|
||||
@@ -234,7 +234,7 @@ impl<H, B, C, E, I, P, Error, SO> slots::SimpleSlotWorker<B> for AuraWorker<C, E
|
||||
self.block_import.clone()
|
||||
}
|
||||
|
||||
fn epoch_data(&self, header: &B::Header, _slot_number: u64) -> Result<Self::EpochData, consensus_common::Error> {
|
||||
fn epoch_data(&self, header: &B::Header, _slot_number: u64) -> Result<Self::EpochData, sp_consensus::Error> {
|
||||
authorities(self.client.as_ref(), &BlockId::Hash(header.hash()))
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ impl<H, B, C, E, I, P, Error, SO> slots::SimpleSlotWorker<B> for AuraWorker<C, E
|
||||
|
||||
expected_author.and_then(|p| {
|
||||
self.keystore.read()
|
||||
.key_pair_by_type::<P>(&p, app_crypto::key_types::AURA).ok()
|
||||
.key_pair_by_type::<P>(&p, sp_application_crypto::key_types::AURA).ok()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ impl<H, B, C, E, I, P, Error, SO> slots::SimpleSlotWorker<B> for AuraWorker<C, E
|
||||
&B::Hash,
|
||||
Vec<B::Extrinsic>,
|
||||
Self::Claim,
|
||||
) -> consensus_common::BlockImportParams<B> + Send> {
|
||||
) -> sp_consensus::BlockImportParams<B> + Send> {
|
||||
Box::new(|header, header_hash, body, pair| {
|
||||
// sign the pre-sealed hash of the block and then
|
||||
// add it to a digest item.
|
||||
@@ -297,9 +297,9 @@ impl<H, B, C, E, I, P, Error, SO> slots::SimpleSlotWorker<B> for AuraWorker<C, E
|
||||
&mut self.sync_oracle
|
||||
}
|
||||
|
||||
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, consensus_common::Error> {
|
||||
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, sp_consensus::Error> {
|
||||
self.env.init(block).map_err(|e| {
|
||||
consensus_common::Error::ClientImport(format!("{:?}", e)).into()
|
||||
sp_consensus::Error::ClientImport(format!("{:?}", e)).into()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -343,12 +343,12 @@ impl<H, B: BlockT, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I,
|
||||
P::Public: Member + Encode + Decode + Hash,
|
||||
P::Signature: Member + Encode + Decode + Hash + Debug,
|
||||
SO: SyncOracle + Send + Sync + Clone,
|
||||
Error: ::std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
Error: ::std::error::Error + Send + From<::sp_consensus::Error> + From<I::Error> + 'static,
|
||||
{
|
||||
type OnSlot = Pin<Box<dyn Future<Output = Result<(), consensus_common::Error>> + Send>>;
|
||||
type OnSlot = Pin<Box<dyn Future<Output = Result<(), sp_consensus::Error>> + Send>>;
|
||||
|
||||
fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot {
|
||||
<Self as slots::SimpleSlotWorker<B>>::on_slot(self, chain_head, slot_info)
|
||||
<Self as sc_consensus_slots::SimpleSlotWorker<B>>::on_slot(self, chain_head, slot_info)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ fn check_header<C, B: BlockT, P: Pair, T>(
|
||||
) -> Result<CheckedHeader<B::Header, (u64, DigestItemFor<B>)>, Error<B>> where
|
||||
DigestItemFor<B>: CompatibleDigestItem<P>,
|
||||
P::Signature: Decode,
|
||||
C: client_api::backend::AuxStore,
|
||||
C: sc_client_api::backend::AuxStore,
|
||||
P::Public: Encode + Decode + PartialEq + Clone,
|
||||
T: Send + Sync + 'static,
|
||||
{
|
||||
@@ -471,7 +471,7 @@ fn check_header<C, B: BlockT, P: Pair, T>(
|
||||
pub struct AuraVerifier<C, P, T> {
|
||||
client: Arc<C>,
|
||||
phantom: PhantomData<P>,
|
||||
inherent_data_providers: inherents::InherentDataProviders,
|
||||
inherent_data_providers: sp_inherents::InherentDataProviders,
|
||||
transaction_pool: Option<Arc<T>>,
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ impl<C, P, T> AuraVerifier<C, P, T>
|
||||
|
||||
#[forbid(deprecated)]
|
||||
impl<B: BlockT, C, P, T> Verifier<B> for AuraVerifier<C, P, T> where
|
||||
C: ProvideRuntimeApi + Send + Sync + client_api::backend::AuxStore + ProvideCache<B> + BlockOf,
|
||||
C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore + ProvideCache<B> + BlockOf,
|
||||
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
|
||||
DigestItemFor<B>: CompatibleDigestItem<P>,
|
||||
P: Pair + Send + Sync + 'static,
|
||||
@@ -661,7 +661,7 @@ fn initialize_authorities_cache<A, B, C>(client: &C) -> Result<(), ConsensusErro
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let map_err = |error| consensus_common::Error::from(consensus_common::Error::ClientImport(
|
||||
let map_err = |error| sp_consensus::Error::from(sp_consensus::Error::ClientImport(
|
||||
format!(
|
||||
"Error initializing authorities cache: {}",
|
||||
error,
|
||||
@@ -687,7 +687,7 @@ fn authorities<A, B, C>(client: &C, at: &BlockId<B>) -> Result<Vec<A>, Consensus
|
||||
.and_then(|(_, _, v)| Decode::decode(&mut &v[..]).ok())
|
||||
)
|
||||
.or_else(|| AuraApi::authorities(&*client.runtime_api(), at).ok())
|
||||
.ok_or_else(|| consensus_common::Error::InvalidAuthoritiesSet.into())
|
||||
.ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet.into())
|
||||
}
|
||||
|
||||
/// The Aura import queue type.
|
||||
@@ -697,12 +697,12 @@ pub type AuraImportQueue<B> = BasicQueue<B>;
|
||||
fn register_aura_inherent_data_provider(
|
||||
inherent_data_providers: &InherentDataProviders,
|
||||
slot_duration: u64,
|
||||
) -> Result<(), consensus_common::Error> {
|
||||
) -> Result<(), sp_consensus::Error> {
|
||||
if !inherent_data_providers.has_provider(&INHERENT_IDENTIFIER) {
|
||||
inherent_data_providers
|
||||
.register_provider(InherentDataProvider::new(slot_duration))
|
||||
.map_err(Into::into)
|
||||
.map_err(consensus_common::Error::InherentData)
|
||||
.map_err(sp_consensus::Error::InherentData)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
@@ -717,7 +717,7 @@ pub fn import_queue<B, C, P, T>(
|
||||
client: Arc<C>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
transaction_pool: Option<Arc<T>>,
|
||||
) -> Result<AuraImportQueue<B>, consensus_common::Error> where
|
||||
) -> Result<AuraImportQueue<B>, sp_consensus::Error> where
|
||||
B: BlockT,
|
||||
C: 'static + ProvideRuntimeApi + BlockOf + ProvideCache<B> + Send + Sync + AuxStore,
|
||||
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
|
||||
@@ -747,24 +747,23 @@ pub fn import_queue<B, C, P, T>(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use consensus_common::NoNetwork as DummyOracle;
|
||||
use sp_consensus::NoNetwork as DummyOracle;
|
||||
use sc_network_test::{Block as TestBlock, *};
|
||||
use sp_runtime::traits::{Block as BlockT, DigestFor};
|
||||
use sc_network::config::ProtocolConfig;
|
||||
use parking_lot::Mutex;
|
||||
use tokio::runtime::current_thread;
|
||||
use keyring::sr25519::Keyring;
|
||||
use client::BlockchainEvents;
|
||||
use test_client;
|
||||
use aura_primitives::sr25519::AuthorityPair;
|
||||
use sp_keyring::sr25519::Keyring;
|
||||
use sc_client::BlockchainEvents;
|
||||
use sp_consensus_aura::sr25519::AuthorityPair;
|
||||
|
||||
type Error = sp_blockchain::Error;
|
||||
|
||||
type TestClient = client::Client<
|
||||
test_client::Backend,
|
||||
test_client::Executor,
|
||||
type TestClient = sc_client::Client<
|
||||
substrate_test_runtime_client::Backend,
|
||||
substrate_test_runtime_client::Executor,
|
||||
TestBlock,
|
||||
test_client::runtime::RuntimeApi
|
||||
substrate_test_runtime_client::runtime::RuntimeApi
|
||||
>;
|
||||
|
||||
struct DummyFactory(Arc<TestClient>);
|
||||
@@ -875,7 +874,7 @@ mod tests {
|
||||
let client = peer.client().as_full().expect("full clients are created").clone();
|
||||
let select_chain = peer.select_chain().expect("full client has a select chain");
|
||||
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
|
||||
let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore.");
|
||||
let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore.");
|
||||
|
||||
keystore.write().insert_ephemeral_from_seed::<AuthorityPair>(&key.to_seed())
|
||||
.expect("Creates authority key");
|
||||
@@ -906,7 +905,7 @@ mod tests {
|
||||
inherent_data_providers,
|
||||
false,
|
||||
keystore,
|
||||
consensus_common::AlwaysCanAuthor,
|
||||
sp_consensus::AlwaysCanAuthor,
|
||||
).expect("Starts aura");
|
||||
|
||||
runtime.spawn(aura);
|
||||
@@ -923,7 +922,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn authorities_call_works() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
|
||||
assert_eq!(client.info().chain.best_number, 0);
|
||||
assert_eq!(authorities(&client, &BlockId::Number(0)).unwrap(), vec![
|
||||
|
||||
@@ -7,26 +7,26 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
babe_primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" }
|
||||
sp-consensus-babe = { path = "../../../primitives/consensus/babe" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-application-crypto = { path = "../../../primitives/application-crypto" }
|
||||
num-bigint = "0.2.3"
|
||||
num-rational = "0.2.2"
|
||||
num-traits = "0.2.8"
|
||||
runtime-version = { package = "sp-version", path = "../../../primitives/version" }
|
||||
sp-version = { path = "../../../primitives/version" }
|
||||
sp-io = { path = "../../../primitives/io" }
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents" }
|
||||
sp-inherents = { path = "../../../primitives/inherents" }
|
||||
sp-timestamp = { path = "../../../primitives/timestamp" }
|
||||
sc-telemetry = { path = "../../telemetry" }
|
||||
keystore = { package = "sc-keystore", path = "../../keystore" }
|
||||
client-api = { package = "sc-client-api", path = "../../api" }
|
||||
client = { package = "sc-client", path = "../../" }
|
||||
sc-keystore = { path = "../../keystore" }
|
||||
sc-client-api = { path = "../../api" }
|
||||
sc-client = { path = "../../" }
|
||||
sp-api = { path = "../../../primitives/api" }
|
||||
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" }
|
||||
sp-block-builder = { path = "../../../primitives/block-builder" }
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" }
|
||||
consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
uncles = { package = "sc-consensus-uncles", path = "../uncles" }
|
||||
slots = { package = "sc-consensus-slots", path = "../slots" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
sc-consensus-uncles = { path = "../uncles" }
|
||||
sc-consensus-slots = { path = "../slots" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
fork-tree = { path = "../../../utils/fork-tree" }
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
@@ -41,13 +41,13 @@ pdqselect = "0.1.0"
|
||||
derive_more = "0.99.2"
|
||||
|
||||
[dev-dependencies]
|
||||
keyring = { package = "sp-keyring", path = "../../../primitives/keyring" }
|
||||
sp-keyring = { path = "../../../primitives/keyring" }
|
||||
sc-executor = { path = "../../executor" }
|
||||
sc-network = { path = "../../network" }
|
||||
sc-network-test = { path = "../../network/test" }
|
||||
service = { package = "sc-service", path = "../../service" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
|
||||
block-builder = { package = "sc-block-builder", path = "../../block-builder" }
|
||||
sc-service = { path = "../../service" }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
|
||||
sc-block-builder = { path = "../../block-builder" }
|
||||
tokio = "0.1.22"
|
||||
env_logger = "0.7.0"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
//! BABE authority selection and slot claiming.
|
||||
|
||||
use merlin::Transcript;
|
||||
use babe_primitives::{AuthorityId, BabeAuthorityWeight, BABE_ENGINE_ID, BABE_VRF_PREFIX};
|
||||
use babe_primitives::{Epoch, SlotNumber, AuthorityPair, BabePreDigest, BabeConfiguration};
|
||||
use primitives::{U256, blake2_256};
|
||||
use sp_consensus_babe::{AuthorityId, BabeAuthorityWeight, BABE_ENGINE_ID, BABE_VRF_PREFIX};
|
||||
use sp_consensus_babe::{Epoch, SlotNumber, AuthorityPair, BabePreDigest, BabeConfiguration};
|
||||
use sp_core::{U256, blake2_256};
|
||||
use codec::Encode;
|
||||
use schnorrkel::vrf::VRFInOut;
|
||||
use primitives::Pair;
|
||||
use keystore::KeyStorePtr;
|
||||
use sp_core::Pair;
|
||||
use sc_keystore::KeyStorePtr;
|
||||
|
||||
/// Calculates the primary selection threshold for a given authority, taking
|
||||
/// into account `c` (`1 - c` represents the probability of a slot being empty).
|
||||
@@ -162,8 +162,8 @@ pub(super) fn claim_slot(
|
||||
}
|
||||
|
||||
fn get_keypair(q: &AuthorityPair) -> &schnorrkel::Keypair {
|
||||
use primitives::crypto::IsWrappedBy;
|
||||
primitives::sr25519::Pair::from_ref(q).as_ref()
|
||||
use sp_core::crypto::IsWrappedBy;
|
||||
sp_core::sr25519::Pair::from_ref(q).as_ref()
|
||||
}
|
||||
|
||||
/// Claim a primary slot if it is our turn. Returns `None` if it is not our turn.
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
use log::info;
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
use client_api::backend::AuxStore;
|
||||
use sc_client_api::backend::AuxStore;
|
||||
use sp_blockchain::{Result as ClientResult, Error as ClientError};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use babe_primitives::BabeBlockWeight;
|
||||
use sp_consensus_babe::BabeBlockWeight;
|
||||
|
||||
use super::{epoch_changes::EpochChangesFor, SharedEpochChanges};
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
//! persistent DAG superimposed over the forks of the blockchain.
|
||||
|
||||
use std::sync::Arc;
|
||||
use babe_primitives::{Epoch, SlotNumber, NextEpochDescriptor};
|
||||
use sp_consensus_babe::{Epoch, SlotNumber, NextEpochDescriptor};
|
||||
use fork_tree::ForkTree;
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor, One, Zero};
|
||||
use codec::{Encode, Decode};
|
||||
use client_api::utils::is_descendent_of;
|
||||
use sc_client_api::utils::is_descendent_of;
|
||||
use sp_blockchain::{HeaderMetadata, HeaderBackend, Error as ClientError};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use std::ops::Add;
|
||||
|
||||
/// A builder for `is_descendent_of` functions.
|
||||
|
||||
@@ -58,15 +58,15 @@
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(missing_docs)]
|
||||
pub use babe_primitives::{
|
||||
pub use sp_consensus_babe::{
|
||||
BabeApi, ConsensusLog, BABE_ENGINE_ID, BabePreDigest, SlotNumber, BabeConfiguration,
|
||||
CompatibleDigestItem,
|
||||
};
|
||||
pub use consensus_common::SyncOracle;
|
||||
pub use sp_consensus::SyncOracle;
|
||||
use std::{collections::HashMap, sync::Arc, u64, pin::Pin, time::{Instant, Duration}};
|
||||
use babe_primitives;
|
||||
use consensus_common::{ImportResult, CanAuthorWith};
|
||||
use consensus_common::import_queue::{
|
||||
use sp_consensus_babe;
|
||||
use sp_consensus::{ImportResult, CanAuthorWith};
|
||||
use sp_consensus::import_queue::{
|
||||
BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
use sp_runtime::{generic::{BlockId, OpaqueDigestItemId}, Justification};
|
||||
@@ -74,32 +74,32 @@ use sp_runtime::traits::{
|
||||
Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi,
|
||||
Zero,
|
||||
};
|
||||
use keystore::KeyStorePtr;
|
||||
use sc_keystore::KeyStorePtr;
|
||||
use parking_lot::Mutex;
|
||||
use primitives::{Blake2Hasher, H256, Pair};
|
||||
use inherents::{InherentDataProviders, InherentData};
|
||||
use sp_core::{Blake2Hasher, H256, Pair};
|
||||
use sp_inherents::{InherentDataProviders, InherentData};
|
||||
use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG};
|
||||
use consensus_common::{
|
||||
use sp_consensus::{
|
||||
self, BlockImport, Environment, Proposer, BlockCheckParams,
|
||||
ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError,
|
||||
SelectChain, SlotData,
|
||||
};
|
||||
use babe_primitives::inherents::BabeInherentData;
|
||||
use sp_consensus_babe::inherents::BabeInherentData;
|
||||
use sp_timestamp::{TimestampInherentData, InherentType as TimestampInherent};
|
||||
use consensus_common::import_queue::{Verifier, BasicQueue, CacheKeyId};
|
||||
use client_api::{
|
||||
use sp_consensus::import_queue::{Verifier, BasicQueue, CacheKeyId};
|
||||
use sc_client_api::{
|
||||
backend::{AuxStore, Backend},
|
||||
call_executor::CallExecutor,
|
||||
BlockchainEvents, ProvideUncles,
|
||||
};
|
||||
use client::Client;
|
||||
use sc_client::Client;
|
||||
|
||||
use block_builder_api::BlockBuilder as BlockBuilderApi;
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
|
||||
use slots::{CheckedHeader, check_equivocation};
|
||||
use sc_consensus_slots::{CheckedHeader, check_equivocation};
|
||||
use futures::prelude::*;
|
||||
use log::{warn, debug, info, trace};
|
||||
use slots::{SlotWorker, SlotInfo, SlotCompatible};
|
||||
use sc_consensus_slots::{SlotWorker, SlotInfo, SlotCompatible};
|
||||
use epoch_changes::descendent_query;
|
||||
use sp_blockchain::{
|
||||
Result as ClientResult, Error as ClientError,
|
||||
@@ -115,7 +115,7 @@ mod epoch_changes;
|
||||
mod authorship;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
pub use babe_primitives::{
|
||||
pub use sp_consensus_babe::{
|
||||
AuthorityId, AuthorityPair, AuthoritySignature, Epoch, NextEpochDescriptor,
|
||||
};
|
||||
pub use epoch_changes::{EpochChanges, EpochChangesFor, SharedEpochChanges};
|
||||
@@ -130,7 +130,7 @@ enum Error<B: BlockT> {
|
||||
#[display(fmt = "Multiple BABE epoch change digests, rejecting!")]
|
||||
MultipleEpochChangeDigests,
|
||||
#[display(fmt = "Could not extract timestamp and slot: {:?}", _0)]
|
||||
Extraction(consensus_common::Error),
|
||||
Extraction(sp_consensus::Error),
|
||||
#[display(fmt = "Could not fetch epoch at {:?}", _0)]
|
||||
FetchEpoch(B::Hash),
|
||||
#[display(fmt = "Header {:?} rejected: too far in the future", _0)]
|
||||
@@ -172,7 +172,7 @@ enum Error<B: BlockT> {
|
||||
#[display(fmt = "Checking inherents failed: {}", _0)]
|
||||
CheckInherents(String),
|
||||
Client(sp_blockchain::Error),
|
||||
Runtime(inherents::Error),
|
||||
Runtime(sp_inherents::Error),
|
||||
ForkTree(Box<fork_tree::Error<sp_blockchain::Error>>),
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ macro_rules! babe_info {
|
||||
// and `super::babe::Config` can be eliminated.
|
||||
// https://github.com/paritytech/substrate/issues/2434
|
||||
#[derive(Clone)]
|
||||
pub struct Config(slots::SlotDuration<BabeConfiguration>);
|
||||
pub struct Config(sc_consensus_slots::SlotDuration<BabeConfiguration>);
|
||||
|
||||
impl Config {
|
||||
/// Either fetch the slot duration from disk or compute it from the genesis
|
||||
@@ -210,7 +210,7 @@ impl Config {
|
||||
C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi<B, Error = sp_blockchain::Error>,
|
||||
{
|
||||
trace!(target: "babe", "Getting slot duration");
|
||||
match slots::SlotDuration::get_or_compute(client, |a, b| a.configuration(b)).map(Self) {
|
||||
match sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| a.configuration(b)).map(Self) {
|
||||
Ok(s) => Ok(s),
|
||||
Err(s) => {
|
||||
warn!(target: "babe", "Failed to get slot duration");
|
||||
@@ -289,7 +289,7 @@ pub fn start_babe<B, C, SC, E, I, SO, CAW, Error>(BabeParams {
|
||||
can_author_with,
|
||||
}: BabeParams<B, C, E, I, SO, SC, CAW>) -> Result<
|
||||
impl futures01::Future<Item=(), Error=()>,
|
||||
consensus_common::Error,
|
||||
sp_consensus::Error,
|
||||
> where
|
||||
B: BlockT<Hash=H256>,
|
||||
C: ProvideRuntimeApi + ProvideCache<B> + ProvideUncles<B> + BlockchainEvents<B>
|
||||
@@ -300,7 +300,7 @@ pub fn start_babe<B, C, SC, E, I, SO, CAW, Error>(BabeParams {
|
||||
E::Proposer: Proposer<B, Error=Error>,
|
||||
<E::Proposer as Proposer<B>>::Create: Unpin + Send + 'static,
|
||||
I: BlockImport<B,Error=ConsensusError> + Send + Sync + 'static,
|
||||
Error: std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
Error: std::error::Error + Send + From<::sp_consensus::Error> + From<I::Error> + 'static,
|
||||
SO: SyncOracle + Send + Sync + Clone,
|
||||
CAW: CanAuthorWith<B> + Send,
|
||||
{
|
||||
@@ -317,14 +317,14 @@ pub fn start_babe<B, C, SC, E, I, SO, CAW, Error>(BabeParams {
|
||||
};
|
||||
|
||||
register_babe_inherent_data_provider(&inherent_data_providers, config.slot_duration())?;
|
||||
uncles::register_uncles_inherent_data_provider(
|
||||
sc_consensus_uncles::register_uncles_inherent_data_provider(
|
||||
client.clone(),
|
||||
select_chain.clone(),
|
||||
&inherent_data_providers,
|
||||
)?;
|
||||
|
||||
babe_info!("Starting BABE Authorship worker");
|
||||
let slot_worker = slots::start_slot_worker(
|
||||
let slot_worker = sc_consensus_slots::start_slot_worker(
|
||||
config.0,
|
||||
select_chain,
|
||||
worker,
|
||||
@@ -348,7 +348,7 @@ struct BabeWorker<B: BlockT, C, E, I, SO> {
|
||||
config: Config,
|
||||
}
|
||||
|
||||
impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I, SO> where
|
||||
impl<B, C, E, I, Error, SO> sc_consensus_slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I, SO> where
|
||||
B: BlockT<Hash=H256>,
|
||||
C: ProvideRuntimeApi + ProvideCache<B> + HeaderBackend<B> + HeaderMetadata<B, Error=ClientError>,
|
||||
C::Api: BabeApi<B>,
|
||||
@@ -357,7 +357,7 @@ impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I
|
||||
<E::Proposer as Proposer<B>>::Create: Unpin + Send + 'static,
|
||||
I: BlockImport<B> + Send + Sync + 'static,
|
||||
SO: SyncOracle + Send + Clone,
|
||||
Error: std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
Error: std::error::Error + Send + From<::sp_consensus::Error> + From<I::Error> + 'static,
|
||||
{
|
||||
type EpochData = Epoch;
|
||||
type Claim = (BabePreDigest, AuthorityPair);
|
||||
@@ -373,7 +373,7 @@ impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I
|
||||
self.block_import.clone()
|
||||
}
|
||||
|
||||
fn epoch_data(&self, parent: &B::Header, slot_number: u64) -> Result<Self::EpochData, consensus_common::Error> {
|
||||
fn epoch_data(&self, parent: &B::Header, slot_number: u64) -> Result<Self::EpochData, sp_consensus::Error> {
|
||||
self.epoch_changes.lock().epoch_for_child_of(
|
||||
descendent_query(&*self.client),
|
||||
&parent.hash(),
|
||||
@@ -383,7 +383,7 @@ impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I
|
||||
)
|
||||
.map_err(|e| ConsensusError::ChainLookup(format!("{:?}", e)))?
|
||||
.map(|e| e.into_inner())
|
||||
.ok_or(consensus_common::Error::InvalidAuthoritiesSet)
|
||||
.ok_or(sp_consensus::Error::InvalidAuthoritiesSet)
|
||||
}
|
||||
|
||||
fn authorities_len(&self, epoch_data: &Self::EpochData) -> usize {
|
||||
@@ -422,7 +422,7 @@ impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I
|
||||
&B::Hash,
|
||||
Vec<B::Extrinsic>,
|
||||
Self::Claim,
|
||||
) -> consensus_common::BlockImportParams<B> + Send> {
|
||||
) -> sp_consensus::BlockImportParams<B> + Send> {
|
||||
Box::new(|header, header_hash, body, (_, pair)| {
|
||||
// sign the pre-sealed hash of the block and then
|
||||
// add it to a digest item.
|
||||
@@ -455,9 +455,9 @@ impl<B, C, E, I, Error, SO> slots::SimpleSlotWorker<B> for BabeWorker<B, C, E, I
|
||||
&mut self.sync_oracle
|
||||
}
|
||||
|
||||
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, consensus_common::Error> {
|
||||
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, sp_consensus::Error> {
|
||||
self.env.init(block).map_err(|e| {
|
||||
consensus_common::Error::ClientImport(format!("{:?}", e))
|
||||
sp_consensus::Error::ClientImport(format!("{:?}", e))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -510,12 +510,12 @@ impl<B, C, E, I, Error, SO> SlotWorker<B> for BabeWorker<B, C, E, I, SO> where
|
||||
<E::Proposer as Proposer<B>>::Create: Unpin + Send + 'static,
|
||||
I: BlockImport<B> + Send + Sync + 'static,
|
||||
SO: SyncOracle + Send + Sync + Clone,
|
||||
Error: std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
Error: std::error::Error + Send + From<::sp_consensus::Error> + From<I::Error> + 'static,
|
||||
{
|
||||
type OnSlot = Pin<Box<dyn Future<Output = Result<(), consensus_common::Error>> + Send>>;
|
||||
type OnSlot = Pin<Box<dyn Future<Output = Result<(), sp_consensus::Error>> + Send>>;
|
||||
|
||||
fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot {
|
||||
<Self as slots::SimpleSlotWorker<B>>::on_slot(self, chain_head, slot_info)
|
||||
<Self as sc_consensus_slots::SimpleSlotWorker<B>>::on_slot(self, chain_head, slot_info)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,12 +571,12 @@ impl SlotCompatible for TimeSource {
|
||||
fn extract_timestamp_and_slot(
|
||||
&self,
|
||||
data: &InherentData,
|
||||
) -> Result<(TimestampInherent, u64, std::time::Duration), consensus_common::Error> {
|
||||
) -> Result<(TimestampInherent, u64, std::time::Duration), sp_consensus::Error> {
|
||||
trace!(target: "babe", "extract timestamp");
|
||||
data.timestamp_inherent_data()
|
||||
.and_then(|t| data.babe_inherent_data().map(|a| (t, a)))
|
||||
.map_err(Into::into)
|
||||
.map_err(consensus_common::Error::InherentData)
|
||||
.map_err(sp_consensus::Error::InherentData)
|
||||
.map(|(x, y)| (x, y, self.0.lock().0.take().unwrap_or_default()))
|
||||
}
|
||||
}
|
||||
@@ -592,7 +592,7 @@ pub struct BabeLink<Block: BlockT> {
|
||||
pub struct BabeVerifier<B, E, Block: BlockT, RA, PRA> {
|
||||
client: Arc<Client<B, E, Block, RA>>,
|
||||
api: Arc<PRA>,
|
||||
inherent_data_providers: inherents::InherentDataProviders,
|
||||
inherent_data_providers: sp_inherents::InherentDataProviders,
|
||||
config: Config,
|
||||
epoch_changes: SharedEpochChanges<Block>,
|
||||
time_source: TimeSource,
|
||||
@@ -818,13 +818,13 @@ pub type BabeImportQueue<B> = BasicQueue<B>;
|
||||
fn register_babe_inherent_data_provider(
|
||||
inherent_data_providers: &InherentDataProviders,
|
||||
slot_duration: u64,
|
||||
) -> Result<(), consensus_common::Error> {
|
||||
) -> Result<(), sp_consensus::Error> {
|
||||
debug!(target: "babe", "Registering");
|
||||
if !inherent_data_providers.has_provider(&babe_primitives::inherents::INHERENT_IDENTIFIER) {
|
||||
if !inherent_data_providers.has_provider(&sp_consensus_babe::inherents::INHERENT_IDENTIFIER) {
|
||||
inherent_data_providers
|
||||
.register_provider(babe_primitives::inherents::InherentDataProvider::new(slot_duration))
|
||||
.register_provider(sp_consensus_babe::inherents::InherentDataProvider::new(slot_duration))
|
||||
.map_err(Into::into)
|
||||
.map_err(consensus_common::Error::InherentData)
|
||||
.map_err(sp_consensus::Error::InherentData)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
use super::*;
|
||||
use authorship::claim_slot;
|
||||
|
||||
use babe_primitives::{AuthorityPair, SlotNumber};
|
||||
use block_builder::BlockBuilder;
|
||||
use consensus_common::NoNetwork as DummyOracle;
|
||||
use consensus_common::import_queue::{
|
||||
use sp_consensus_babe::{AuthorityPair, SlotNumber};
|
||||
use sc_block_builder::BlockBuilder;
|
||||
use sp_consensus::NoNetwork as DummyOracle;
|
||||
use sp_consensus::import_queue::{
|
||||
BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport,
|
||||
};
|
||||
use sc_network_test::*;
|
||||
@@ -33,8 +33,7 @@ use sc_network_test::{Block as TestBlock, PeersClient};
|
||||
use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig};
|
||||
use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}};
|
||||
use tokio::runtime::current_thread;
|
||||
use client_api::BlockchainEvents;
|
||||
use test_client;
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use log::debug;
|
||||
use std::{time::Duration, cell::RefCell};
|
||||
|
||||
@@ -42,11 +41,11 @@ type Item = DigestItem<Hash>;
|
||||
|
||||
type Error = sp_blockchain::Error;
|
||||
|
||||
type TestClient = client::Client<
|
||||
test_client::Backend,
|
||||
test_client::Executor,
|
||||
type TestClient = sc_client::Client<
|
||||
substrate_test_runtime_client::Backend,
|
||||
substrate_test_runtime_client::Executor,
|
||||
TestBlock,
|
||||
test_client::runtime::RuntimeApi,
|
||||
substrate_test_runtime_client::runtime::RuntimeApi,
|
||||
>;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
@@ -196,10 +195,10 @@ type TestExtrinsic = <TestBlock as BlockT>::Extrinsic;
|
||||
|
||||
pub struct TestVerifier {
|
||||
inner: BabeVerifier<
|
||||
test_client::Backend,
|
||||
test_client::Executor,
|
||||
substrate_test_runtime_client::Backend,
|
||||
substrate_test_runtime_client::Executor,
|
||||
TestBlock,
|
||||
test_client::runtime::RuntimeApi,
|
||||
substrate_test_runtime_client::runtime::RuntimeApi,
|
||||
PeersFullClient,
|
||||
>,
|
||||
mutator: Mutator,
|
||||
@@ -358,7 +357,7 @@ fn run_one_test(
|
||||
let select_chain = peer.select_chain().expect("Full client has select_chain");
|
||||
|
||||
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
|
||||
let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
|
||||
let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
|
||||
keystore.write().insert_ephemeral_from_seed::<AuthorityPair>(seed).expect("Generates authority key");
|
||||
keystore_paths.push(keystore_path);
|
||||
|
||||
@@ -403,7 +402,7 @@ fn run_one_test(
|
||||
force_authoring: false,
|
||||
babe_link: data.link.clone(),
|
||||
keystore,
|
||||
can_author_with: consensus_common::AlwaysCanAuthor,
|
||||
can_author_with: sp_consensus::AlwaysCanAuthor,
|
||||
}).expect("Starts babe"));
|
||||
}
|
||||
|
||||
@@ -483,7 +482,7 @@ fn sig_is_not_pre_digest() {
|
||||
fn can_author_block() {
|
||||
let _ = env_logger::try_init();
|
||||
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
|
||||
let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
|
||||
let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
|
||||
let pair = keystore.write().insert_ephemeral_from_seed::<AuthorityPair>("//Alice")
|
||||
.expect("Generates authority pair");
|
||||
|
||||
@@ -634,7 +633,7 @@ fn importing_block_one_sets_genesis_epoch() {
|
||||
|
||||
#[test]
|
||||
fn importing_epoch_change_block_prunes_tree() {
|
||||
use client_api::Finalizer;
|
||||
use sc_client_api::Finalizer;
|
||||
|
||||
let mut net = BabeTestNet::new(1);
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
//! Verification for BABE headers.
|
||||
use schnorrkel::vrf::{VRFOutput, VRFProof};
|
||||
use sp_runtime::{traits::Header, traits::DigestItemFor};
|
||||
use primitives::{Pair, Public};
|
||||
use babe_primitives::{Epoch, BabePreDigest, CompatibleDigestItem, AuthorityId};
|
||||
use babe_primitives::{AuthoritySignature, SlotNumber, AuthorityIndex, AuthorityPair};
|
||||
use slots::CheckedHeader;
|
||||
use sp_core::{Pair, Public};
|
||||
use sp_consensus_babe::{Epoch, BabePreDigest, CompatibleDigestItem, AuthorityId};
|
||||
use sp_consensus_babe::{AuthoritySignature, SlotNumber, AuthorityIndex, AuthorityPair};
|
||||
use sc_consensus_slots::CheckedHeader;
|
||||
use log::{debug, trace};
|
||||
use super::{find_pre_digest, babe_err, BlockT, Error};
|
||||
use super::authorship::{make_transcript, calculate_primary_threshold, check_primary_threshold, secondary_slot_author};
|
||||
|
||||
@@ -7,14 +7,14 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
client-api = { package = "sc-client-api", path = "../../api" }
|
||||
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" }
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents" }
|
||||
pow-primitives = { package = "sp-consensus-pow", path = "../../../primitives/consensus/pow" }
|
||||
consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
sc-client-api = { path = "../../api" }
|
||||
sp-block-builder = { path = "../../../primitives/block-builder" }
|
||||
sp-inherents = { path = "../../../primitives/inherents" }
|
||||
sp-consensus-pow = { path = "../../../primitives/consensus/pow" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
log = "0.4.8"
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
sp-timestamp = { path = "../../../primitives/timestamp" }
|
||||
|
||||
@@ -32,23 +32,23 @@
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::collections::HashMap;
|
||||
use client_api::{BlockOf, backend::AuxStore};
|
||||
use sc_client_api::{BlockOf, backend::AuxStore};
|
||||
use sp_blockchain::{HeaderBackend, ProvideCache, well_known_cache_keys::Id as CacheKeyId};
|
||||
use block_builder_api::BlockBuilder as BlockBuilderApi;
|
||||
use sp_block_builder::BlockBuilder as BlockBuilderApi;
|
||||
use sp_runtime::{Justification, RuntimeString};
|
||||
use sp_runtime::generic::{BlockId, Digest, DigestItem};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi};
|
||||
use sp_timestamp::{TimestampInherentData, InherentError as TIError};
|
||||
use pow_primitives::{Seal, TotalDifficulty, POW_ENGINE_ID};
|
||||
use primitives::H256;
|
||||
use inherents::{InherentDataProviders, InherentData};
|
||||
use consensus_common::{
|
||||
use sp_consensus_pow::{Seal, TotalDifficulty, POW_ENGINE_ID};
|
||||
use sp_core::H256;
|
||||
use sp_inherents::{InherentDataProviders, InherentData};
|
||||
use sp_consensus::{
|
||||
BlockImportParams, BlockOrigin, ForkChoiceStrategy, SyncOracle, Environment, Proposer,
|
||||
SelectChain, Error as ConsensusError, CanAuthorWith,
|
||||
};
|
||||
use consensus_common::import_queue::{BoxBlockImport, BasicQueue, Verifier};
|
||||
use sp_consensus::import_queue::{BoxBlockImport, BasicQueue, Verifier};
|
||||
use codec::{Encode, Decode};
|
||||
use client_api;
|
||||
use sc_client_api;
|
||||
use log::*;
|
||||
|
||||
#[derive(derive_more::Display, Debug)]
|
||||
@@ -74,7 +74,7 @@ pub enum Error<B: BlockT> {
|
||||
#[display(fmt = "Error with block built on {:?}: {:?}", _0, _1)]
|
||||
BlockBuiltError(B::Hash, ConsensusError),
|
||||
#[display(fmt = "Creating inherents failed: {}", _0)]
|
||||
CreateInherents(inherents::Error),
|
||||
CreateInherents(sp_inherents::Error),
|
||||
#[display(fmt = "Checking inherents failed: {}", _0)]
|
||||
CheckInherents(String),
|
||||
Client(sp_blockchain::Error),
|
||||
@@ -151,7 +151,7 @@ pub trait PowAlgorithm<B: BlockT> {
|
||||
pub struct PowVerifier<B: BlockT<Hash=H256>, C, S, Algorithm> {
|
||||
client: Arc<C>,
|
||||
algorithm: Algorithm,
|
||||
inherent_data_providers: inherents::InherentDataProviders,
|
||||
inherent_data_providers: sp_inherents::InherentDataProviders,
|
||||
select_chain: Option<S>,
|
||||
check_inherents_after: <<B as BlockT>::Header as HeaderT>::Number,
|
||||
}
|
||||
@@ -162,7 +162,7 @@ impl<B: BlockT<Hash=H256>, C, S, Algorithm> PowVerifier<B, C, S, Algorithm> {
|
||||
algorithm: Algorithm,
|
||||
check_inherents_after: <<B as BlockT>::Header as HeaderT>::Number,
|
||||
select_chain: Option<S>,
|
||||
inherent_data_providers: inherents::InherentDataProviders,
|
||||
inherent_data_providers: sp_inherents::InherentDataProviders,
|
||||
) -> Self {
|
||||
Self { client, algorithm, inherent_data_providers, select_chain, check_inherents_after }
|
||||
}
|
||||
@@ -314,12 +314,12 @@ impl<B: BlockT<Hash=H256>, C, S, Algorithm> Verifier<B> for PowVerifier<B, C, S,
|
||||
/// Register the PoW inherent data provider, if not registered already.
|
||||
pub fn register_pow_inherent_data_provider(
|
||||
inherent_data_providers: &InherentDataProviders,
|
||||
) -> Result<(), consensus_common::Error> {
|
||||
) -> Result<(), sp_consensus::Error> {
|
||||
if !inherent_data_providers.has_provider(&sp_timestamp::INHERENT_IDENTIFIER) {
|
||||
inherent_data_providers
|
||||
.register_provider(sp_timestamp::InherentDataProvider)
|
||||
.map_err(Into::into)
|
||||
.map_err(consensus_common::Error::InherentData)
|
||||
.map_err(sp_consensus::Error::InherentData)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
@@ -336,7 +336,7 @@ pub fn import_queue<B, C, S, Algorithm>(
|
||||
check_inherents_after: <<B as BlockT>::Header as HeaderT>::Number,
|
||||
select_chain: Option<S>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
) -> Result<PowImportQueue<B>, consensus_common::Error> where
|
||||
) -> Result<PowImportQueue<B>, sp_consensus::Error> where
|
||||
B: BlockT<Hash=H256>,
|
||||
C: ProvideRuntimeApi + HeaderBackend<B> + BlockOf + ProvideCache<B> + AuxStore,
|
||||
C: Send + Sync + AuxStore + 'static,
|
||||
@@ -382,7 +382,7 @@ pub fn start_mine<B: BlockT<Hash=H256>, C, Algorithm, E, SO, S, CAW>(
|
||||
mut sync_oracle: SO,
|
||||
build_time: std::time::Duration,
|
||||
select_chain: Option<S>,
|
||||
inherent_data_providers: inherents::InherentDataProviders,
|
||||
inherent_data_providers: sp_inherents::InherentDataProviders,
|
||||
can_author_with: CAW,
|
||||
) where
|
||||
C: HeaderBackend<B> + AuxStore + 'static,
|
||||
@@ -433,7 +433,7 @@ fn mine_loop<B: BlockT<Hash=H256>, C, Algorithm, E, SO, S, CAW>(
|
||||
sync_oracle: &mut SO,
|
||||
build_time: std::time::Duration,
|
||||
select_chain: Option<&S>,
|
||||
inherent_data_providers: &inherents::InherentDataProviders,
|
||||
inherent_data_providers: &sp_inherents::InherentDataProviders,
|
||||
can_author_with: &CAW,
|
||||
) -> Result<(), Error<B>> where
|
||||
C: HeaderBackend<B> + AuxStore,
|
||||
|
||||
@@ -8,17 +8,17 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
client-api = { package = "sc-client-api", path = "../../api" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sc-client-api = { path = "../../api" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
sc-telemetry = { path = "../../telemetry" }
|
||||
consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
sp-inherents = { path = "../../../primitives/inherents" }
|
||||
futures = "0.3.1"
|
||||
futures-timer = "2.0"
|
||||
parking_lot = "0.9.0"
|
||||
log = "0.4.8"
|
||||
|
||||
[dev-dependencies]
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" }
|
||||
substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" }
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Schema for slots in the aux-db.
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use client_api::backend::AuxStore;
|
||||
use sc_client_api::backend::AuxStore;
|
||||
use sp_blockchain::{Result as ClientResult, Error as ClientError};
|
||||
use sp_runtime::traits::Header;
|
||||
|
||||
@@ -151,10 +151,10 @@ pub fn check_equivocation<C, H, P>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use primitives::{sr25519, Pair};
|
||||
use primitives::hash::H256;
|
||||
use sp_core::{sr25519, Pair};
|
||||
use sp_core::hash::H256;
|
||||
use sp_runtime::testing::{Header as HeaderTest, Digest as DigestTest};
|
||||
use test_client;
|
||||
use substrate_test_runtime_client;
|
||||
|
||||
use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation};
|
||||
|
||||
@@ -175,7 +175,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn check_equivocation_works() {
|
||||
let client = test_client::new();
|
||||
let client = substrate_test_runtime_client::new();
|
||||
let (pair, _seed) = sr25519::Pair::generate();
|
||||
let public = pair.public();
|
||||
|
||||
|
||||
@@ -31,23 +31,23 @@ use slots::Slots;
|
||||
pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData};
|
||||
use sp_consensus::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData};
|
||||
use futures::{prelude::*, future::{self, Either}};
|
||||
use futures_timer::Delay;
|
||||
use inherents::{InherentData, InherentDataProviders};
|
||||
use sp_inherents::{InherentData, InherentDataProviders};
|
||||
use log::{debug, error, info, warn};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{ApiRef, Block as BlockT, Header, ProvideRuntimeApi};
|
||||
use std::{fmt::Debug, ops::Deref, pin::Pin, sync::Arc, time::{Instant, Duration}};
|
||||
use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO};
|
||||
use parking_lot::Mutex;
|
||||
use client_api;
|
||||
use sc_client_api;
|
||||
|
||||
/// A worker that should be invoked at every new slot.
|
||||
pub trait SlotWorker<B: BlockT> {
|
||||
/// The type of the future that will be returned when a new slot is
|
||||
/// triggered.
|
||||
type OnSlot: Future<Output = Result<(), consensus_common::Error>>;
|
||||
type OnSlot: Future<Output = Result<(), sp_consensus::Error>>;
|
||||
|
||||
/// Called when a new slot is triggered.
|
||||
fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot;
|
||||
@@ -80,7 +80,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
|
||||
/// Returns the epoch data necessary for authoring. For time-dependent epochs,
|
||||
/// use the provided slot number as a canonical source of time.
|
||||
fn epoch_data(&self, header: &B::Header, slot_number: u64) -> Result<Self::EpochData, consensus_common::Error>;
|
||||
fn epoch_data(&self, header: &B::Header, slot_number: u64) -> Result<Self::EpochData, sp_consensus::Error>;
|
||||
|
||||
/// Returns the number of authorities given the epoch data.
|
||||
fn authorities_len(&self, epoch_data: &Self::EpochData) -> usize;
|
||||
@@ -102,7 +102,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
&B::Hash,
|
||||
Vec<B::Extrinsic>,
|
||||
Self::Claim,
|
||||
) -> consensus_common::BlockImportParams<B> + Send>;
|
||||
) -> sp_consensus::BlockImportParams<B> + Send>;
|
||||
|
||||
/// Whether to force authoring if offline.
|
||||
fn force_authoring(&self) -> bool;
|
||||
@@ -111,7 +111,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
fn sync_oracle(&mut self) -> &mut Self::SyncOracle;
|
||||
|
||||
/// Returns a `Proposer` to author on top of the given block.
|
||||
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, consensus_common::Error>;
|
||||
fn proposer(&mut self, block: &B::Header) -> Result<Self::Proposer, sp_consensus::Error>;
|
||||
|
||||
/// Remaining duration of the slot.
|
||||
fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration {
|
||||
@@ -134,7 +134,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
|
||||
/// Implements the `on_slot` functionality from `SlotWorker`.
|
||||
fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo)
|
||||
-> Pin<Box<dyn Future<Output = Result<(), consensus_common::Error>> + Send>> where
|
||||
-> Pin<Box<dyn Future<Output = Result<(), sp_consensus::Error>> + Send>> where
|
||||
Self: Send + Sync,
|
||||
<Self::Proposer as Proposer<B>>::Create: Unpin + Send + 'static,
|
||||
{
|
||||
@@ -222,7 +222,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
logs,
|
||||
},
|
||||
slot_remaining_duration,
|
||||
).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e)));
|
||||
).map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e)));
|
||||
let delay: Box<dyn Future<Output=()> + Unpin + Send> = match proposing_remaining_duration {
|
||||
Some(r) => Box::new(Delay::new(r)),
|
||||
None => Box::new(future::pending()),
|
||||
@@ -239,7 +239,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
||||
telemetry!(CONSENSUS_INFO; "slots.discarding_proposal_took_too_long";
|
||||
"slot" => slot_number,
|
||||
);
|
||||
Err(consensus_common::Error::ClientImport("Timeout in the Slots proposer".into()))
|
||||
Err(sp_consensus::Error::ClientImport("Timeout in the Slots proposer".into()))
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -293,7 +293,7 @@ pub trait SlotCompatible {
|
||||
fn extract_timestamp_and_slot(
|
||||
&self,
|
||||
inherent: &InherentData,
|
||||
) -> Result<(u64, u64, std::time::Duration), consensus_common::Error>;
|
||||
) -> Result<(u64, u64, std::time::Duration), sp_consensus::Error>;
|
||||
|
||||
/// Get the difference between chain time and local time. Defaults to
|
||||
/// always returning zero.
|
||||
@@ -417,7 +417,7 @@ impl<T: Clone> SlotDuration<T> {
|
||||
/// `slot_key` is marked as `'static`, as it should really be a
|
||||
/// compile-time constant.
|
||||
pub fn get_or_compute<B: BlockT, C, CB>(client: &C, cb: CB) -> sp_blockchain::Result<Self> where
|
||||
C: client_api::backend::AuxStore,
|
||||
C: sc_client_api::backend::AuxStore,
|
||||
C: ProvideRuntimeApi,
|
||||
CB: FnOnce(ApiRef<C::Api>, &BlockId<B>) -> sp_blockchain::Result<T>,
|
||||
T: SlotData + Encode + Decode + Debug,
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
//! This is used instead of `futures_timer::Interval` because it was unreliable.
|
||||
|
||||
use super::SlotCompatible;
|
||||
use consensus_common::Error;
|
||||
use sp_consensus::Error;
|
||||
use futures::{prelude::*, task::Context, task::Poll};
|
||||
use inherents::{InherentData, InherentDataProviders};
|
||||
use sp_inherents::{InherentData, InherentDataProviders};
|
||||
|
||||
use std::{pin::Pin, time::{Duration, Instant}};
|
||||
use futures_timer::Delay;
|
||||
@@ -135,7 +135,7 @@ impl<SC: SlotCompatible + Unpin> Stream for Slots<SC> {
|
||||
|
||||
let inherent_data = match self.inherent_data_providers.create_inherent_data() {
|
||||
Ok(id) => id,
|
||||
Err(err) => return Poll::Ready(Some(Err(consensus_common::Error::InherentData(err)))),
|
||||
Err(err) => return Poll::Ready(Some(Err(sp_consensus::Error::InherentData(err)))),
|
||||
};
|
||||
let result = self.timestamp_extractor.extract_timestamp_and_slot(&inherent_data);
|
||||
let (timestamp, slot_num, offset) = match result {
|
||||
|
||||
@@ -6,10 +6,10 @@ description = "Generic uncle inclusion utilities for consensus"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
client-api = { package = "sc-client-api", path = "../../api" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
sc-client-api = { path = "../../api" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
sp-authorship = { path = "../../../primitives/authorship" }
|
||||
consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" }
|
||||
inherents = { package = "sp-inherents", path = "../../../primitives/inherents" }
|
||||
sp-consensus = { path = "../../../primitives/consensus/common" }
|
||||
sp-inherents = { path = "../../../primitives/inherents" }
|
||||
log = "0.4.8"
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#![deny(warnings)]
|
||||
#![forbid(unsafe_code, missing_docs)]
|
||||
|
||||
use consensus_common::SelectChain;
|
||||
use inherents::{InherentDataProviders};
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_inherents::{InherentDataProviders};
|
||||
use log::warn;
|
||||
use client_api::ProvideUncles;
|
||||
use sc_client_api::ProvideUncles;
|
||||
use sp_runtime::traits::{Block as BlockT, Header};
|
||||
use std::sync::Arc;
|
||||
use sp_authorship;
|
||||
@@ -35,7 +35,7 @@ pub fn register_uncles_inherent_data_provider<B, C, SC>(
|
||||
client: Arc<C>,
|
||||
select_chain: SC,
|
||||
inherent_data_providers: &InherentDataProviders,
|
||||
) -> Result<(), consensus_common::Error> where
|
||||
) -> Result<(), sp_consensus::Error> where
|
||||
B: BlockT,
|
||||
C: ProvideUncles<B> + Send + Sync + 'static,
|
||||
SC: SelectChain<B> + 'static,
|
||||
@@ -60,7 +60,7 @@ pub fn register_uncles_inherent_data_provider<B, C, SC>(
|
||||
}
|
||||
}
|
||||
}))
|
||||
.map_err(|err| consensus_common::Error::InherentData(err.into()))?;
|
||||
.map_err(|err| sp_consensus::Error::InherentData(err.into()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -12,21 +12,21 @@ kvdb-rocksdb = { version = "0.2", optional = true }
|
||||
kvdb-memorydb = "0.1.2"
|
||||
linked-hash-map = "0.5.2"
|
||||
hash-db = "0.15.2"
|
||||
client-api = { package = "sc-client-api", path = "../api" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sc-client-api = { path = "../api" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-runtime = { path = "../../primitives/runtime" }
|
||||
client = { package = "sc-client", path = "../" }
|
||||
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
sc-client = { path = "../" }
|
||||
sp-state-machine = { path = "../../primitives/state-machine" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
executor = { package = "sc-executor", path = "../executor" }
|
||||
state_db = { package = "sc-state-db", path = "../state-db" }
|
||||
trie = { package = "sp-trie", path = "../../primitives/trie" }
|
||||
consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" }
|
||||
sc-executor = { path = "../executor" }
|
||||
sc-state-db = { path = "../state-db" }
|
||||
sp-trie = { path = "../../primitives/trie" }
|
||||
sp-consensus = { path = "../../primitives/consensus/common" }
|
||||
sp-blockchain = { path = "../../primitives/blockchain" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-keyring = { path = "../../primitives/keyring" }
|
||||
test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" }
|
||||
substrate-test-runtime-client = { path = "../../test-utils/runtime/client" }
|
||||
env_logger = "0.7.0"
|
||||
quickcheck = "0.9"
|
||||
|
||||
|
||||
+1
-1
@@ -724,7 +724,7 @@ fn read_forks<Block: BlockT, T: CacheItemT, S: Storage<Block, T>>(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use test_client::runtime::H256;
|
||||
use substrate_test_runtime_client::runtime::H256;
|
||||
use sp_runtime::testing::{Header, Block as RawBlock, ExtrinsicWrapper};
|
||||
use sp_runtime::traits::Header as HeaderT;
|
||||
use crate::cache::list_storage::tests::{DummyStorage, FaultyStorage, DummyTransaction};
|
||||
|
||||
Vendored
+1
-1
@@ -21,7 +21,7 @@ use parking_lot::RwLock;
|
||||
|
||||
use kvdb::{KeyValueDB, DBTransaction};
|
||||
|
||||
use client_api::blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, Cache as BlockchainCache};
|
||||
use sc_client_api::blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, Cache as BlockchainCache};
|
||||
use sp_blockchain::Result as ClientResult;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::generic::BlockId;
|
||||
|
||||
@@ -39,9 +39,9 @@ use std::path::PathBuf;
|
||||
use std::io;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use client_api::{execution_extensions::ExecutionExtensions, ForkBlocks};
|
||||
use client_api::backend::NewBlockState;
|
||||
use client_api::backend::{StorageCollection, ChildStorageCollection};
|
||||
use sc_client_api::{execution_extensions::ExecutionExtensions, ForkBlocks};
|
||||
use sc_client_api::backend::NewBlockState;
|
||||
use sc_client_api::backend::{StorageCollection, ChildStorageCollection};
|
||||
use sp_blockchain::{
|
||||
Result as ClientResult, Error as ClientError,
|
||||
well_known_cache_keys, HeaderBackend,
|
||||
@@ -49,10 +49,10 @@ use sp_blockchain::{
|
||||
use codec::{Decode, Encode};
|
||||
use hash_db::{Hasher, Prefix};
|
||||
use kvdb::{KeyValueDB, DBTransaction};
|
||||
use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key};
|
||||
use sp_trie::{MemoryDB, PrefixedMemoryDB, prefixed_key};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor};
|
||||
use primitives::storage::{well_known_keys, ChildInfo};
|
||||
use sp_core::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor};
|
||||
use sp_core::storage::{well_known_keys, ChildInfo};
|
||||
use sp_runtime::{
|
||||
generic::{BlockId, DigestItem}, Justification, Storage,
|
||||
BuildStorage,
|
||||
@@ -60,21 +60,21 @@ use sp_runtime::{
|
||||
use sp_runtime::traits::{
|
||||
Block as BlockT, Header as HeaderT, NumberFor, Zero, One, SaturatedConversion
|
||||
};
|
||||
use executor::RuntimeInfo;
|
||||
use state_machine::{
|
||||
use sc_executor::RuntimeInfo;
|
||||
use sp_state_machine::{
|
||||
DBValue, ChangesTrieTransaction, ChangesTrieCacheAction, ChangesTrieBuildCache,
|
||||
backend::Backend as StateBackend,
|
||||
};
|
||||
use crate::utils::{Meta, db_err, meta_keys, read_db, read_meta};
|
||||
use client::leaves::{LeafSet, FinalizationDisplaced};
|
||||
use state_db::StateDb;
|
||||
use sc_client::leaves::{LeafSet, FinalizationDisplaced};
|
||||
use sc_state_db::StateDb;
|
||||
use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache};
|
||||
use crate::storage_cache::{CachingState, SharedCache, new_shared_cache};
|
||||
use log::{trace, debug, warn};
|
||||
pub use state_db::PruningMode;
|
||||
pub use sc_state_db::PruningMode;
|
||||
|
||||
#[cfg(feature = "test-helpers")]
|
||||
use client::in_mem::Backend as InMemoryBackend;
|
||||
use sc_client::in_mem::Backend as InMemoryBackend;
|
||||
|
||||
const CANONICALIZATION_DELAY: u64 = 4096;
|
||||
const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768;
|
||||
@@ -83,7 +83,7 @@ const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768;
|
||||
const DEFAULT_CHILD_RATIO: (usize, usize) = (1, 10);
|
||||
|
||||
/// DB-backed patricia trie state, transaction type is an overlay of changes to commit.
|
||||
pub type DbState = state_machine::TrieBackend<Arc<dyn state_machine::Storage<Blake2Hasher>>, Blake2Hasher>;
|
||||
pub type DbState = sp_state_machine::TrieBackend<Arc<dyn sp_state_machine::Storage<Blake2Hasher>>, Blake2Hasher>;
|
||||
|
||||
/// Re-export the KVDB trait so that one can pass an implementation of it.
|
||||
pub use kvdb;
|
||||
@@ -239,7 +239,7 @@ impl<B: BlockT> StateBackend<Blake2Hasher> for RefTrackingState<B> {
|
||||
|
||||
fn as_trie_backend(
|
||||
&mut self,
|
||||
) -> Option<&state_machine::TrieBackend<Self::TrieBackendStorage, Blake2Hasher>> {
|
||||
) -> Option<&sp_state_machine::TrieBackend<Self::TrieBackendStorage, Blake2Hasher>> {
|
||||
self.state.as_trie_backend()
|
||||
}
|
||||
}
|
||||
@@ -278,9 +278,9 @@ pub fn new_client<E, S, Block, RA>(
|
||||
fork_blocks: ForkBlocks<Block>,
|
||||
execution_extensions: ExecutionExtensions<Block>,
|
||||
) -> Result<(
|
||||
client::Client<
|
||||
sc_client::Client<
|
||||
Backend<Block>,
|
||||
client::LocalCallExecutor<Backend<Block>, E>,
|
||||
sc_client::LocalCallExecutor<Backend<Block>, E>,
|
||||
Block,
|
||||
RA,
|
||||
>,
|
||||
@@ -294,9 +294,9 @@ pub fn new_client<E, S, Block, RA>(
|
||||
S: BuildStorage,
|
||||
{
|
||||
let backend = Arc::new(Backend::new(settings, CANONICALIZATION_DELAY)?);
|
||||
let executor = client::LocalCallExecutor::new(backend.clone(), executor);
|
||||
let executor = sc_client::LocalCallExecutor::new(backend.clone(), executor);
|
||||
Ok((
|
||||
client::Client::new(backend.clone(), executor, genesis_storage, fork_blocks, execution_extensions)?,
|
||||
sc_client::Client::new(backend.clone(), executor, genesis_storage, fork_blocks, execution_extensions)?,
|
||||
backend,
|
||||
))
|
||||
}
|
||||
@@ -326,7 +326,7 @@ struct PendingBlock<Block: BlockT> {
|
||||
// wrapper that implements trait required for state_db
|
||||
struct StateMetaDb<'a>(&'a dyn KeyValueDB);
|
||||
|
||||
impl<'a> state_db::MetaDb for StateMetaDb<'a> {
|
||||
impl<'a> sc_state_db::MetaDb for StateMetaDb<'a> {
|
||||
type Error = io::Error;
|
||||
|
||||
fn get_meta(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error> {
|
||||
@@ -379,14 +379,14 @@ impl<Block: BlockT> BlockchainDb<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> client::blockchain::HeaderBackend<Block> for BlockchainDb<Block> {
|
||||
impl<Block: BlockT> sc_client::blockchain::HeaderBackend<Block> for BlockchainDb<Block> {
|
||||
fn header(&self, id: BlockId<Block>) -> ClientResult<Option<Block::Header>> {
|
||||
utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id)
|
||||
}
|
||||
|
||||
fn info(&self) -> client::blockchain::Info<Block> {
|
||||
fn info(&self) -> sc_client::blockchain::Info<Block> {
|
||||
let meta = self.meta.read();
|
||||
client::blockchain::Info {
|
||||
sc_client::blockchain::Info {
|
||||
best_hash: meta.best_hash,
|
||||
best_number: meta.best_number,
|
||||
genesis_hash: meta.genesis_hash,
|
||||
@@ -395,7 +395,7 @@ impl<Block: BlockT> client::blockchain::HeaderBackend<Block> for BlockchainDb<Bl
|
||||
}
|
||||
}
|
||||
|
||||
fn status(&self, id: BlockId<Block>) -> ClientResult<client::blockchain::BlockStatus> {
|
||||
fn status(&self, id: BlockId<Block>) -> ClientResult<sc_client::blockchain::BlockStatus> {
|
||||
let exists = match id {
|
||||
BlockId::Hash(_) => read_db(
|
||||
&*self.db,
|
||||
@@ -406,8 +406,8 @@ impl<Block: BlockT> client::blockchain::HeaderBackend<Block> for BlockchainDb<Bl
|
||||
BlockId::Number(n) => n <= self.meta.read().best_number,
|
||||
};
|
||||
match exists {
|
||||
true => Ok(client::blockchain::BlockStatus::InChain),
|
||||
false => Ok(client::blockchain::BlockStatus::Unknown),
|
||||
true => Ok(sc_client::blockchain::BlockStatus::InChain),
|
||||
false => Ok(sc_client::blockchain::BlockStatus::Unknown),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ impl<Block: BlockT> client::blockchain::HeaderBackend<Block> for BlockchainDb<Bl
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
impl<Block: BlockT> sc_client::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
fn body(&self, id: BlockId<Block>) -> ClientResult<Option<Vec<Block::Extrinsic>>> {
|
||||
match read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, id)? {
|
||||
Some(body) => match Decode::decode(&mut &body[..]) {
|
||||
@@ -452,7 +452,7 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
Ok(self.meta.read().finalized_hash.clone())
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<dyn client::blockchain::Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn sc_client::blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -465,8 +465,8 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> client::blockchain::ProvideCache<Block> for BlockchainDb<Block> {
|
||||
fn cache(&self) -> Option<Arc<dyn client::blockchain::Cache<Block>>> {
|
||||
impl<Block: BlockT> sc_client::blockchain::ProvideCache<Block> for BlockchainDb<Block> {
|
||||
fn cache(&self) -> Option<Arc<dyn sc_client::blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,7 @@ impl<Block: BlockT, H: Hasher> BlockImportOperation<Block, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> client_api::backend::BlockImportOperation<Block, Blake2Hasher>
|
||||
impl<Block> sc_client_api::backend::BlockImportOperation<Block, Blake2Hasher>
|
||||
for BlockImportOperation<Block, Blake2Hasher> where Block: BlockT<Hash=H256>,
|
||||
{
|
||||
type State = CachingState<Blake2Hasher, RefTrackingState<Block>, Block>;
|
||||
@@ -630,7 +630,7 @@ struct StorageDb<Block: BlockT> {
|
||||
pub state_db: StateDb<Block::Hash, Vec<u8>>,
|
||||
}
|
||||
|
||||
impl<Block: BlockT> state_machine::Storage<Blake2Hasher> for StorageDb<Block> {
|
||||
impl<Block: BlockT> sp_state_machine::Storage<Blake2Hasher> for StorageDb<Block> {
|
||||
fn get(&self, key: &H256, prefix: Prefix) -> Result<Option<DBValue>, String> {
|
||||
let key = prefixed_key::<Blake2Hasher>(key, prefix);
|
||||
self.state_db.get(&key, self).map(|r| r.map(|v| DBValue::from_slice(&v)))
|
||||
@@ -638,7 +638,7 @@ impl<Block: BlockT> state_machine::Storage<Blake2Hasher> for StorageDb<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> state_db::NodeDb for StorageDb<Block> {
|
||||
impl<Block: BlockT> sc_state_db::NodeDb for StorageDb<Block> {
|
||||
type Error = io::Error;
|
||||
type Key = [u8];
|
||||
|
||||
@@ -653,12 +653,12 @@ impl DbGenesisStorage {
|
||||
pub fn new() -> Self {
|
||||
let mut root = H256::default();
|
||||
let mut mdb = MemoryDB::<Blake2Hasher>::default();
|
||||
state_machine::TrieDBMut::<Blake2Hasher>::new(&mut mdb, &mut root);
|
||||
sp_state_machine::TrieDBMut::<Blake2Hasher>::new(&mut mdb, &mut root);
|
||||
DbGenesisStorage(root)
|
||||
}
|
||||
}
|
||||
|
||||
impl state_machine::Storage<Blake2Hasher> for DbGenesisStorage {
|
||||
impl sp_state_machine::Storage<Blake2Hasher> for DbGenesisStorage {
|
||||
fn get(&self, _key: &H256, _prefix: Prefix) -> Result<Option<DBValue>, String> {
|
||||
Ok(None)
|
||||
}
|
||||
@@ -700,11 +700,11 @@ impl<Block: BlockT<Hash=H256>> DbChangesTrieStorage<Block> {
|
||||
None => return,
|
||||
};
|
||||
|
||||
state_machine::prune_changes_tries(
|
||||
sp_state_machine::prune_changes_tries(
|
||||
config,
|
||||
&*self,
|
||||
min_blocks_to_keep.into(),
|
||||
&state_machine::ChangesTrieAnchorBlockId {
|
||||
&sp_state_machine::ChangesTrieAnchorBlockId {
|
||||
hash: convert_hash(&block_hash),
|
||||
number: block_num,
|
||||
},
|
||||
@@ -712,7 +712,7 @@ impl<Block: BlockT<Hash=H256>> DbChangesTrieStorage<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> client_api::backend::PrunableStateChangesTrieStorage<Block, Blake2Hasher>
|
||||
impl<Block> sc_client_api::backend::PrunableStateChangesTrieStorage<Block, Blake2Hasher>
|
||||
for DbChangesTrieStorage<Block>
|
||||
where
|
||||
Block: BlockT<Hash=H256>,
|
||||
@@ -723,7 +723,7 @@ where
|
||||
best_finalized_block: NumberFor<Block>,
|
||||
) -> NumberFor<Block> {
|
||||
match self.min_blocks_to_keep {
|
||||
Some(min_blocks_to_keep) => state_machine::oldest_non_pruned_changes_trie(
|
||||
Some(min_blocks_to_keep) => sp_state_machine::oldest_non_pruned_changes_trie(
|
||||
config,
|
||||
min_blocks_to_keep.into(),
|
||||
best_finalized_block,
|
||||
@@ -733,7 +733,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> state_machine::ChangesTrieRootsStorage<Blake2Hasher, NumberFor<Block>>
|
||||
impl<Block> sp_state_machine::ChangesTrieRootsStorage<Blake2Hasher, NumberFor<Block>>
|
||||
for DbChangesTrieStorage<Block>
|
||||
where
|
||||
Block: BlockT<Hash=H256>,
|
||||
@@ -741,11 +741,11 @@ where
|
||||
fn build_anchor(
|
||||
&self,
|
||||
hash: H256,
|
||||
) -> Result<state_machine::ChangesTrieAnchorBlockId<H256, NumberFor<Block>>, String> {
|
||||
) -> Result<sp_state_machine::ChangesTrieAnchorBlockId<H256, NumberFor<Block>>, String> {
|
||||
utils::read_header::<Block>(&*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Hash(hash))
|
||||
.map_err(|e| e.to_string())
|
||||
.and_then(|maybe_header| maybe_header.map(|header|
|
||||
state_machine::ChangesTrieAnchorBlockId {
|
||||
sp_state_machine::ChangesTrieAnchorBlockId {
|
||||
hash,
|
||||
number: *header.number(),
|
||||
}
|
||||
@@ -754,7 +754,7 @@ where
|
||||
|
||||
fn root(
|
||||
&self,
|
||||
anchor: &state_machine::ChangesTrieAnchorBlockId<H256, NumberFor<Block>>,
|
||||
anchor: &sp_state_machine::ChangesTrieAnchorBlockId<H256, NumberFor<Block>>,
|
||||
block: NumberFor<Block>,
|
||||
) -> Result<Option<H256>, String> {
|
||||
// check API requirement: we can't get NEXT block(s) based on anchor
|
||||
@@ -800,12 +800,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> state_machine::ChangesTrieStorage<Blake2Hasher, NumberFor<Block>>
|
||||
impl<Block> sp_state_machine::ChangesTrieStorage<Blake2Hasher, NumberFor<Block>>
|
||||
for DbChangesTrieStorage<Block>
|
||||
where
|
||||
Block: BlockT<Hash=H256>,
|
||||
{
|
||||
fn as_roots_storage(&self) -> &dyn state_machine::ChangesTrieRootsStorage<Blake2Hasher, NumberFor<Block>> {
|
||||
fn as_roots_storage(&self) -> &dyn sp_state_machine::ChangesTrieRootsStorage<Blake2Hasher, NumberFor<Block>> {
|
||||
self
|
||||
}
|
||||
|
||||
@@ -870,7 +870,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
let is_archive_pruning = config.pruning.is_archive();
|
||||
let blockchain = BlockchainDb::new(db.clone())?;
|
||||
let meta = blockchain.meta.clone();
|
||||
let map_e = |e: state_db::Error<io::Error>| ::sp_blockchain::Error::from(format!("State database error: {:?}", e));
|
||||
let map_e = |e: sc_state_db::Error<io::Error>| ::sp_blockchain::Error::from(format!("State database error: {:?}", e));
|
||||
let state_db: StateDb<_, _> = StateDb::new(config.pruning.clone(), &StateMetaDb(&*db)).map_err(map_e)?;
|
||||
let storage_db = StorageDb {
|
||||
db: db.clone(),
|
||||
@@ -904,8 +904,8 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
/// Returns in-memory blockchain that contains the same set of blocks that the self.
|
||||
#[cfg(feature = "test-helpers")]
|
||||
pub fn as_in_memory(&self) -> InMemoryBackend<Block, Blake2Hasher> {
|
||||
use client_api::backend::{Backend as ClientBackend, BlockImportOperation};
|
||||
use client::blockchain::Backend as BlockchainBackend;
|
||||
use sc_client_api::backend::{Backend as ClientBackend, BlockImportOperation};
|
||||
use sc_client::blockchain::Backend as BlockchainBackend;
|
||||
|
||||
let inmem = InMemoryBackend::<Block, Blake2Hasher>::new();
|
||||
|
||||
@@ -965,7 +965,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
match cached_changes_trie_config.clone() {
|
||||
Some(cached_changes_trie_config) => Ok(cached_changes_trie_config),
|
||||
None => {
|
||||
use client_api::backend::Backend;
|
||||
use sc_client_api::backend::Backend;
|
||||
let changes_trie_config = self
|
||||
.state_at(BlockId::Hash(block))?
|
||||
.storage(well_known_keys::CHANGES_TRIE_CONFIG)?
|
||||
@@ -1109,14 +1109,14 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
let hash = if new_canonical == number_u64 {
|
||||
hash
|
||||
} else {
|
||||
::client::blockchain::HeaderBackend::hash(&self.blockchain, new_canonical.saturated_into())?
|
||||
::sc_client::blockchain::HeaderBackend::hash(&self.blockchain, new_canonical.saturated_into())?
|
||||
.expect("existence of block with number `new_canonical` \
|
||||
implies existence of blocks with all numbers before it; qed")
|
||||
};
|
||||
|
||||
trace!(target: "db", "Canonicalize block #{} ({:?})", new_canonical, hash);
|
||||
let commit = self.storage.state_db.canonicalize_block(&hash)
|
||||
.map_err(|e: state_db::Error<io::Error>| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?;
|
||||
.map_err(|e: sc_state_db::Error<io::Error>| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?;
|
||||
apply_state_commit(transaction, commit);
|
||||
};
|
||||
|
||||
@@ -1190,7 +1190,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
}
|
||||
|
||||
let finalized = if operation.commit_state {
|
||||
let mut changeset: state_db::ChangeSet<Vec<u8>> = state_db::ChangeSet::default();
|
||||
let mut changeset: sc_state_db::ChangeSet<Vec<u8>> = sc_state_db::ChangeSet::default();
|
||||
for (key, (val, rc)) in operation.db_updates.drain() {
|
||||
if rc > 0 {
|
||||
changeset.inserted.push((key, val.to_vec()));
|
||||
@@ -1200,7 +1200,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
}
|
||||
let number_u64 = number.saturated_into::<u64>();
|
||||
let commit = self.storage.state_db.insert_block(&hash, number_u64, &pending_block.header.parent_hash(), changeset)
|
||||
.map_err(|e: state_db::Error<io::Error>| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?;
|
||||
.map_err(|e: sc_state_db::Error<io::Error>| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?;
|
||||
apply_state_commit(&mut transaction, commit);
|
||||
|
||||
// Check if need to finalize. Genesis is always finalized instantly.
|
||||
@@ -1253,7 +1253,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
};
|
||||
|
||||
let cache_update = if let Some(set_head) = operation.set_head {
|
||||
if let Some(header) = ::client::blockchain::HeaderBackend::header(&self.blockchain, set_head)? {
|
||||
if let Some(header) = ::sc_client::blockchain::HeaderBackend::header(&self.blockchain, set_head)? {
|
||||
let number = header.number();
|
||||
let hash = header.hash();
|
||||
|
||||
@@ -1336,7 +1336,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key);
|
||||
|
||||
let commit = self.storage.state_db.canonicalize_block(&f_hash)
|
||||
.map_err(|e: state_db::Error<io::Error>| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?;
|
||||
.map_err(|e: sc_state_db::Error<io::Error>| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?;
|
||||
apply_state_commit(transaction, commit);
|
||||
|
||||
let changes_trie_config = self.changes_trie_config(parent_hash)?;
|
||||
@@ -1355,7 +1355,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet<Vec<u8>>) {
|
||||
fn apply_state_commit(transaction: &mut DBTransaction, commit: sc_state_db::CommitSet<Vec<u8>>) {
|
||||
for (key, val) in commit.data.inserted.into_iter() {
|
||||
transaction.put(columns::STATE, &key[..], &val);
|
||||
}
|
||||
@@ -1370,7 +1370,7 @@ fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitS
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> client_api::backend::AuxStore for Backend<Block> where Block: BlockT<Hash=H256> {
|
||||
impl<Block> sc_client_api::backend::AuxStore for Backend<Block> where Block: BlockT<Hash=H256> {
|
||||
fn insert_aux<
|
||||
'a,
|
||||
'b: 'a,
|
||||
@@ -1394,7 +1394,7 @@ impl<Block> client_api::backend::AuxStore for Backend<Block> where Block: BlockT
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> client_api::backend::Backend<Block, Blake2Hasher> for Backend<Block> where Block: BlockT<Hash=H256> {
|
||||
impl<Block> sc_client_api::backend::Backend<Block, Blake2Hasher> for Backend<Block> where Block: BlockT<Hash=H256> {
|
||||
type BlockImportOperation = BlockImportOperation<Block, Blake2Hasher>;
|
||||
type Blockchain = BlockchainDb<Block>;
|
||||
type State = CachingState<Blake2Hasher, RefTrackingState<Block>, Block>;
|
||||
@@ -1530,7 +1530,7 @@ impl<Block> client_api::backend::Backend<Block, Blake2Hasher> for Backend<Block>
|
||||
}
|
||||
|
||||
fn state_at(&self, block: BlockId<Block>) -> ClientResult<Self::State> {
|
||||
use client::blockchain::HeaderBackend as BcHeaderBackend;
|
||||
use sc_client::blockchain::HeaderBackend as BcHeaderBackend;
|
||||
|
||||
// special case for genesis initialization
|
||||
match block {
|
||||
@@ -1568,7 +1568,7 @@ impl<Block> client_api::backend::Backend<Block, Blake2Hasher> for Backend<Block>
|
||||
if self.is_archive {
|
||||
match self.blockchain.header(BlockId::Hash(hash.clone())) {
|
||||
Ok(Some(header)) => {
|
||||
state_machine::Storage::get(self.storage.as_ref(), &header.state_root(), (&[], None)).unwrap_or(None).is_some()
|
||||
sp_state_machine::Storage::get(self.storage.as_ref(), &header.state_root(), (&[], None)).unwrap_or(None).is_some()
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
@@ -1590,7 +1590,7 @@ impl<Block> client_api::backend::Backend<Block, Blake2Hasher> for Backend<Block>
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block> client_api::backend::LocalBackend<Block, Blake2Hasher> for Backend<Block>
|
||||
impl<Block> sc_client_api::backend::LocalBackend<Block, Blake2Hasher> for Backend<Block>
|
||||
where Block: BlockT<Hash=H256> {}
|
||||
|
||||
/// TODO: remove me in #3201
|
||||
@@ -1604,15 +1604,13 @@ mod tests {
|
||||
use hash_db::{HashDB, EMPTY_PREFIX};
|
||||
use super::*;
|
||||
use crate::columns;
|
||||
use client_api::backend::{Backend as BTrait, BlockImportOperation as Op};
|
||||
use client::blockchain::Backend as BLBTrait;
|
||||
use sc_client_api::backend::{Backend as BTrait, BlockImportOperation as Op};
|
||||
use sc_client::blockchain::Backend as BLBTrait;
|
||||
use sp_runtime::testing::{Header, Block as RawBlock, ExtrinsicWrapper};
|
||||
use sp_runtime::traits::{Hash, BlakeTwo256};
|
||||
use state_machine::{TrieMut, TrieDBMut, ChangesTrieRootsStorage, ChangesTrieStorage};
|
||||
use sp_state_machine::{TrieMut, TrieDBMut, ChangesTrieRootsStorage, ChangesTrieStorage};
|
||||
use sp_blockchain::{lowest_common_ancestor, tree_route};
|
||||
|
||||
use test_client;
|
||||
|
||||
type Block = RawBlock<ExtrinsicWrapper<u64>>;
|
||||
|
||||
fn prepare_changes(changes: Vec<(Vec<u8>, Vec<u8>)>) -> (H256, MemoryDB<Blake2Hasher>) {
|
||||
@@ -1849,7 +1847,7 @@ mod tests {
|
||||
backend.commit_operation(op).unwrap();
|
||||
assert_eq!(backend.storage.db.get(
|
||||
columns::STATE,
|
||||
&trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
&sp_trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
).unwrap().unwrap(), &b"hello"[..]);
|
||||
hash
|
||||
};
|
||||
@@ -1886,7 +1884,7 @@ mod tests {
|
||||
backend.commit_operation(op).unwrap();
|
||||
assert_eq!(backend.storage.db.get(
|
||||
columns::STATE,
|
||||
&trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
&sp_trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
).unwrap().unwrap(), &b"hello"[..]);
|
||||
hash
|
||||
};
|
||||
@@ -1924,7 +1922,7 @@ mod tests {
|
||||
|
||||
assert!(backend.storage.db.get(
|
||||
columns::STATE,
|
||||
&trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
&sp_trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
).unwrap().is_some());
|
||||
hash
|
||||
};
|
||||
@@ -1958,7 +1956,7 @@ mod tests {
|
||||
backend.commit_operation(op).unwrap();
|
||||
assert!(backend.storage.db.get(
|
||||
columns::STATE,
|
||||
&trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
&sp_trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
).unwrap().is_none());
|
||||
}
|
||||
|
||||
@@ -1967,7 +1965,7 @@ mod tests {
|
||||
backend.finalize_block(BlockId::Number(3), None).unwrap();
|
||||
assert!(backend.storage.db.get(
|
||||
columns::STATE,
|
||||
&trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
&sp_trie::prefixed_key::<Blake2Hasher>(&key, EMPTY_PREFIX)
|
||||
).unwrap().is_none());
|
||||
}
|
||||
|
||||
@@ -1979,7 +1977,7 @@ mod tests {
|
||||
|
||||
let check_changes = |backend: &Backend<Block>, block: u64, changes: Vec<(Vec<u8>, Vec<u8>)>| {
|
||||
let (changes_root, mut changes_trie_update) = prepare_changes(changes);
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId {
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId {
|
||||
hash: backend.blockchain().header(BlockId::Number(block)).unwrap().unwrap().hash(),
|
||||
number: block
|
||||
};
|
||||
@@ -2033,21 +2031,21 @@ mod tests {
|
||||
|
||||
// branch1: when asking for finalized block hash
|
||||
let (changes1_root, _) = prepare_changes(changes1);
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 };
|
||||
assert_eq!(backend.changes_tries_storage.root(&anchor, 1), Ok(Some(changes1_root)));
|
||||
|
||||
// branch2: when asking for finalized block hash
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 };
|
||||
assert_eq!(backend.changes_tries_storage.root(&anchor, 1), Ok(Some(changes1_root)));
|
||||
|
||||
// branch1: when asking for non-finalized block hash (search by traversal)
|
||||
let (changes2_1_0_root, _) = prepare_changes(changes2_1_0);
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 };
|
||||
assert_eq!(backend.changes_tries_storage.root(&anchor, 3), Ok(Some(changes2_1_0_root)));
|
||||
|
||||
// branch2: when asking for non-finalized block hash (search using canonicalized hint)
|
||||
let (changes2_2_0_root, _) = prepare_changes(changes2_2_0);
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 };
|
||||
assert_eq!(backend.changes_tries_storage.root(&anchor, 3), Ok(Some(changes2_2_0_root)));
|
||||
|
||||
// finalize first block of branch2 (block2_2_0)
|
||||
@@ -2059,7 +2057,7 @@ mod tests {
|
||||
// branch1: when asking for finalized block of other branch
|
||||
// => result is incorrect (returned for the block of branch1), but this is expected,
|
||||
// because the other fork is abandoned (forked before finalized header)
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 };
|
||||
assert_eq!(backend.changes_tries_storage.root(&anchor, 3), Ok(Some(changes2_2_0_root)));
|
||||
}
|
||||
|
||||
@@ -2090,7 +2088,7 @@ mod tests {
|
||||
backend.changes_tries_storage.meta.write().finalized_number = 13;
|
||||
|
||||
// check that roots of all tries are in the columns::CHANGES_TRIE
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block13, number: 13 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block13, number: 13 };
|
||||
fn read_changes_trie_root(backend: &Backend<Block>, num: u64) -> H256 {
|
||||
backend.blockchain().header(BlockId::Number(num)).unwrap().unwrap().digest().logs().iter()
|
||||
.find(|i| i.as_changes_trie_root().is_some()).unwrap().as_changes_trie_root().unwrap().clone()
|
||||
@@ -2161,7 +2159,7 @@ mod tests {
|
||||
let block6 = insert_header(&backend, 6, block5, vec![(b"key_at_6".to_vec(), b"val_at_6".to_vec())], Default::default());
|
||||
|
||||
// check that roots of all tries are in the columns::CHANGES_TRIE
|
||||
let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block6, number: 6 };
|
||||
let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block6, number: 6 };
|
||||
fn read_changes_trie_root(backend: &Backend<Block>, num: u64) -> H256 {
|
||||
backend.blockchain().header(BlockId::Number(num)).unwrap().unwrap().digest().logs().iter()
|
||||
.find(|i| i.as_changes_trie_root().is_some()).unwrap().as_changes_trie_root().unwrap().clone()
|
||||
@@ -2348,20 +2346,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_leaves_with_complex_block_tree() {
|
||||
let backend: Arc<Backend<test_client::runtime::Block>> = Arc::new(Backend::new_test(20, 20));
|
||||
test_client::trait_tests::test_leaves_for_backend(backend);
|
||||
let backend: Arc<Backend<substrate_test_runtime_client::runtime::Block>> = Arc::new(Backend::new_test(20, 20));
|
||||
substrate_test_runtime_client::trait_tests::test_leaves_for_backend(backend);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_children_with_complex_block_tree() {
|
||||
let backend: Arc<Backend<test_client::runtime::Block>> = Arc::new(Backend::new_test(20, 20));
|
||||
test_client::trait_tests::test_children_for_backend(backend);
|
||||
let backend: Arc<Backend<substrate_test_runtime_client::runtime::Block>> = Arc::new(Backend::new_test(20, 20));
|
||||
substrate_test_runtime_client::trait_tests::test_children_for_backend(backend);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_blockchain_query_by_number_gets_canonical() {
|
||||
let backend: Arc<Backend<test_client::runtime::Block>> = Arc::new(Backend::new_test(20, 20));
|
||||
test_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend);
|
||||
let backend: Arc<Backend<substrate_test_runtime_client::runtime::Block>> = Arc::new(Backend::new_test(20, 20));
|
||||
substrate_test_runtime_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2390,7 +2388,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_aux() {
|
||||
let backend: Backend<test_client::runtime::Block> = Backend::new_test(0, 0);
|
||||
let backend: Backend<substrate_test_runtime_client::runtime::Block> = Backend::new_test(0, 0);
|
||||
assert!(backend.get_aux(b"test").unwrap().is_none());
|
||||
backend.insert_aux(&[(&b"test"[..], &b"hello"[..])], &[]).unwrap();
|
||||
assert_eq!(b"hello", &backend.get_aux(b"test").unwrap().unwrap()[..]);
|
||||
@@ -2400,7 +2398,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_finalize_block_with_justification() {
|
||||
use client::blockchain::{Backend as BlockChainBackend};
|
||||
use sc_client::blockchain::{Backend as BlockChainBackend};
|
||||
|
||||
let backend = Backend::<Block>::new_test(10, 10);
|
||||
|
||||
|
||||
@@ -22,20 +22,20 @@ use parking_lot::RwLock;
|
||||
|
||||
use kvdb::{KeyValueDB, DBTransaction};
|
||||
|
||||
use client_api::backend::{AuxStore, NewBlockState};
|
||||
use client::blockchain::{
|
||||
use sc_client_api::backend::{AuxStore, NewBlockState};
|
||||
use sc_client::blockchain::{
|
||||
BlockStatus, Cache as BlockchainCache,Info as BlockchainInfo,
|
||||
};
|
||||
use client::cht;
|
||||
use sc_client::cht;
|
||||
use sp_blockchain::{
|
||||
CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache,
|
||||
Error as ClientError, Result as ClientResult,
|
||||
HeaderBackend as BlockchainHeaderBackend,
|
||||
well_known_cache_keys,
|
||||
};
|
||||
use client::light::blockchain::Storage as LightBlockchainStorage;
|
||||
use sc_client::light::blockchain::Storage as LightBlockchainStorage;
|
||||
use codec::{Decode, Encode};
|
||||
use primitives::Blake2Hasher;
|
||||
use sp_core::Blake2Hasher;
|
||||
use sp_runtime::generic::{DigestItem, BlockId};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, One, NumberFor};
|
||||
use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType};
|
||||
@@ -559,14 +559,14 @@ fn cht_key<N: TryInto<u32>>(cht_type: u8, block: N) -> ClientResult<[u8; 5]> {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use client::cht;
|
||||
use sc_client::cht;
|
||||
use sp_runtime::generic::DigestItem;
|
||||
use sp_runtime::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper};
|
||||
use sp_blockchain::{lowest_common_ancestor, tree_route};
|
||||
use super::*;
|
||||
|
||||
type Block = RawBlock<ExtrinsicWrapper<u32>>;
|
||||
type AuthorityId = primitives::ed25519::Public;
|
||||
type AuthorityId = sp_core::ed25519::Public;
|
||||
|
||||
pub fn default_header(parent: &Hash, number: u64) -> Header {
|
||||
Header {
|
||||
|
||||
@@ -56,7 +56,7 @@ impl LocalStorage {
|
||||
}
|
||||
}
|
||||
|
||||
impl primitives::offchain::OffchainStorage for LocalStorage {
|
||||
impl sp_core::offchain::OffchainStorage for LocalStorage {
|
||||
fn set(&mut self, prefix: &[u8], key: &[u8], value: &[u8]) {
|
||||
let key: Vec<u8> = prefix.iter().chain(key).cloned().collect();
|
||||
let mut tx = self.db.transaction();
|
||||
@@ -117,7 +117,7 @@ impl primitives::offchain::OffchainStorage for LocalStorage {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::offchain::OffchainStorage;
|
||||
use sp_core::offchain::OffchainStorage;
|
||||
|
||||
#[test]
|
||||
fn should_compare_and_set_and_clear_the_locks_map() {
|
||||
|
||||
@@ -22,11 +22,11 @@ use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
|
||||
use linked_hash_map::{LinkedHashMap, Entry};
|
||||
use hash_db::Hasher;
|
||||
use sp_runtime::traits::{Block as BlockT, Header};
|
||||
use primitives::hexdisplay::HexDisplay;
|
||||
use primitives::storage::ChildInfo;
|
||||
use state_machine::{backend::Backend as StateBackend, TrieBackend};
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use sp_core::storage::ChildInfo;
|
||||
use sp_state_machine::{backend::Backend as StateBackend, TrieBackend};
|
||||
use log::trace;
|
||||
use client_api::backend::{StorageCollection, ChildStorageCollection};
|
||||
use sc_client_api::backend::{StorageCollection, ChildStorageCollection};
|
||||
use std::hash::Hash as StdHash;
|
||||
|
||||
const STATE_CACHE_BLOCKS: usize = 12;
|
||||
@@ -642,8 +642,8 @@ impl<H: Hasher, S: StateBackend<H>, B: BlockT> StateBackend<H> for CachingState<
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper};
|
||||
use state_machine::backend::InMemory;
|
||||
use primitives::Blake2Hasher;
|
||||
use sp_state_machine::backend::InMemory;
|
||||
use sp_core::Blake2Hasher;
|
||||
|
||||
type Block = RawBlock<ExtrinsicWrapper<u32>>;
|
||||
|
||||
@@ -890,8 +890,8 @@ mod qc {
|
||||
|
||||
use super::*;
|
||||
use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper};
|
||||
use state_machine::backend::InMemory;
|
||||
use primitives::Blake2Hasher;
|
||||
use sp_state_machine::backend::InMemory;
|
||||
use sp_core::Blake2Hasher;
|
||||
|
||||
type Block = RawBlock<ExtrinsicWrapper<u32>>;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use kvdb_rocksdb::{Database, DatabaseConfig};
|
||||
use log::debug;
|
||||
|
||||
use codec::Decode;
|
||||
use trie::DBValue;
|
||||
use sp_trie::DBValue;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{
|
||||
Block as BlockT, Header as HeaderT, Zero,
|
||||
|
||||
@@ -8,17 +8,17 @@ edition = "2018"
|
||||
derive_more = "0.99.2"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
trie = { package = "sp-trie", path = "../../primitives/trie" }
|
||||
serializer = { package = "sp-serializer", path = "../../primitives/serializer" }
|
||||
runtime_version = { package = "sp-version", path = "../../primitives/version" }
|
||||
panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-trie = { path = "../../primitives/trie" }
|
||||
sp-serializer = { path = "../../primitives/serializer" }
|
||||
sp-version = { path = "../../primitives/version" }
|
||||
sp-panic-handler = { path = "../../primitives/panic-handler" }
|
||||
wasmi = "0.6.2"
|
||||
parity-wasm = "0.41.0"
|
||||
lazy_static = "1.4.0"
|
||||
wasm-interface = { package = "sp-wasm-interface", path = "../../primitives/wasm-interface" }
|
||||
runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" }
|
||||
externalities = { package = "sp-externalities", path = "../../primitives/externalities" }
|
||||
sp-wasm-interface = { path = "../../primitives/wasm-interface" }
|
||||
sp-runtime-interface = { path = "../../primitives/runtime-interface" }
|
||||
sp-externalities = { path = "../../primitives/externalities" }
|
||||
parking_lot = "0.9.0"
|
||||
log = "0.4.8"
|
||||
libsecp256k1 = "0.3.2"
|
||||
@@ -36,10 +36,9 @@ wasmtime-runtime = { version = "0.8", optional = true }
|
||||
assert_matches = "1.3.0"
|
||||
wabt = "0.9.2"
|
||||
hex-literal = "0.2.1"
|
||||
runtime-test = { package = "sc-runtime-test", path = "runtime-test" }
|
||||
test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" }
|
||||
runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" }
|
||||
state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
|
||||
sc-runtime-test = { path = "runtime-test" }
|
||||
substrate-test-runtime = { path = "../../test-utils/runtime" }
|
||||
sp-state-machine = { path = "../../primitives/state-machine" }
|
||||
test-case = "0.3.3"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -8,13 +8,13 @@ build = "build.rs"
|
||||
[dependencies]
|
||||
sp-std = { path = "../../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../../primitives/io", default-features = false }
|
||||
sandbox = { package = "sp-sandbox", path = "../../../primitives/sandbox", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
|
||||
sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false }
|
||||
sp-sandbox = { path = "../../../primitives/sandbox", default-features = false }
|
||||
sp-core = { path = "../../../primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = ["sp-io/std", "sandbox/std", "sp-std/std"]
|
||||
std = ["sp-io/std", "sp-sandbox/std", "sp-std/std"]
|
||||
|
||||
@@ -16,9 +16,9 @@ use sp_io::{
|
||||
#[cfg(not(feature = "std"))]
|
||||
use sp_runtime::{print, traits::{BlakeTwo256, Hash}};
|
||||
#[cfg(not(feature = "std"))]
|
||||
use primitives::{ed25519, sr25519};
|
||||
use sp_core::{ed25519, sr25519};
|
||||
|
||||
primitives::wasm_export_functions! {
|
||||
sp_core::wasm_export_functions! {
|
||||
fn test_data_in(input: Vec<u8>) -> Vec<u8> {
|
||||
print("set_storage");
|
||||
storage::set(b"input", &input);
|
||||
@@ -112,8 +112,8 @@ primitives::wasm_export_functions! {
|
||||
execute_sandboxed(
|
||||
&code,
|
||||
&[
|
||||
sandbox::TypedValue::I32(0x12345678),
|
||||
sandbox::TypedValue::I64(0x1234567887654321),
|
||||
sp_sandbox::TypedValue::I32(0x12345678),
|
||||
sp_sandbox::TypedValue::I64(0x1234567887654321),
|
||||
],
|
||||
).is_ok()
|
||||
}
|
||||
@@ -122,10 +122,10 @@ primitives::wasm_export_functions! {
|
||||
let ok = match execute_sandboxed(
|
||||
&code,
|
||||
&[
|
||||
sandbox::TypedValue::I32(0x1336),
|
||||
sp_sandbox::TypedValue::I32(0x1336),
|
||||
]
|
||||
) {
|
||||
Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(0x1337))) => true,
|
||||
Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(0x1337))) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
@@ -133,19 +133,19 @@ primitives::wasm_export_functions! {
|
||||
}
|
||||
|
||||
fn test_sandbox_instantiate(code: Vec<u8>) -> u8 {
|
||||
let env_builder = sandbox::EnvironmentDefinitionBuilder::new();
|
||||
let code = match sandbox::Instance::new(&code, &env_builder, &mut ()) {
|
||||
let env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new();
|
||||
let code = match sp_sandbox::Instance::new(&code, &env_builder, &mut ()) {
|
||||
Ok(_) => 0,
|
||||
Err(sandbox::Error::Module) => 1,
|
||||
Err(sandbox::Error::Execution) => 2,
|
||||
Err(sandbox::Error::OutOfBounds) => 3,
|
||||
Err(sp_sandbox::Error::Module) => 1,
|
||||
Err(sp_sandbox::Error::Execution) => 2,
|
||||
Err(sp_sandbox::Error::OutOfBounds) => 3,
|
||||
};
|
||||
|
||||
code
|
||||
}
|
||||
|
||||
fn test_offchain_local_storage() -> bool {
|
||||
let kind = primitives::offchain::StorageKind::PERSISTENT;
|
||||
let kind = sp_core::offchain::StorageKind::PERSISTENT;
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None);
|
||||
sp_io::offchain::local_storage_set(kind, b"test", b"asd");
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"asd".to_vec()));
|
||||
@@ -161,7 +161,7 @@ primitives::wasm_export_functions! {
|
||||
}
|
||||
|
||||
fn test_offchain_local_storage_with_none() {
|
||||
let kind = primitives::offchain::StorageKind::PERSISTENT;
|
||||
let kind = sp_core::offchain::StorageKind::PERSISTENT;
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None);
|
||||
|
||||
let res = sp_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value");
|
||||
@@ -170,7 +170,7 @@ primitives::wasm_export_functions! {
|
||||
}
|
||||
|
||||
fn test_offchain_http() -> bool {
|
||||
use primitives::offchain::HttpRequestStatus;
|
||||
use sp_core::offchain::HttpRequestStatus;
|
||||
let run = || -> Option<()> {
|
||||
let id = sp_io::offchain::http_request_start(
|
||||
"POST",
|
||||
@@ -201,45 +201,45 @@ primitives::wasm_export_functions! {
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn execute_sandboxed(
|
||||
code: &[u8],
|
||||
args: &[sandbox::TypedValue],
|
||||
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
|
||||
args: &[sp_sandbox::TypedValue],
|
||||
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
|
||||
struct State {
|
||||
counter: u32,
|
||||
}
|
||||
|
||||
fn env_assert(
|
||||
_e: &mut State,
|
||||
args: &[sandbox::TypedValue],
|
||||
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
|
||||
args: &[sp_sandbox::TypedValue],
|
||||
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
|
||||
if args.len() != 1 {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
let condition = args[0].as_i32().ok_or_else(|| sandbox::HostError)?;
|
||||
let condition = args[0].as_i32().ok_or_else(|| sp_sandbox::HostError)?;
|
||||
if condition != 0 {
|
||||
Ok(sandbox::ReturnValue::Unit)
|
||||
Ok(sp_sandbox::ReturnValue::Unit)
|
||||
} else {
|
||||
Err(sandbox::HostError)
|
||||
Err(sp_sandbox::HostError)
|
||||
}
|
||||
}
|
||||
fn env_inc_counter(
|
||||
e: &mut State,
|
||||
args: &[sandbox::TypedValue],
|
||||
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
|
||||
args: &[sp_sandbox::TypedValue],
|
||||
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
|
||||
if args.len() != 1 {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
let inc_by = args[0].as_i32().ok_or_else(|| sandbox::HostError)?;
|
||||
let inc_by = args[0].as_i32().ok_or_else(|| sp_sandbox::HostError)?;
|
||||
e.counter += inc_by as u32;
|
||||
Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(e.counter as i32)))
|
||||
Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(e.counter as i32)))
|
||||
}
|
||||
|
||||
let mut state = State { counter: 0 };
|
||||
|
||||
let env_builder = {
|
||||
let mut env_builder = sandbox::EnvironmentDefinitionBuilder::new();
|
||||
let mut env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new();
|
||||
env_builder.add_host_func("env", "assert", env_assert);
|
||||
env_builder.add_host_func("env", "inc_counter", env_inc_counter);
|
||||
let memory = match sandbox::Memory::new(1, Some(16)) {
|
||||
let memory = match sp_sandbox::Memory::new(1, Some(16)) {
|
||||
Ok(m) => m,
|
||||
Err(_) => unreachable!("
|
||||
Memory::new() can return Err only if parameters are borked; \
|
||||
@@ -251,8 +251,8 @@ fn execute_sandboxed(
|
||||
env_builder
|
||||
};
|
||||
|
||||
let mut instance = sandbox::Instance::new(code, &env_builder, &mut state)?;
|
||||
let mut instance = sp_sandbox::Instance::new(code, &env_builder, &mut state)?;
|
||||
let result = instance.invoke("call", args, &mut state);
|
||||
|
||||
result.map_err(|_| sandbox::HostError)
|
||||
result.map_err(|_| sp_sandbox::HostError)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ use crate::error::{Error, Result};
|
||||
use log::trace;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::ops::Range;
|
||||
use wasm_interface::{Pointer, WordSize};
|
||||
use sp_wasm_interface::{Pointer, WordSize};
|
||||
|
||||
// The pointers need to be aligned to 8 bytes. This is because the
|
||||
// maximum value type handled by wasm32 is u64.
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
use codec::Encode;
|
||||
use std::{convert::TryFrom, str};
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, keccak_256, Blake2Hasher, Pair,
|
||||
crypto::KeyTypeId, offchain,
|
||||
};
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
use wasm_interface::{
|
||||
use sp_trie::{TrieConfiguration, trie_types::Layout};
|
||||
use sp_wasm_interface::{
|
||||
Pointer, WordSize, WritePrimitive, ReadPrimitive, FunctionContext, Result as WResult,
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Rust executor possible errors.
|
||||
|
||||
use serializer;
|
||||
use sp_serializer;
|
||||
use wasmi;
|
||||
#[cfg(feature = "wasmtime")]
|
||||
use wasmtime_jit::{ActionError, SetupError};
|
||||
@@ -28,7 +28,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
pub enum Error {
|
||||
/// Unserializable Data
|
||||
InvalidData(serializer::Error),
|
||||
InvalidData(sp_serializer::Error),
|
||||
/// Trap occured during execution
|
||||
Trap(wasmi::Trap),
|
||||
/// Wasmi loading/instantiating error
|
||||
|
||||
@@ -18,15 +18,15 @@ mod sandbox;
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use hex_literal::hex;
|
||||
use primitives::{
|
||||
use sp_core::{
|
||||
Blake2Hasher, blake2_128, blake2_256, ed25519, sr25519, map, Pair,
|
||||
offchain::{OffchainExt, testing},
|
||||
traits::Externalities,
|
||||
};
|
||||
use runtime_test::WASM_BINARY;
|
||||
use state_machine::TestExternalities as CoreTestExternalities;
|
||||
use sc_runtime_test::WASM_BINARY;
|
||||
use sp_state_machine::TestExternalities as CoreTestExternalities;
|
||||
use test_case::test_case;
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
use sp_trie::{TrieConfiguration, trie_types::Layout};
|
||||
|
||||
use crate::WasmExecutionMethod;
|
||||
|
||||
@@ -128,7 +128,7 @@ fn storage_should_work(wasm_method: WasmExecutionMethod) {
|
||||
assert_eq!(output, b"all ok!".to_vec().encode());
|
||||
}
|
||||
|
||||
let expected = TestExternalities::new(primitives::storage::Storage {
|
||||
let expected = TestExternalities::new(sp_core::storage::Storage {
|
||||
top: map![
|
||||
b"input".to_vec() => b"Hello world".to_vec(),
|
||||
b"foo".to_vec() => b"bar".to_vec(),
|
||||
@@ -165,7 +165,7 @@ fn clear_prefix_should_work(wasm_method: WasmExecutionMethod) {
|
||||
assert_eq!(output, b"all ok!".to_vec().encode());
|
||||
}
|
||||
|
||||
let expected = TestExternalities::new(primitives::storage::Storage {
|
||||
let expected = TestExternalities::new(sp_core::storage::Storage {
|
||||
top: map![
|
||||
b"aaa".to_vec() => b"1".to_vec(),
|
||||
b"aab".to_vec() => b"2".to_vec(),
|
||||
@@ -443,7 +443,7 @@ fn ordered_trie_root_should_work(wasm_method: WasmExecutionMethod) {
|
||||
#[test_case(WasmExecutionMethod::Interpreted)]
|
||||
#[cfg_attr(feature = "wasmtime", test_case(WasmExecutionMethod::Compiled))]
|
||||
fn offchain_local_storage_should_work(wasm_method: WasmExecutionMethod) {
|
||||
use primitives::offchain::OffchainStorage;
|
||||
use sp_core::offchain::OffchainStorage;
|
||||
|
||||
let mut ext = TestExternalities::default();
|
||||
let (offchain, state) = testing::TestOffchainExt::new();
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::{TestExternalities, call_in_wasm};
|
||||
use crate::WasmExecutionMethod;
|
||||
|
||||
use codec::Encode;
|
||||
use runtime_test::WASM_BINARY;
|
||||
use sc_runtime_test::WASM_BINARY;
|
||||
use test_case::test_case;
|
||||
use wabt;
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ mod integration_tests;
|
||||
pub mod error;
|
||||
pub use wasmi;
|
||||
pub use native_executor::{with_native_environment, NativeExecutor, NativeExecutionDispatch};
|
||||
pub use runtime_version::{RuntimeVersion, NativeVersion};
|
||||
pub use sp_version::{RuntimeVersion, NativeVersion};
|
||||
pub use codec::Codec;
|
||||
#[doc(hidden)]
|
||||
pub use primitives::traits::Externalities;
|
||||
pub use sp_core::traits::Externalities;
|
||||
#[doc(hidden)]
|
||||
pub use wasm_interface;
|
||||
pub use sp_wasm_interface;
|
||||
pub use wasm_runtime::WasmExecutionMethod;
|
||||
|
||||
/// Call the given `function` in the given wasm `code`.
|
||||
@@ -64,7 +64,7 @@ pub use wasm_runtime::WasmExecutionMethod;
|
||||
/// - `heap_pages`: The number of heap pages to allocate.
|
||||
///
|
||||
/// Returns the `Vec<u8>` that contains the return value of the function.
|
||||
pub fn call_in_wasm<E: Externalities, HF: wasm_interface::HostFunctions>(
|
||||
pub fn call_in_wasm<E: Externalities, HF: sp_wasm_interface::HostFunctions>(
|
||||
function: &str,
|
||||
call_data: &[u8],
|
||||
execution_method: WasmExecutionMethod,
|
||||
@@ -93,7 +93,7 @@ pub trait RuntimeInfo {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use runtime_test::WASM_BINARY;
|
||||
use sc_runtime_test::WASM_BINARY;
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -19,17 +19,17 @@ use crate::{
|
||||
wasm_runtime::{RuntimesCache, WasmExecutionMethod, WasmRuntime},
|
||||
};
|
||||
|
||||
use runtime_version::{NativeVersion, RuntimeVersion};
|
||||
use sp_version::{NativeVersion, RuntimeVersion};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
use primitives::{NativeOrEncoded, traits::{CodeExecutor, Externalities}};
|
||||
use sp_core::{NativeOrEncoded, traits::{CodeExecutor, Externalities}};
|
||||
|
||||
use log::trace;
|
||||
|
||||
use std::{result, cell::RefCell, panic::{UnwindSafe, AssertUnwindSafe}};
|
||||
|
||||
use wasm_interface::{HostFunctions, Function};
|
||||
use sp_wasm_interface::{HostFunctions, Function};
|
||||
|
||||
thread_local! {
|
||||
static RUNTIMES_CACHE: RefCell<RuntimesCache> = RefCell::new(RuntimesCache::new());
|
||||
@@ -43,7 +43,7 @@ pub(crate) fn safe_call<F, U>(f: F) -> Result<U>
|
||||
{
|
||||
// Substrate uses custom panic hook that terminates process on panic. Disable
|
||||
// termination for the native call.
|
||||
let _guard = panic_handler::AbortGuard::force_unwind();
|
||||
let _guard = sp_panic_handler::AbortGuard::force_unwind();
|
||||
std::panic::catch_unwind(f).map_err(|_| Error::Runtime)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ pub(crate) fn safe_call<F, U>(f: F) -> Result<U>
|
||||
pub fn with_native_environment<F, U>(ext: &mut dyn Externalities, f: F) -> Result<U>
|
||||
where F: UnwindSafe + FnOnce() -> U
|
||||
{
|
||||
externalities::set_and_run_with_externalities(ext, move || safe_call(f))
|
||||
sp_externalities::set_and_run_with_externalities(ext, move || safe_call(f))
|
||||
}
|
||||
|
||||
/// Delegate for dispatching a CodeExecutor call.
|
||||
@@ -267,8 +267,8 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
|
||||
/// ```
|
||||
/// sc_executor::native_executor_instance!(
|
||||
/// pub MyExecutor,
|
||||
/// test_runtime::api::dispatch,
|
||||
/// test_runtime::native_version,
|
||||
/// substrate_test_runtime::api::dispatch,
|
||||
/// substrate_test_runtime::native_version,
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
@@ -278,7 +278,7 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
|
||||
/// executor aware of the host functions for these interfaces.
|
||||
///
|
||||
/// ```
|
||||
/// # use runtime_interface::runtime_interface;
|
||||
/// # use sp_runtime_interface::runtime_interface;
|
||||
///
|
||||
/// #[runtime_interface]
|
||||
/// trait MyInterface {
|
||||
@@ -289,8 +289,8 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
|
||||
///
|
||||
/// sc_executor::native_executor_instance!(
|
||||
/// pub MyExecutor,
|
||||
/// test_runtime::api::dispatch,
|
||||
/// test_runtime::native_version,
|
||||
/// substrate_test_runtime::api::dispatch,
|
||||
/// substrate_test_runtime::native_version,
|
||||
/// my_interface::HostFunctions,
|
||||
/// );
|
||||
/// ```
|
||||
@@ -337,7 +337,7 @@ macro_rules! native_executor_instance {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use runtime_interface::runtime_interface;
|
||||
use sp_runtime_interface::runtime_interface;
|
||||
|
||||
#[runtime_interface]
|
||||
trait MyInterface {
|
||||
@@ -348,8 +348,8 @@ mod tests {
|
||||
|
||||
native_executor_instance!(
|
||||
pub MyExecutor,
|
||||
test_runtime::api::dispatch,
|
||||
test_runtime::native_version,
|
||||
substrate_test_runtime::api::dispatch,
|
||||
substrate_test_runtime::native_version,
|
||||
(my_interface::HostFunctions, my_interface::HostFunctions),
|
||||
);
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
use crate::error::{Result, Error};
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
use codec::{Decode, Encode};
|
||||
use primitives::sandbox as sandbox_primitives;
|
||||
use sp_core::sandbox as sandbox_primitives;
|
||||
use wasmi::{
|
||||
Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance,
|
||||
ModuleRef, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages,
|
||||
};
|
||||
use wasm_interface::{Pointer, WordSize};
|
||||
use sp_wasm_interface::{Pointer, WordSize};
|
||||
|
||||
/// Index of a function inside the supervisor.
|
||||
///
|
||||
|
||||
@@ -26,12 +26,12 @@ use log::{trace, warn};
|
||||
|
||||
use codec::Decode;
|
||||
|
||||
use primitives::{storage::well_known_keys, traits::Externalities};
|
||||
use sp_core::{storage::well_known_keys, traits::Externalities};
|
||||
|
||||
use runtime_version::RuntimeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use std::{collections::hash_map::{Entry, HashMap}, panic::AssertUnwindSafe};
|
||||
|
||||
use wasm_interface::Function;
|
||||
use sp_wasm_interface::Function;
|
||||
|
||||
/// The Substrate Wasm runtime.
|
||||
pub trait WasmRuntime {
|
||||
@@ -259,7 +259,7 @@ fn create_versioned_wasm_runtime<E: Externalities>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use wasm_interface::HostFunctions;
|
||||
use sp_wasm_interface::HostFunctions;
|
||||
|
||||
#[test]
|
||||
fn host_functions_are_equal() {
|
||||
|
||||
@@ -16,28 +16,28 @@
|
||||
|
||||
//! Utilities for defining the wasm host environment.
|
||||
|
||||
use wasm_interface::{Pointer, WordSize};
|
||||
use sp_wasm_interface::{Pointer, WordSize};
|
||||
|
||||
/// Converts arguments into respective WASM types.
|
||||
#[macro_export]
|
||||
macro_rules! convert_args {
|
||||
() => ([]);
|
||||
( $( $t:ty ),* ) => ( [ $( <$t as $crate::wasm_interface::IntoValue>::VALUE_TYPE, )* ] );
|
||||
( $( $t:ty ),* ) => ( [ $( <$t as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE, )* ] );
|
||||
}
|
||||
|
||||
/// Generates a WASM signature for given list of parameters.
|
||||
#[macro_export]
|
||||
macro_rules! gen_signature {
|
||||
( ( $( $params: ty ),* ) ) => (
|
||||
$crate::wasm_interface::Signature {
|
||||
$crate::sp_wasm_interface::Signature {
|
||||
args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]),
|
||||
return_value: None,
|
||||
}
|
||||
);
|
||||
( ( $( $params: ty ),* ) -> $returns:ty ) => (
|
||||
$crate::wasm_interface::Signature {
|
||||
$crate::sp_wasm_interface::Signature {
|
||||
args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]),
|
||||
return_value: Some(<$returns as $crate::wasm_interface::IntoValue>::VALUE_TYPE),
|
||||
return_value: Some(<$returns as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE),
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -63,18 +63,18 @@ macro_rules! gen_functions {
|
||||
struct $name;
|
||||
|
||||
#[allow(unused)]
|
||||
impl $crate::wasm_interface::Function for $name {
|
||||
impl $crate::sp_wasm_interface::Function for $name {
|
||||
fn name(&self) -> &str {
|
||||
stringify!($name)
|
||||
}
|
||||
fn signature(&self) -> $crate::wasm_interface::Signature {
|
||||
fn signature(&self) -> $crate::sp_wasm_interface::Signature {
|
||||
gen_signature!( ( $( $params ),* ) $( -> $returns )? )
|
||||
}
|
||||
fn execute(
|
||||
&self,
|
||||
context: &mut dyn $crate::wasm_interface::FunctionContext,
|
||||
args: &mut dyn Iterator<Item=$crate::wasm_interface::Value>,
|
||||
) -> ::std::result::Result<Option<$crate::wasm_interface::Value>, String> {
|
||||
context: &mut dyn $crate::sp_wasm_interface::FunctionContext,
|
||||
args: &mut dyn Iterator<Item=$crate::sp_wasm_interface::Value>,
|
||||
) -> ::std::result::Result<Option<$crate::sp_wasm_interface::Value>, String> {
|
||||
let mut $context = context;
|
||||
marshall! {
|
||||
args,
|
||||
@@ -83,7 +83,7 @@ macro_rules! gen_functions {
|
||||
}
|
||||
}
|
||||
|
||||
&$name as &dyn $crate::wasm_interface::Function
|
||||
&$name as &dyn $crate::sp_wasm_interface::Function
|
||||
},
|
||||
}
|
||||
$context,
|
||||
@@ -103,7 +103,7 @@ macro_rules! unmarshall_args {
|
||||
$(
|
||||
let $names : $params =
|
||||
$args_iter.next()
|
||||
.and_then(|val| <$params as $crate::wasm_interface::TryFromValue>::try_from_value(val))
|
||||
.and_then(|val| <$params as $crate::sp_wasm_interface::TryFromValue>::try_from_value(val))
|
||||
.expect(
|
||||
"`$args_iter` comes from an argument of Externals::execute_function;
|
||||
args to an external call always matches the signature of the external;
|
||||
@@ -140,7 +140,7 @@ macro_rules! marshall {
|
||||
unmarshall_args!($body, $args_iter, $( $names : $params ),*)
|
||||
});
|
||||
let r = body()?;
|
||||
return Ok(Some($crate::wasm_interface::IntoValue::into_value(r)))
|
||||
return Ok(Some($crate::sp_wasm_interface::IntoValue::into_value(r)))
|
||||
});
|
||||
( $args_iter:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({
|
||||
let body = $crate::wasm_utils::constrain_closure::<(), _>(|| {
|
||||
@@ -162,9 +162,9 @@ macro_rules! impl_wasm_host_interface {
|
||||
)*
|
||||
}
|
||||
) => (
|
||||
impl $crate::wasm_interface::HostFunctions for $interface_name {
|
||||
impl $crate::sp_wasm_interface::HostFunctions for $interface_name {
|
||||
#[allow(non_camel_case_types)]
|
||||
fn host_functions() -> Vec<&'static dyn $crate::wasm_interface::Function> {
|
||||
fn host_functions() -> Vec<&'static dyn $crate::sp_wasm_interface::Function> {
|
||||
gen_functions!(
|
||||
$context,
|
||||
$( $name( $( $names: $params ),* ) $( -> $returns )? { $( $body )* } )*
|
||||
|
||||
@@ -23,14 +23,14 @@ use wasmi::{
|
||||
};
|
||||
use crate::error::{Error, WasmError};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::{sandbox as sandbox_primitives, traits::Externalities};
|
||||
use sp_core::{sandbox as sandbox_primitives, traits::Externalities};
|
||||
use crate::sandbox;
|
||||
use crate::allocator;
|
||||
use crate::wasm_utils::interpret_runtime_api_result;
|
||||
use crate::wasm_runtime::WasmRuntime;
|
||||
use log::{error, trace};
|
||||
use parity_wasm::elements::{deserialize_buffer, DataSegment, Instruction, Module as RawModule};
|
||||
use wasm_interface::{
|
||||
use sp_wasm_interface::{
|
||||
FunctionContext, Pointer, WordSize, Sandbox, MemoryId, Result as WResult, Function,
|
||||
};
|
||||
|
||||
@@ -273,7 +273,7 @@ impl<'a> wasmi::ModuleImportResolver for Resolver<'a> {
|
||||
fn resolve_func(&self, name: &str, signature: &wasmi::Signature)
|
||||
-> std::result::Result<wasmi::FuncRef, wasmi::Error>
|
||||
{
|
||||
let signature = wasm_interface::Signature::from(signature);
|
||||
let signature = sp_wasm_interface::Signature::from(signature);
|
||||
for (function_index, function) in self.0.iter().enumerate() {
|
||||
if name == function.name() {
|
||||
if signature == function.signature() {
|
||||
@@ -364,7 +364,7 @@ fn call_in_wasm_module(
|
||||
let offset = fec.allocate_memory(data.len() as u32)?;
|
||||
fec.write_memory(offset, data)?;
|
||||
|
||||
let result = externalities::set_and_run_with_externalities(
|
||||
let result = sp_externalities::set_and_run_with_externalities(
|
||||
ext,
|
||||
|| module_instance.invoke_export(
|
||||
method,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user