Enhancement on Substrate Node Template (#8473)

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Jimmy Chu
2021-03-30 07:47:37 +08:00
committed by GitHub
parent a946c3343e
commit fb73a4eef6
15 changed files with 313 additions and 150 deletions
+11 -11
View File
@@ -1,11 +1,11 @@
[package]
name = "node-template-runtime"
version = "2.0.0"
authors = ["Anonymous"]
version = "3.0.0"
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
edition = "2018"
license = "Unlicense"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
@@ -45,7 +45,7 @@ frame-benchmarking = { version = "3.1.0", default-features = false, path = "../.
frame-system-benchmarking = { version = "3.0.0", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
hex-literal = { version = "0.3.1", optional = true }
template = { version = "2.0.0", default-features = false, path = "../pallets/template", package = "pallet-template" }
pallet-template = { version = "3.0.0", default-features = false, path = "../pallets/template" }
[build-dependencies]
substrate-wasm-builder = { version = "4.0.0", path = "../../../utils/wasm-builder" }
@@ -56,14 +56,17 @@ 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/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"serde",
"sp-api/std",
"sp-block-builder/std",
@@ -76,18 +79,15 @@ std = [
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"template/std",
]
runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking",
"hex-literal",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-balances/runtime-benchmarks",
"pallet-template/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"template/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
+15 -8
View File
@@ -40,7 +40,7 @@ pub use frame_support::{
use pallet_transaction_payment::CurrencyAdapter;
/// Import the template pallet.
pub use template;
pub use pallet_template;
/// An index to a block.
pub type BlockNumber = u32;
@@ -92,17 +92,24 @@ 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,
spec_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 targetting.
/// 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
/// up by `pallet_aura` to implement `fn slot_duration()`.
@@ -258,8 +265,8 @@ impl pallet_sudo::Config for Runtime {
type Call = Call;
}
/// Configure the pallet template in pallets/template.
impl template::Config for Runtime {
/// Configure the pallet-template in pallets/template.
impl pallet_template::Config for Runtime {
type Event = Event;
}
@@ -278,8 +285,8 @@ construct_runtime!(
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 template pallet in the runtime.
TemplateModule: template::{Pallet, Call, Storage, Event<T>},
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
}
);
@@ -475,7 +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, template, TemplateModule);
add_benchmark!(params, batches, pallet_template, TemplateModule);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)