Node template generated from Substrate repo `monthly-2021-05` tag (#186)

main
Jimmy Chu 2021-05-19 14:45:16 +08:00 committed by GitHub
parent 83ed2d45b9
commit 12d56a7621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1176 additions and 1004 deletions

1728
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,9 @@
[workspace]
members = [
'node',
'pallets/*',
'runtime',
]
[profile.release]
panic = 'unwind'
[workspace]
members = [
'node',
'pallets/*',
'runtime',
]

View File

@ -75,14 +75,6 @@ RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/node-template -lruntime=debug -
Once the node template is running locally, you can connect it with **Polkadot-JS Apps** front-end
to interact with your chain. [Click here](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944) connecting the Apps to your local node template.
Due to recent Substrate upgrade, paste the following custom types JSON in **Setting** > **Developer**
```json
{
"AccountInfo": "AccountInfoWithDualRefCount"
}
```
### Multi-Node Local Testnet
If you want to see the multi-node consensus algorithm in action, refer to

View File

@ -16,43 +16,43 @@ name = 'node-template'
targets = ['x86_64-unknown-linux-gnu']
[build-dependencies]
substrate-build-script-utils = '3.0.0'
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 = '3.1.0'
frame-benchmarking-cli = '3.0.0'
pallet-transaction-payment-rpc = '3.0.0'
sc-basic-authorship = '0.9.0'
sc-cli = { features = ['wasmtime'], version = '0.9.0' }
sc-client-api = '3.0.0'
sc-consensus = '0.9.0'
sc-consensus-aura = '0.9.0'
sc-executor = { features = ['wasmtime'], version = '0.9.0' }
sc-finality-grandpa = '0.9.0'
sc-keystore = '3.0.0'
sc-rpc = '3.0.0'
sc-rpc-api = '0.9.0'
sc-service = { features = ['wasmtime'], version = '0.9.0' }
sc-telemetry = '3.0.0'
sc-transaction-pool = '3.0.0'
sp-api = '3.0.0'
sp-block-builder = '3.0.0'
sp-blockchain = '3.0.0'
sp-consensus = '0.9.0'
sp-consensus-aura = '0.9.0'
sp-core = '3.0.0'
sp-finality-grandpa = '3.0.0'
sp-inherents = '3.0.0'
sp-runtime = '3.0.0'
sp-transaction-pool = '3.0.0'
substrate-frame-rpc-system = '3.0.0'
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'}
# local dependencies
node-template-runtime = { path = '../runtime', version = '3.0.0' }
node-template-runtime = {version = '3.0.0', path = '../runtime'}
[features]
default = []

View File

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

View File

@ -9,8 +9,10 @@ use sp_inherents::InherentDataProviders;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sc_consensus_aura::{ImportQueueParams, StartAuraParams, SlotProportion};
use sc_finality_grandpa::SharedVoterState;
use sc_keystore::LocalKeystore;
use sc_telemetry::{Telemetry, TelemetryWorker};
// Our native executor instance.
native_executor_instance!(
@ -36,6 +38,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
AuraPair
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
Option<Telemetry>,
)
>, ServiceError> {
if config.keystore_remote.is_some() {
@ -44,10 +47,28 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
}
let inherent_data_providers = InherentDataProviders::new();
let telemetry = config.telemetry_endpoints.clone()
.filter(|x| !x.is_empty())
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
let worker = TelemetryWorker::new(16)?;
let telemetry = worker.handle().new_telemetry(endpoints);
Ok((worker, telemetry))
})
.transpose()?;
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
&config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;
let client = Arc::new(client);
let telemetry = telemetry
.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
telemetry
});
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
@ -62,21 +83,26 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
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 import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import.clone(),
Some(Box::new(grandpa_block_import.clone())),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
config.prometheus_registry(),
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(
ImportQueueParams {
block_import: aura_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.clone())),
client: client.clone(),
inherent_data_providers: inherent_data_providers.clone(),
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()),
},
)?;
Ok(sc_service::PartialComponents {
@ -88,7 +114,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
select_chain,
transaction_pool,
inherent_data_providers,
other: (aura_block_import, grandpa_link),
other: (aura_block_import, grandpa_link, telemetry),
})
}
@ -110,7 +136,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
select_chain,
transaction_pool,
inherent_data_providers,
other: (block_import, grandpa_link),
other: (block_import, grandpa_link, mut telemetry),
} = new_partial(&config)?;
if let Some(url) = &config.keystore_remote {
@ -138,7 +164,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
if config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&config, backend.clone(), task_manager.spawn_handle(), client.clone(), network.clone(),
&config, task_manager.spawn_handle(), client.clone(), network.clone(),
);
}
@ -164,7 +190,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
})
};
let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(
let _rpc_handlers = sc_service::spawn_tasks(
sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
@ -178,6 +204,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
network_status_sinks,
system_rpc_tx,
config,
telemetry: telemetry.as_mut(),
},
)?;
@ -187,23 +214,28 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
client.clone(),
transaction_pool,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|x| x.handle()),
);
let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _,_>(
sc_consensus_aura::slot_duration(&*client)?,
client.clone(),
select_chain,
block_import,
proposer_factory,
network.clone(),
inherent_data_providers.clone(),
force_authoring,
backoff_authoring_blocks,
keystore_container.sync_keystore(),
can_author_with,
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _,_>(
StartAuraParams {
slot_duration: sc_consensus_aura::slot_duration(&*client)?,
client: client.clone(),
select_chain,
block_import,
proposer_factory,
inherent_data_providers: inherent_data_providers.clone(),
force_authoring,
backoff_authoring_blocks,
keystore: keystore_container.sync_keystore(),
can_author_with,
sync_oracle: network.clone(),
block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32),
telemetry: telemetry.as_ref().map(|x| x.handle()),
},
)?;
// the AURA authoring task is considered essential, i.e. if it
@ -226,7 +258,8 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
name: Some(name),
observer_enabled: false,
keystore,
is_authority: role.is_network_authority(),
is_authority: role.is_authority(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
};
if enable_grandpa {
@ -243,7 +276,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
shared_voter_state: SharedVoterState::empty(),
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
telemetry: telemetry.as_ref().map(|x| x.handle()),
};
// the GRANDPA voter task is considered infallible, i.e.
@ -260,8 +293,26 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
/// Builds a new service for a light client.
pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError> {
let telemetry = config.telemetry_endpoints.clone()
.filter(|x| !x.is_empty())
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
let worker = TelemetryWorker::new(16)?;
let telemetry = worker.handle().new_telemetry(endpoints);
Ok((worker, telemetry))
})
.transpose()?;
let (client, backend, keystore_container, mut task_manager, on_demand) =
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(
&config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;
let mut telemetry = telemetry
.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
telemetry
});
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
@ -279,6 +330,7 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
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(
@ -286,15 +338,19 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
client.clone(),
);
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import,
Some(Box::new(grandpa_block_import)),
client.clone(),
InherentDataProviders::new(),
&task_manager.spawn_handle(),
config.prometheus_registry(),
sp_consensus::NeverCanAuthor,
let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(
ImportQueueParams {
block_import: aura_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.clone())),
client: client.clone(),
inherent_data_providers: InherentDataProviders::new(),
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) =
@ -310,7 +366,7 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
if config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&config, backend.clone(), task_manager.spawn_handle(), client.clone(), network.clone(),
&config, task_manager.spawn_handle(), client.clone(), network.clone(),
);
}
@ -327,6 +383,7 @@ pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
network,
network_status_sinks,
system_rpc_tx,
telemetry: telemetry.as_mut(),
})?;
network_starter.start_network();

View File

@ -13,32 +13,27 @@ version = '3.0.0'
targets = ['x86_64-unknown-linux-gnu']
[dependencies]
codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0' }
frame-system = { default-features = false, version = '3.0.0' }
frame-support = { default-features = false, version = '3.0.0' }
frame-benchmarking = { default-features = false, optional = true, version = '3.1.0' }
sp-std = { default-features = false, version = '3.0.0' }
# 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 = { version = "1.0.119" }
sp-core = { default-features = false, version = '3.0.0' }
sp-io = { default-features = false, version = '3.0.0' }
sp-runtime = { default-features = false, version = '3.0.0' }
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',
'sp-std/std',
]
runtime-benchmarks = [
'frame-benchmarking',
'frame-support/runtime-benchmarks',
'frame-system/runtime-benchmarks',
]
# Note: frame-support `try-runtime` feature is released after v3.
# Uncomment the following line when `frame-support` version > `3.0.0`.
# try-runtime = ['frame-support/try-runtime']
try-runtime = ['frame-support/try-runtime']

View File

@ -4,10 +4,8 @@ use super::*;
use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks, whitelisted_caller, impl_benchmark_test_suite};
use sp_std::{vec, vec::Vec, boxed::Box};
#[allow(unused)]
use crate::Module as Template;
use crate::Pallet as Template;
benchmarks! {
do_something {

View File

@ -17,7 +17,7 @@ mod benchmarking;
#[frame_support::pallet]
pub mod pallet {
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*};
use frame_support::{dispatch::DispatchResult, pallet_prelude::*};
use frame_system::pallet_prelude::*;
/// Configure the pallet by specifying the parameters and types on which it depends.
@ -70,7 +70,7 @@ pub mod pallet {
/// An example dispatchable that takes a singles value as a parameter, writes the value to
/// storage and emits an event. This function must be dispatched by a signed extrinsic.
#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResultWithPostInfo {
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
// Check that the extrinsic was signed and get the signer.
// This function will return an error if the extrinsic is not signed.
// https://substrate.dev/docs/en/knowledgebase/runtime/origin
@ -82,12 +82,12 @@ pub mod pallet {
// Emit an event.
Self::deposit_event(Event::SomethingStored(something, who));
// Return a successful DispatchResultWithPostInfo
Ok(().into())
Ok(())
}
/// An example dispatchable that may throw a custom error.
#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
pub fn cause_error(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
let _who = ensure_signed(origin)?;
// Read a value from storage.
@ -99,7 +99,7 @@ pub mod pallet {
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
// Update the value in storage with the incremented result.
<Something<T>>::put(new);
Ok(().into())
Ok(())
},
}
}

View File

@ -16,8 +16,8 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
}
);
@ -49,6 +49,7 @@ impl system::Config for Test {
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
}
impl pallet_template::Config for Test {

View File

@ -11,81 +11,80 @@ version = '3.0.0'
targets = ['x86_64-unknown-linux-gnu']
[build-dependencies]
substrate-wasm-builder = '4.0.0'
substrate-wasm-builder={version = '4.0.0', git = 'https://github.com/paritytech/substrate.git', tag = 'monthly-2021-05'}
[dependencies]
codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0' }
hex-literal = { optional = true, version = '0.3.1' }
serde = { version = "1.0.119", optional = true, features = ["derive"] }
# 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.0.0' }
frame-executive = { default-features = false, version = '3.0.0' }
frame-support = { default-features = false, version = '3.0.0' }
frame-system = { default-features = false, version = '3.0.0' }
frame-system-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
frame-system-rpc-runtime-api = { default-features = false, version = '3.0.0' }
pallet-aura = { default-features = false, version = '3.0.0' }
pallet-balances = { default-features = false, version = '3.0.0' }
pallet-grandpa = { default-features = false, version = '3.0.0' }
pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }
pallet-sudo = { default-features = false, version = '3.0.0' }
pallet-timestamp = { default-features = false, version = '3.0.0' }
pallet-transaction-payment = { default-features = false, version = '3.0.0' }
pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '3.0.0' }
sp-api = { default-features = false, version = '3.0.0' }
sp-block-builder = { default-features = false, version = '3.0.0' }
sp-consensus-aura = { default-features = false, version = '0.9.0' }
sp-core = { default-features = false, version = '3.0.0' }
sp-inherents = { default-features = false, version = '3.0.0' }
sp-offchain = { default-features = false, version = '3.0.0' }
sp-runtime = { default-features = false, version = '3.0.0' }
sp-session = { default-features = false, version = '3.0.0' }
sp-std = { default-features = false, version = '3.0.0' }
sp-transaction-pool = { default-features = false, version = '3.0.0' }
sp-version = { default-features = false, version = '3.0.0' }
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, path = '../pallets/template', version = '3.0.0' }
pallet-template = {default-features = false, version = '3.0.0', path = '../pallets/template'}
[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',
'serde',
'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

@ -117,6 +117,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
/// Change this to adjust the block time.
pub const MILLISECS_PER_BLOCK: u64 = 6000;
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
// Attempting to do so will brick block production.
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
// Time is measured by number of blocks.
@ -195,6 +197,8 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
type SS58Prefix = SS58Prefix;
/// The set code logic, just the default since we're not a parachain.
type OnSetCode = ();
}
impl pallet_aura::Config for Runtime {
@ -277,16 +281,16 @@ construct_runtime!(
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Aura: pallet_aura::{Module, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
}
);
@ -320,7 +324,7 @@ pub type Executive = frame_executive::Executive<
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
AllPallets,
>;
impl_runtime_apis! {
@ -365,7 +369,7 @@ impl_runtime_apis! {
}
fn random_seed() -> <Block as BlockT>::Hash {
RandomnessCollectiveFlip::random_seed()
RandomnessCollectiveFlip::random_seed().0
}
}
@ -385,8 +389,8 @@ impl_runtime_apis! {
}
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> u64 {
Aura::slot_duration()
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
}
fn authorities() -> Vec<AuraId> {
@ -460,7 +464,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
use frame_system_benchmarking::Module as SystemBench;
use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {}
let whitelist: Vec<TrackedStorageKey> = vec![

View File

@ -1,3 +0,0 @@
{
"AccountInfo": "AccountInfoWithDualRefCount"
}

2
scripts/docker_run.sh 100755 → 100644
View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script meant to be run on Unix/Linux based systems
# This script is meant to be run on Unix/Linux based systems
set -e
echo "*** Start Substrate node template ***"

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script meant to be run on Unix/Linux based systems
# This script is meant to be run on Unix/Linux based systems
set -e
echo "*** Initializing WASM build environment"