Use latest node-template from Substrate master (#205)

Co-authored-by: Jimmy Chu <jimmychu0807@gmail.com>
main
Shawn Tabrizi 2021-06-22 07:00:32 +01:00 committed by GitHub
parent 56da2b636c
commit f471fdd6e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1027 additions and 633 deletions

954
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,6 @@ panic = 'unwind'
[workspace] [workspace]
members = [ members = [
'node', 'node',
'pallets/*', 'pallets/template',
'runtime', 'runtime',
] ]

View File

@ -1,3 +1,10 @@
[features]
default = []
runtime-benchmarks = ['node-template-runtime/runtime-benchmarks']
[[bin]]
name = 'node-template'
[package] [package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>'] authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
build = 'build.rs' build = 'build.rs'
@ -8,52 +15,160 @@ license = 'Unlicense'
name = 'node-template' name = 'node-template'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/' repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0' version = '3.0.0'
[[bin]]
name = 'node-template'
[package.metadata.docs.rs] [package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu'] targets = ['x86_64-unknown-linux-gnu']
[build-dependencies]
substrate-build-script-utils = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
[dependencies] [dependencies]
jsonrpc-core = '15.1.0' jsonrpc-core = '15.1.0'
structopt = '0.3.8' structopt = '0.3.8'
# Substrate dependencies [dependencies.frame-benchmarking]
frame-benchmarking = {version = '3.1.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} git = 'https://github.com/paritytech/substrate.git'
frame-benchmarking-cli = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
pallet-transaction-payment-rpc = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} version = '3.1.0'
sc-basic-authorship = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-cli = {features = ['wasmtime'], version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-client-api = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-consensus = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-consensus-aura = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-executor = {features = ['wasmtime'], version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-finality-grandpa = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-keystore = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-rpc = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-rpc-api = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-service = {features = ['wasmtime'], version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-telemetry = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sc-transaction-pool = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-api = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-block-builder = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-blockchain = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-consensus = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-consensus-aura = {version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-core = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-finality-grandpa = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-inherents = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-runtime = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-transaction-pool = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
substrate-frame-rpc-system = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
# local dependencies [dependencies.frame-benchmarking-cli]
node-template-runtime = {version = '3.0.0', path = '../runtime'} git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[features] [dependencies.node-template-runtime]
default = [] path = '../runtime'
runtime-benchmarks = ['node-template-runtime/runtime-benchmarks'] version = '3.0.0'
[dependencies.pallet-transaction-payment-rpc]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sc-basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-cli]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-client-api]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sc-consensus]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-executor]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-keystore]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sc-rpc]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sc-rpc-api]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-service]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sc-telemetry]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-api]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-block-builder]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-blockchain]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-timestamp]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.substrate-frame-rpc-system]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[build-dependencies.substrate-build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

View File

@ -134,22 +134,22 @@ fn testnet_genesis(
_enable_println: bool, _enable_println: bool,
) -> GenesisConfig { ) -> GenesisConfig {
GenesisConfig { GenesisConfig {
frame_system: SystemConfig { system: SystemConfig {
// Add Wasm runtime to storage. // Add Wasm runtime to storage.
code: wasm_binary.to_vec(), code: wasm_binary.to_vec(),
changes_trie_config: Default::default(), changes_trie_config: Default::default(),
}, },
pallet_balances: BalancesConfig { balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60. // Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(), balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
}, },
pallet_aura: AuraConfig { aura: AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}, },
pallet_grandpa: GrandpaConfig { grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
}, },
pallet_sudo: SudoConfig { sudo: SudoConfig {
// Assign network admin rights. // Assign network admin rights.
key: root_key, key: root_key,
}, },

View File

@ -1,11 +1,9 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. //! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use std::sync::Arc; use std::{sync::Arc, time::Duration};
use std::time::Duration;
use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_client_api::{ExecutorProvider, RemoteBackend};
use node_template_runtime::{self, opaque::Block, RuntimeApi}; use node_template_runtime::{self, opaque::Block, RuntimeApi};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_inherents::InherentDataProviders;
use sc_executor::native_executor_instance; use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor; pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
@ -13,6 +11,7 @@ use sc_consensus_aura::{ImportQueueParams, StartAuraParams, SlotProportion};
use sc_finality_grandpa::SharedVoterState; use sc_finality_grandpa::SharedVoterState;
use sc_keystore::LocalKeystore; use sc_keystore::LocalKeystore;
use sc_telemetry::{Telemetry, TelemetryWorker}; use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_consensus::SlotData;
// Our native executor instance. // Our native executor instance.
native_executor_instance!( native_executor_instance!(
@ -31,12 +30,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
sp_consensus::DefaultImportQueue<Block, FullClient>, sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>, sc_transaction_pool::FullPool<Block, FullClient>,
( (
sc_consensus_aura::AuraBlockImport<
Block,
FullClient,
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>, sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
AuraPair
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>, sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
Option<Telemetry>, Option<Telemetry>,
) )
@ -45,7 +39,6 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
return Err(ServiceError::Other( return Err(ServiceError::Other(
format!("Remote Keystores are not supported."))) format!("Remote Keystores are not supported.")))
} }
let inherent_data_providers = InherentDataProviders::new();
let telemetry = config.telemetry_endpoints.clone() let telemetry = config.telemetry_endpoints.clone()
.filter(|x| !x.is_empty()) .filter(|x| !x.is_empty())
@ -75,7 +68,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
config.transaction_pool.clone(), config.transaction_pool.clone(),
config.role.is_authority().into(), config.role.is_authority().into(),
config.prometheus_registry(), config.prometheus_registry(),
task_manager.spawn_handle(), task_manager.spawn_essential_handle(),
client.clone(), client.clone(),
); );
@ -86,19 +79,26 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
telemetry.as_ref().map(|x| x.handle()), telemetry.as_ref().map(|x| x.handle()),
)?; )?;
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
grandpa_block_import.clone(), client.clone(),
);
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>( let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(
ImportQueueParams { ImportQueueParams {
block_import: aura_block_import.clone(), block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.clone())), justification_import: Some(Box::new(grandpa_block_import.clone())),
client: client.clone(), client: client.clone(),
inherent_data_providers: inherent_data_providers.clone(), create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
slot_duration,
);
Ok((timestamp, slot))
},
spawner: &task_manager.spawn_essential_handle(), spawner: &task_manager.spawn_essential_handle(),
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
slot_duration: sc_consensus_aura::slot_duration(&*client)?,
registry: config.prometheus_registry(), registry: config.prometheus_registry(),
check_for_equivocation: Default::default(), check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()), telemetry: telemetry.as_ref().map(|x| x.handle()),
@ -113,8 +113,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
keystore_container, keystore_container,
select_chain, select_chain,
transaction_pool, transaction_pool,
inherent_data_providers, other: (grandpa_block_import, grandpa_link, telemetry),
other: (aura_block_import, grandpa_link, telemetry),
}) })
} }
@ -135,7 +134,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
mut keystore_container, mut keystore_container,
select_chain, select_chain,
transaction_pool, transaction_pool,
inherent_data_providers,
other: (block_import, grandpa_link, mut telemetry), other: (block_import, grandpa_link, mut telemetry),
} = new_partial(&config)?; } = new_partial(&config)?;
@ -151,7 +149,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config()); config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
let (network, network_status_sinks, system_rpc_tx, network_starter) = let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams { sc_service::build_network(sc_service::BuildNetworkParams {
config: &config, config: &config,
client: client.clone(), client: client.clone(),
@ -201,7 +199,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
on_demand: None, on_demand: None,
remote_blockchain: None, remote_blockchain: None,
backend, backend,
network_status_sinks,
system_rpc_tx, system_rpc_tx,
config, config,
telemetry: telemetry.as_mut(), telemetry: telemetry.as_mut(),
@ -220,20 +217,35 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
let can_author_with = let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _,_>( let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let raw_slot_duration = slot_duration.slot_duration();
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>(
StartAuraParams { StartAuraParams {
slot_duration: sc_consensus_aura::slot_duration(&*client)?, slot_duration,
client: client.clone(), client: client.clone(),
select_chain, select_chain,
block_import, block_import,
proposer_factory, proposer_factory,
inherent_data_providers: inherent_data_providers.clone(), create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
raw_slot_duration,
);
Ok((timestamp, slot))
},
force_authoring, force_authoring,
backoff_authoring_blocks, backoff_authoring_blocks,
keystore: keystore_container.sync_keystore(), keystore: keystore_container.sync_keystore(),
can_author_with, can_author_with,
sync_oracle: network.clone(), sync_oracle: network.clone(),
justification_sync_link: network.clone(),
block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32),
max_block_proposal_slot_portion: None,
telemetry: telemetry.as_ref().map(|x| x.handle()), telemetry: telemetry.as_ref().map(|x| x.handle()),
}, },
)?; )?;
@ -258,7 +270,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
name: Some(name), name: Some(name),
observer_enabled: false, observer_enabled: false,
keystore, keystore,
is_authority: role.is_authority(), local_role: role,
telemetry: telemetry.as_ref().map(|x| x.handle()), telemetry: telemetry.as_ref().map(|x| x.handle()),
}; };
@ -321,39 +333,45 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light( let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(), config.transaction_pool.clone(),
config.prometheus_registry(), config.prometheus_registry(),
task_manager.spawn_handle(), task_manager.spawn_essential_handle(),
client.clone(), client.clone(),
on_demand.clone(), on_demand.clone(),
)); ));
let (grandpa_block_import, _) = sc_finality_grandpa::block_import( let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
client.clone(), client.clone(),
&(client.clone() as Arc<_>), &(client.clone() as Arc<_>),
select_chain.clone(), select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()), telemetry.as_ref().map(|x| x.handle()),
)?; )?;
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
grandpa_block_import.clone(),
client.clone(),
);
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>( let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(
ImportQueueParams { ImportQueueParams {
block_import: aura_block_import.clone(), block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.clone())), justification_import: Some(Box::new(grandpa_block_import.clone())),
client: client.clone(), client: client.clone(),
inherent_data_providers: InherentDataProviders::new(), create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
slot_duration,
);
Ok((timestamp, slot))
},
spawner: &task_manager.spawn_essential_handle(), spawner: &task_manager.spawn_essential_handle(),
can_author_with: sp_consensus::NeverCanAuthor, can_author_with: sp_consensus::NeverCanAuthor,
slot_duration: sc_consensus_aura::slot_duration(&*client)?,
registry: config.prometheus_registry(), registry: config.prometheus_registry(),
check_for_equivocation: Default::default(), check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()), telemetry: telemetry.as_ref().map(|x| x.handle()),
}, },
)?; )?;
let (network, network_status_sinks, system_rpc_tx, network_starter) = let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams { sc_service::build_network(sc_service::BuildNetworkParams {
config: &config, config: &config,
client: client.clone(), client: client.clone(),
@ -370,6 +388,26 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
); );
} }
let enable_grandpa = !config.disable_grandpa;
if enable_grandpa {
let name = config.network.node_name.clone();
let config = sc_finality_grandpa::Config {
gossip_duration: std::time::Duration::from_millis(333),
justification_period: 512,
name: Some(name),
observer_enabled: false,
keystore: None,
local_role: config.role.clone(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
};
task_manager.spawn_handle().spawn_blocking(
"grandpa-observer",
sc_finality_grandpa::run_grandpa_observer(config, grandpa_link, network.clone())?,
);
}
sc_service::spawn_tasks(sc_service::SpawnTasksParams { sc_service::spawn_tasks(sc_service::SpawnTasksParams {
remote_blockchain: Some(backend.remote_blockchain()), remote_blockchain: Some(backend.remote_blockchain()),
transaction_pool, transaction_pool,
@ -381,12 +419,10 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
keystore: keystore_container.sync_keystore(), keystore: keystore_container.sync_keystore(),
backend, backend,
network, network,
network_status_sinks,
system_rpc_tx, system_rpc_tx,
telemetry: telemetry.as_mut(), telemetry: telemetry.as_mut(),
})?; })?;
network_starter.start_network(); network_starter.start_network();
Ok(task_manager) Ok(task_manager)
} }

View File

@ -1,31 +1,47 @@
[package] [dev-dependencies.serde]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>'] version = '1.0.119'
description = 'FRAME pallet template for defining custom runtime logic.'
edition = '2018' [dev-dependencies.sp-core]
homepage = 'https://substrate.dev' default-features = false
license = 'Unlicense' git = 'https://github.com/paritytech/substrate.git'
name = 'pallet-template' rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
readme = 'README.md'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0' version = '3.0.0'
[package.metadata.docs.rs] [dev-dependencies.sp-io]
targets = ['x86_64-unknown-linux-gnu'] default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies] [dev-dependencies.sp-runtime]
# external dependencies default-features = false
codec = {default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0'} git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.0.0'
# Substrate dependencies [dependencies.frame-benchmarking]
frame-benchmarking = {default-features = false, optional = true, version = '3.1.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} default-features = false
frame-support = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} git = 'https://github.com/paritytech/substrate.git'
frame-system = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'
[dev-dependencies] [dependencies.frame-support]
serde = '1.0.119' default-features = false
sp-core = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} git = 'https://github.com/paritytech/substrate.git'
sp-io = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
sp-runtime = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} version = '3.0.0'
[dependencies.frame-system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[features] [features]
default = ['std'] default = ['std']
@ -37,3 +53,16 @@ std = [
'frame-benchmarking/std', 'frame-benchmarking/std',
] ]
try-runtime = ['frame-support/try-runtime'] try-runtime = ['frame-support/try-runtime']
[package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
description = 'FRAME pallet template for defining custom runtime logic.'
edition = '2018'
homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'pallet-template'
readme = 'README.md'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

View File

@ -59,9 +59,6 @@ pub mod pallet {
StorageOverflow, StorageOverflow,
} }
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
// Dispatchable functions allows users to interact with the pallet and invoke state changes. // Dispatchable functions allows users to interact with the pallet and invoke state changes.
// These functions materialize as "extrinsics", which are often compared to transactions. // These functions materialize as "extrinsics", which are often compared to transactions.
// Dispatchable functions must be annotated with a weight and must return a DispatchResult. // Dispatchable functions must be annotated with a weight and must return a DispatchResult.

View File

@ -1,3 +1,170 @@
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.0.0'
[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'
[dependencies.frame-executive]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.frame-system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.frame-system-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.frame-system-rpc-runtime-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.hex-literal]
optional = true
version = '0.3.1'
[dependencies.pallet-aura]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.pallet-balances]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.pallet-grandpa]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'
[dependencies.pallet-randomness-collective-flip]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.pallet-sudo]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.pallet-template]
default-features = false
path = '../pallets/template'
version = '3.0.0'
[dependencies.pallet-timestamp]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.pallet-transaction-payment]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.pallet-transaction-payment-rpc-runtime-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-block-builder]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-consensus-aura]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'
[dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-inherents]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-offchain]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-session]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-std]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-transaction-pool]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.sp-version]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[package] [package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>'] authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
edition = '2018' edition = '2018'
@ -6,47 +173,12 @@ license = 'Unlicense'
name = 'node-template-runtime' name = 'node-template-runtime'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/' repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0' version = '3.0.0'
[package.metadata.docs.rs] [package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu'] targets = ['x86_64-unknown-linux-gnu']
[build-dependencies.substrate-wasm-builder]
[build-dependencies] git = 'https://github.com/paritytech/substrate.git'
substrate-wasm-builder={version = '4.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'} rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '4.0.0'
[dependencies]
# external dependencies
codec = {default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0'}
hex-literal= {optional = true, version = '0.3.1'}
# Substrate dependencies
frame-benchmarking = {default-features = false, optional = true, version = '3.1.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
frame-executive = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
frame-support = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
frame-system = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
frame-system-benchmarking = {default-features = false, optional = true, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
frame-system-rpc-runtime-api = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-aura = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-balances = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-grandpa = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-randomness-collective-flip = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-sudo = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-timestamp = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-transaction-payment = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-transaction-payment-rpc-runtime-api = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-api = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-block-builder = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-consensus-aura = {default-features = false, version = '0.9.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-core = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-inherents = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-offchain = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-runtime = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-session = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-std = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-transaction-pool = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-version = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
# local dependencies
pallet-template = {default-features = false, version = '3.0.0', path = '../pallets/template'}
[features] [features]
default = ['std'] default = ['std']

View File

@ -52,6 +52,10 @@ pub type Signature = MultiSignature;
/// to the public key of our transaction signing scheme. /// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId; pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
pub type AccountIndex = u32;
/// Balance of an account. /// Balance of an account.
pub type Balance = u128; pub type Balance = u128;
@ -90,6 +94,7 @@ pub mod opaque {
// To learn more about runtime versioning and what each of the following value means: // To learn more about runtime versioning and what each of the following value means:
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning // https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion { pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node-template"), spec_name: create_runtime_str!("node-template"),
impl_name: create_runtime_str!("node-template"), impl_name: create_runtime_str!("node-template"),
@ -197,6 +202,8 @@ impl frame_system::Config for Runtime {
type OnSetCode = (); type OnSetCode = ();
} }
impl pallet_randomness_collective_flip::Config for Runtime {}
impl pallet_aura::Config for Runtime { impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId; type AuthorityId = AuraId;
} }
@ -239,6 +246,8 @@ parameter_types! {
impl pallet_balances::Config for Runtime { impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks; type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
/// The type for recording an account's balance. /// The type for recording an account's balance.
type Balance = Balance; type Balance = Balance;
/// The ubiquitous event type. /// The ubiquitous event type.
@ -278,7 +287,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Pallet, Config<T>}, Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
@ -363,10 +372,6 @@ impl_runtime_apis! {
) -> sp_inherents::CheckInherentsResult { ) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block) data.check_extrinsics(&block)
} }
fn random_seed() -> <Block as BlockT>::Hash {
RandomnessCollectiveFlip::random_seed().0
}
} }
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {