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

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

View File

@ -1,3 +1,10 @@
[features]
default = []
runtime-benchmarks = ['node-template-runtime/runtime-benchmarks']
[[bin]]
name = 'node-template'
[package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
build = 'build.rs'
@ -8,52 +15,160 @@ license = 'Unlicense'
name = 'node-template'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0'
[[bin]]
name = 'node-template'
[package.metadata.docs.rs]
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]
jsonrpc-core = '15.1.0'
structopt = '0.3.8'
# Substrate dependencies
frame-benchmarking = {version = '3.1.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
frame-benchmarking-cli = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
pallet-transaction-payment-rpc = {version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
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'}
[dependencies.frame-benchmarking]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'
# local dependencies
node-template-runtime = {version = '3.0.0', path = '../runtime'}
[dependencies.frame-benchmarking-cli]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[features]
default = []
runtime-benchmarks = ['node-template-runtime/runtime-benchmarks']
[dependencies.node-template-runtime]
path = '../runtime'
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,
) -> GenesisConfig {
GenesisConfig {
frame_system: SystemConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
},
pallet_balances: BalancesConfig {
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
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(),
},
pallet_grandpa: GrandpaConfig {
grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
},
pallet_sudo: SudoConfig {
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
},

View File

@ -1,11 +1,9 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use std::sync::Arc;
use std::time::Duration;
use std::{sync::Arc, time::Duration};
use sc_client_api::{ExecutorProvider, RemoteBackend};
use node_template_runtime::{self, opaque::Block, RuntimeApi};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_inherents::InherentDataProviders;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
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_keystore::LocalKeystore;
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_consensus::SlotData;
// Our 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>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_aura::AuraBlockImport<
Block,
FullClient,
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
AuraPair
>,
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
Option<Telemetry>,
)
@ -45,7 +39,6 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
return Err(ServiceError::Other(
format!("Remote Keystores are not supported.")))
}
let inherent_data_providers = InherentDataProviders::new();
let telemetry = config.telemetry_endpoints.clone()
.filter(|x| !x.is_empty())
@ -75,7 +68,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
task_manager.spawn_handle(),
task_manager.spawn_essential_handle(),
client.clone(),
);
@ -86,19 +79,26 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
telemetry.as_ref().map(|x| x.handle()),
)?;
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
grandpa_block_import.clone(), client.clone(),
);
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(
ImportQueueParams {
block_import: aura_block_import.clone(),
block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.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(),
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
slot_duration: sc_consensus_aura::slot_duration(&*client)?,
registry: config.prometheus_registry(),
check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
@ -113,8 +113,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (aura_block_import, grandpa_link, telemetry),
other: (grandpa_block_import, grandpa_link, telemetry),
})
}
@ -135,7 +134,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
mut keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (block_import, grandpa_link, mut telemetry),
} = 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());
let (network, network_status_sinks, system_rpc_tx, network_starter) =
let (network, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
client: client.clone(),
@ -201,7 +199,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
on_demand: None,
remote_blockchain: None,
backend,
network_status_sinks,
system_rpc_tx,
config,
telemetry: telemetry.as_mut(),
@ -220,20 +217,35 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
let can_author_with =
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 {
slot_duration: sc_consensus_aura::slot_duration(&*client)?,
slot_duration,
client: client.clone(),
select_chain,
block_import,
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,
backoff_authoring_blocks,
keystore: keystore_container.sync_keystore(),
can_author_with,
sync_oracle: network.clone(),
justification_sync_link: network.clone(),
block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32),
max_block_proposal_slot_portion: None,
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),
observer_enabled: false,
keystore,
is_authority: role.is_authority(),
local_role: role,
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(
config.transaction_pool.clone(),
config.prometheus_registry(),
task_manager.spawn_handle(),
task_manager.spawn_essential_handle(),
client.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() as Arc<_>),
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
)?;
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
grandpa_block_import.clone(),
client.clone(),
);
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(
ImportQueueParams {
block_import: aura_block_import.clone(),
block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.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(),
can_author_with: sp_consensus::NeverCanAuthor,
slot_duration: sc_consensus_aura::slot_duration(&*client)?,
registry: config.prometheus_registry(),
check_for_equivocation: Default::default(),
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 {
config: &config,
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 {
remote_blockchain: Some(backend.remote_blockchain()),
transaction_pool,
@ -381,12 +419,10 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
keystore: keystore_container.sync_keystore(),
backend,
network,
network_status_sinks,
system_rpc_tx,
telemetry: telemetry.as_mut(),
})?;
network_starter.start_network();
Ok(task_manager)
}

View File

@ -1,3 +1,59 @@
[dev-dependencies.serde]
version = '1.0.119'
[dev-dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dev-dependencies.sp-io]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dev-dependencies.sp-runtime]
default-features = false
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'
[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.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'
[features]
default = ['std']
runtime-benchmarks = ['frame-benchmarking']
std = [
'codec/std',
'frame-support/std',
'frame-system/std',
'frame-benchmarking/std',
]
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.'
@ -8,32 +64,5 @@ 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']
[dependencies]
# external dependencies
codec = {default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0'}
# 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-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'}
[dev-dependencies]
serde = '1.0.119'
sp-core = {default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
sp-io = {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'}
[features]
default = ['std']
runtime-benchmarks = ['frame-benchmarking']
std = [
'codec/std',
'frame-support/std',
'frame-system/std',
'frame-benchmarking/std',
]
try-runtime = ['frame-support/try-runtime']

View File

@ -59,9 +59,6 @@ pub mod pallet {
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.
// These functions materialize as "extrinsics", which are often compared to transactions.
// 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]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
edition = '2018'
@ -6,85 +173,50 @@ license = 'Unlicense'
name = 'node-template-runtime'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[build-dependencies]
substrate-wasm-builder={version = '4.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
[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'}
[build-dependencies.substrate-wasm-builder]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '4.0.0'
[features]
default = ['std']
runtime-benchmarks = [
'frame-benchmarking',
'frame-support/runtime-benchmarks',
'frame-system-benchmarking',
'frame-system/runtime-benchmarks',
'hex-literal',
'pallet-balances/runtime-benchmarks',
'pallet-template/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'sp-runtime/runtime-benchmarks',
'frame-benchmarking',
'frame-support/runtime-benchmarks',
'frame-system-benchmarking',
'frame-system/runtime-benchmarks',
'hex-literal',
'pallet-balances/runtime-benchmarks',
'pallet-template/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'sp-runtime/runtime-benchmarks',
]
std = [
'codec/std',
'frame-executive/std',
'frame-support/std',
'frame-system-rpc-runtime-api/std',
'frame-system/std',
'pallet-aura/std',
'pallet-balances/std',
'pallet-grandpa/std',
'pallet-randomness-collective-flip/std',
'pallet-sudo/std',
'pallet-template/std',
'pallet-timestamp/std',
'pallet-transaction-payment-rpc-runtime-api/std',
'pallet-transaction-payment/std',
'sp-api/std',
'sp-block-builder/std',
'sp-consensus-aura/std',
'sp-core/std',
'sp-inherents/std',
'sp-offchain/std',
'sp-runtime/std',
'sp-session/std',
'sp-std/std',
'sp-transaction-pool/std',
'sp-version/std',
'codec/std',
'frame-executive/std',
'frame-support/std',
'frame-system-rpc-runtime-api/std',
'frame-system/std',
'pallet-aura/std',
'pallet-balances/std',
'pallet-grandpa/std',
'pallet-randomness-collective-flip/std',
'pallet-sudo/std',
'pallet-template/std',
'pallet-timestamp/std',
'pallet-transaction-payment-rpc-runtime-api/std',
'pallet-transaction-payment/std',
'sp-api/std',
'sp-block-builder/std',
'sp-consensus-aura/std',
'sp-core/std',
'sp-inherents/std',
'sp-offchain/std',
'sp-runtime/std',
'sp-session/std',
'sp-std/std',
'sp-transaction-pool/std',
'sp-version/std',
]

View File

@ -52,6 +52,10 @@ pub type Signature = MultiSignature;
/// to the public key of our transaction signing scheme.
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.
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:
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_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 = ();
}
impl pallet_randomness_collective_flip::Config for Runtime {}
impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
}
@ -239,6 +246,8 @@ parameter_types! {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
@ -278,7 +287,7 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic
{
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},
Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
@ -363,10 +372,6 @@ impl_runtime_apis! {
) -> sp_inherents::CheckInherentsResult {
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 {