The latest Substrate Node Template v3 compiled from Substrate (#160)
parent
8370ddd69c
commit
0a0a91d578
|
@ -1,22 +1,16 @@
|
|||
root = true
|
||||
[*.rs]
|
||||
indent_style=tab
|
||||
indent_size=tab
|
||||
tab_width=4
|
||||
|
||||
[*]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
tab_width=2
|
||||
end_of_line=lf
|
||||
charset=utf-8
|
||||
trim_trailing_whitespace=true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{rs,toml}]
|
||||
indent_style=tab
|
||||
indent_size=tab
|
||||
tab_width=4
|
||||
max_line_length=100
|
||||
insert_final_newline=true
|
||||
|
||||
[*.yml]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
tab_width=8
|
||||
end_of_line=lf
|
||||
|
||||
[*.sh]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
tab_width=8
|
||||
end_of_line=lf
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,8 @@
|
|||
[profile.release]
|
||||
panic = 'unwind'
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
'node',
|
||||
'pallets/*',
|
||||
'runtime',
|
||||
]
|
||||
[profile.release]
|
||||
panic = 'unwind'
|
||||
|
|
|
@ -22,11 +22,8 @@ substrate-build-script-utils = '3.0.0'
|
|||
jsonrpc-core = '15.1.0'
|
||||
structopt = '0.3.8'
|
||||
|
||||
# local dependencies
|
||||
node-template-runtime = { path = '../runtime', version = '3.0.0' }
|
||||
|
||||
# Substrate dependencies
|
||||
frame-benchmarking = '3.0.0'
|
||||
frame-benchmarking = '3.1.0'
|
||||
frame-benchmarking-cli = '3.0.0'
|
||||
pallet-transaction-payment-rpc = '3.0.0'
|
||||
sc-basic-authorship = '0.9.0'
|
||||
|
@ -40,6 +37,7 @@ 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'
|
||||
|
@ -53,6 +51,9 @@ sp-runtime = '3.0.0'
|
|||
sp-transaction-pool = '3.0.0'
|
||||
substrate-frame-rpc-system = '3.0.0'
|
||||
|
||||
# local dependencies
|
||||
node-template-runtime = { path = '../runtime', version = '3.0.0' }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
runtime-benchmarks = ['node-template-runtime/runtime-benchmarks']
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
|
|||
}
|
||||
|
||||
pub fn development_config() -> Result<ChainSpec, String> {
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?;
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
|
||||
|
||||
Ok(ChainSpec::from_genesis(
|
||||
// Name
|
||||
|
@ -78,7 +78,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
|
|||
}
|
||||
|
||||
pub fn local_testnet_config() -> Result<ChainSpec, String> {
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?;
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
|
||||
|
||||
Ok(ChainSpec::from_genesis(
|
||||
// Name
|
||||
|
|
|
@ -8,7 +8,7 @@ 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};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use sc_finality_grandpa::SharedVoterState;
|
||||
use sc_keystore::LocalKeystore;
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
return Err(ServiceError::Other(
|
||||
format!("Remote Keystores are not supported.")))
|
||||
}
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
let inherent_data_providers = InherentDataProviders::new();
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
@ -59,7 +59,9 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
);
|
||||
|
||||
let (grandpa_block_import, grandpa_link) = sc_finality_grandpa::block_import(
|
||||
client.clone(), &(client.clone() as Arc<_>), select_chain.clone(),
|
||||
client.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
select_chain.clone(),
|
||||
)?;
|
||||
|
||||
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
|
||||
|
@ -78,7 +80,13 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
)?;
|
||||
|
||||
Ok(sc_service::PartialComponents {
|
||||
client, backend, task_manager, import_queue, keystore_container, select_chain, transaction_pool,
|
||||
client,
|
||||
backend,
|
||||
task_manager,
|
||||
import_queue,
|
||||
keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (aura_block_import, grandpa_link),
|
||||
})
|
||||
|
@ -94,7 +102,13 @@ fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
|
|||
/// Builds a new service for a full client.
|
||||
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
client, backend, mut task_manager, import_queue, mut keystore_container, select_chain, transaction_pool,
|
||||
client,
|
||||
backend,
|
||||
mut task_manager,
|
||||
import_queue,
|
||||
mut keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (block_import, grandpa_link),
|
||||
} = new_partial(&config)?;
|
||||
|
@ -168,7 +182,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
)?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
|
@ -178,12 +192,12 @@ 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 aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _,_>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
client.clone(),
|
||||
select_chain,
|
||||
block_import,
|
||||
proposer,
|
||||
proposer_factory,
|
||||
network.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
force_authoring,
|
||||
|
@ -226,10 +240,10 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network,
|
||||
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
|
||||
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()),
|
||||
};
|
||||
|
||||
// the GRANDPA voter task is considered infallible, i.e.
|
||||
|
|
|
@ -5,22 +5,18 @@ 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']
|
||||
|
||||
# alias "parity-scale-code" to "codec"
|
||||
[dependencies.codec]
|
||||
default-features = false
|
||||
features = ['derive']
|
||||
package = 'parity-scale-codec'
|
||||
version = '2.0.0'
|
||||
|
||||
[dependencies]
|
||||
frame-support = { default-features = false, version = '3.0.0' }
|
||||
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' }
|
||||
|
||||
[dev-dependencies]
|
||||
serde = { version = "1.0.119" }
|
||||
|
@ -31,7 +27,12 @@ sp-runtime = { default-features = false, version = '3.0.0' }
|
|||
[features]
|
||||
default = ['std']
|
||||
std = [
|
||||
'codec/std',
|
||||
'frame-support/std',
|
||||
'frame-system/std',
|
||||
'codec/std',
|
||||
'frame-support/std',
|
||||
'frame-system/std',
|
||||
'frame-benchmarking/std',
|
||||
]
|
||||
runtime-benchmarks = ['frame-benchmarking']
|
||||
# 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']
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
License: Unlicense
|
|
@ -0,0 +1,24 @@
|
|||
//! Benchmarking setup for pallet-template
|
||||
|
||||
use super::*;
|
||||
|
||||
use frame_system::RawOrigin;
|
||||
use frame_benchmarking::{benchmarks, whitelisted_caller, impl_benchmark_test_suite};
|
||||
#[allow(unused)]
|
||||
use crate::Module as Template;
|
||||
|
||||
benchmarks! {
|
||||
do_something {
|
||||
let s in 0 .. 100;
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller), s)
|
||||
verify {
|
||||
assert_eq!(Something::<T>::get(), Some(s));
|
||||
}
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
Template,
|
||||
crate::mock::new_test_ext(),
|
||||
crate::mock::Test,
|
||||
);
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
/// Edit this file to define custom logic or remove it if it is not needed.
|
||||
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
|
||||
/// https://substrate.dev/docs/en/knowledgebase/runtime/frame
|
||||
/// <https://substrate.dev/docs/en/knowledgebase/runtime/frame>
|
||||
|
||||
use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch, traits::Get};
|
||||
use frame_system::ensure_signed;
|
||||
pub use pallet::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
|
@ -13,89 +12,94 @@ mod mock;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||
pub trait Config: frame_system::Config {
|
||||
/// Because this pallet emits events, it depends on the runtime's definition of an event.
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
|
||||
// The pallet's runtime storage items.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage
|
||||
decl_storage! {
|
||||
// A unique name is used to ensure that the pallet's storage items are isolated.
|
||||
// This name may be updated, but each pallet in the runtime must use a unique name.
|
||||
// ---------------------------------vvvvvvvvvvvvvv
|
||||
trait Store for Module<T: Config> as TemplateModule {
|
||||
// Learn more about declaring storage items:
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items
|
||||
Something get(fn something): Option<u32>;
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*};
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
/// Because this pallet emits events, it depends on the runtime's definition of an event.
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
}
|
||||
|
||||
// Pallets use events to inform users when important changes are made.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/events
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
|
||||
#[pallet::pallet]
|
||||
#[pallet::generate_store(pub(super) trait Store)]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
// The pallet's runtime storage items.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn something)]
|
||||
// Learn more about declaring storage items:
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items
|
||||
pub type Something<T> = StorageValue<_, u32>;
|
||||
|
||||
// Pallets use events to inform users when important changes are made.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/events
|
||||
#[pallet::event]
|
||||
#[pallet::metadata(T::AccountId = "AccountId")]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// Event documentation should end with an array that provides descriptive names for event
|
||||
/// parameters. [something, who]
|
||||
SomethingStored(u32, AccountId),
|
||||
SomethingStored(u32, T::AccountId),
|
||||
}
|
||||
);
|
||||
|
||||
// Errors inform users that something went wrong.
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Config> {
|
||||
// Errors inform users that something went wrong.
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Error names should be descriptive.
|
||||
NoneValue,
|
||||
/// Errors should have helpful documentation associated with them.
|
||||
StorageOverflow,
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
decl_module! {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
// Errors must be initialized if they are used by the pallet.
|
||||
type Error = Error<T>;
|
||||
|
||||
// Events must be initialized if they are used by the pallet.
|
||||
fn deposit_event() = default;
|
||||
#[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.
|
||||
#[pallet::call]
|
||||
impl<T:Config> Pallet<T> {
|
||||
/// 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.
|
||||
#[weight = 10_000 + T::DbWeight::get().writes(1)]
|
||||
pub fn do_something(origin, something: u32) -> dispatch::DispatchResult {
|
||||
#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
|
||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResultWithPostInfo {
|
||||
// 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
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
// Update storage.
|
||||
Something::put(something);
|
||||
<Something<T>>::put(something);
|
||||
|
||||
// Emit an event.
|
||||
Self::deposit_event(RawEvent::SomethingStored(something, who));
|
||||
// Return a successful DispatchResult
|
||||
Ok(())
|
||||
Self::deposit_event(Event::SomethingStored(something, who));
|
||||
// Return a successful DispatchResultWithPostInfo
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
/// An example dispatchable that may throw a custom error.
|
||||
#[weight = 10_000 + T::DbWeight::get().reads_writes(1,1)]
|
||||
pub fn cause_error(origin) -> dispatch::DispatchResult {
|
||||
#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
|
||||
pub fn cause_error(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
let _who = ensure_signed(origin)?;
|
||||
|
||||
// Read a value from storage.
|
||||
match Something::get() {
|
||||
match <Something<T>>::get() {
|
||||
// Return an error if the value has not been set.
|
||||
None => Err(Error::<T>::NoneValue)?,
|
||||
Some(old) => {
|
||||
// Increment the value read from storage; will error in the event of overflow.
|
||||
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
|
||||
// Update the value in storage with the incremented result.
|
||||
Something::put(new);
|
||||
Ok(())
|
||||
<Something<T>>::put(new);
|
||||
Ok(().into())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,19 +13,10 @@ targets = ['x86_64-unknown-linux-gnu']
|
|||
[build-dependencies]
|
||||
substrate-wasm-builder = '4.0.0'
|
||||
|
||||
# alias "parity-scale-code" to "codec"
|
||||
[dependencies.codec]
|
||||
default-features = false
|
||||
features = ['derive']
|
||||
package = 'parity-scale-codec'
|
||||
version = '2.0.0'
|
||||
|
||||
[dependencies]
|
||||
codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0' }
|
||||
hex-literal = { optional = true, version = '0.3.1' }
|
||||
serde = { features = ['derive'], optional = true, version = '1.0.119' }
|
||||
|
||||
# local dependencies
|
||||
pallet-template = { path = '../pallets/template', default-features = false, version = '3.0.0' }
|
||||
serde = { version = "1.0.119", optional = true, features = ["derive"] }
|
||||
|
||||
# Substrate dependencies
|
||||
frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
|
||||
|
@ -54,25 +45,28 @@ 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' }
|
||||
|
||||
# local dependencies
|
||||
pallet-template = { default-features = false, path = '../pallets/template', version = '3.0.0' }
|
||||
|
||||
[features]
|
||||
default = ['std']
|
||||
runtime-benchmarks = [
|
||||
'hex-literal',
|
||||
'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',
|
||||
'serde',
|
||||
'frame-executive/std',
|
||||
'frame-support/std',
|
||||
'frame-system/std',
|
||||
'frame-system-rpc-runtime-api/std',
|
||||
'frame-system/std',
|
||||
'pallet-aura/std',
|
||||
'pallet-balances/std',
|
||||
'pallet-grandpa/std',
|
||||
|
@ -80,8 +74,9 @@ std = [
|
|||
'pallet-sudo/std',
|
||||
'pallet-template/std',
|
||||
'pallet-timestamp/std',
|
||||
'pallet-transaction-payment/std',
|
||||
'pallet-transaction-payment-rpc-runtime-api/std',
|
||||
'pallet-transaction-payment/std',
|
||||
'serde',
|
||||
'sp-api/std',
|
||||
'sp-block-builder/std',
|
||||
'sp-consensus-aura/std',
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use substrate_wasm_builder::WasmBuilder;
|
||||
|
||||
fn main() {
|
||||
WasmBuilder::new()
|
||||
.with_current_project()
|
||||
.import_memory()
|
||||
.export_heap_base()
|
||||
.build()
|
||||
WasmBuilder::new()
|
||||
.with_current_project()
|
||||
.export_heap_base()
|
||||
.import_memory()
|
||||
.build()
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use sp_runtime::{
|
|||
transaction_validity::{TransactionValidity, TransactionSource},
|
||||
};
|
||||
use sp_runtime::traits::{
|
||||
AccountIdLookup, BlakeTwo256, Block as BlockT, Verify, IdentifyAccount, NumberFor,
|
||||
BlakeTwo256, Block as BlockT, AccountIdLookup, Verify, IdentifyAccount, NumberFor,
|
||||
};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
|
@ -92,17 +92,23 @@ 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
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("node-template"),
|
||||
impl_name: create_runtime_str!("node-template"),
|
||||
authoring_version: 1,
|
||||
// The version of the runtime specification. A full node will not attempt to use its native
|
||||
// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
|
||||
// `spec_version`, and `authoring_version` are the same between Wasm and native.
|
||||
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
|
||||
// the compatible custom types.
|
||||
spec_version: 100,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
};
|
||||
|
||||
|
||||
/// This determines the average expected block time that we are targeting.
|
||||
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
|
||||
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
|
||||
|
@ -259,7 +265,7 @@ impl pallet_sudo::Config for Runtime {
|
|||
type Call = Call;
|
||||
}
|
||||
|
||||
/// Configure the template pallet in pallets/template.
|
||||
/// Configure the pallet-template in pallets/template.
|
||||
impl pallet_template::Config for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
@ -279,7 +285,7 @@ construct_runtime!(
|
|||
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>},
|
||||
// Include the custom logic from the template pallet in the runtime.
|
||||
// Include the custom logic from the pallet-template in the runtime.
|
||||
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
|
||||
}
|
||||
);
|
||||
|
@ -324,7 +330,7 @@ impl_runtime_apis! {
|
|||
}
|
||||
|
||||
fn execute_block(block: Block) {
|
||||
Executive::execute_block(block)
|
||||
Executive::execute_block(block);
|
||||
}
|
||||
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
|
@ -347,8 +353,7 @@ impl_runtime_apis! {
|
|||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: sp_inherents::InherentData) ->
|
||||
Vec<<Block as BlockT>::Extrinsic> {
|
||||
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
|
@ -433,8 +438,7 @@ impl_runtime_apis! {
|
|||
}
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
|
||||
for Runtime {
|
||||
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
|
||||
fn query_info(
|
||||
uxt: <Block as BlockT>::Extrinsic,
|
||||
len: u32,
|
||||
|
@ -456,25 +460,20 @@ 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![
|
||||
// Block Number
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
|
||||
.to_vec().into(),
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
|
||||
// Total Issuance
|
||||
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
|
||||
.to_vec().into(),
|
||||
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
|
||||
// Execution Phase
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
|
||||
.to_vec().into(),
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
|
||||
// Event Count
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
|
||||
.to_vec().into(),
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
|
||||
// System Events
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
|
||||
.to_vec().into(),
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
|
||||
];
|
||||
|
||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||
|
@ -483,6 +482,7 @@ impl_runtime_apis! {
|
|||
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
|
||||
add_benchmark!(params, batches, pallet_balances, Balances);
|
||||
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
|
||||
add_benchmark!(params, batches, pallet_template, TemplateModule);
|
||||
|
||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
||||
Ok(batches)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script meant to be run on Unix/Linux based systems
|
||||
set -e
|
||||
|
||||
echo "*** Start Substrate node template ***"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
# This script meant to be run on Unix/Linux based systems
|
||||
set -e
|
||||
|
||||
echo "*** Initializing WASM build environment"
|
||||
|
||||
if [ -z $CI_PROJECT_NAME ] ; then
|
||||
rustup update nightly
|
||||
rustup update stable
|
||||
fi
|
||||
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
Loading…
Reference in New Issue