[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:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
+28 -28
View File
@@ -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"
+1 -1
View File
@@ -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,
+24 -24
View File
@@ -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| {
+11 -11
View File
@@ -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,
}
}
+57 -57
View File
@@ -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| {
+14 -14
View File
@@ -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"
+8 -8
View File
@@ -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(
+79 -78
View File
@@ -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])),
},
]
);
+2 -2
View File
@@ -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",
]
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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" }
+4 -4
View File
@@ -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,
{
+73 -73
View File
@@ -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",
]
+4 -4
View File
@@ -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, \
+134 -133
View File
@@ -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) +
+15 -15
View File
@@ -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"
+7 -7
View File
@@ -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,
> {
+20 -20
View File
@@ -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()),
}
}
+8 -8
View File
@@ -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>,