new docs site + Do not provide benchmarking host functions by default (#255)
parent
28ea72b5c5
commit
8e5c1c4855
36
README.md
36
README.md
|
@ -1,14 +1,14 @@
|
||||||
# Substrate Node Template
|
# Substrate Node Template
|
||||||
|
|
||||||
[![Try on playground](https://img.shields.io/badge/Playground-Node_Template-brightgreen?logo=Parity%20Substrate)](https://playground.substrate.dev/?deploy=node-template) [![Matrix](https://img.shields.io/matrix/substrate-technical:matrix.org)](https://matrix.to/#/#substrate-technical:matrix.org)
|
[![Try on playground](https://img.shields.io/badge/Playground-Node_Template-brightgreen?logo=Parity%20Substrate)](https://docs.substrate.io/playground/) [![Matrix](https://img.shields.io/matrix/substrate-technical:matrix.org)](https://matrix.to/#/#substrate-technical:matrix.org)
|
||||||
|
|
||||||
A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacking :rocket:
|
A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacking :rocket:
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
Follow the steps below to get started with the Node Template, or get it up and running right from
|
Follow the steps below to get started with the Node Template, or get it up and running right from
|
||||||
your browser in just a few clicks using [Playground](https://playground.substrate.dev/)
|
your browser in just a few clicks using
|
||||||
:hammer_and_wrench:
|
the [Substrate Playground](https://docs.substrate.io/playground/) :hammer_and_wrench:
|
||||||
|
|
||||||
### Using Nix
|
### Using Nix
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ local node template.
|
||||||
### Multi-Node Local Testnet
|
### Multi-Node Local Testnet
|
||||||
|
|
||||||
If you want to see the multi-node consensus algorithm in action, refer to our
|
If you want to see the multi-node consensus algorithm in action, refer to our
|
||||||
[Start a Private Network tutorial](https://substrate.dev/docs/en/tutorials/start-a-private-network/).
|
[Start a Private Network tutorial](https://docs.substrate.io/tutorials/v3/private-network).
|
||||||
|
|
||||||
## Template Structure
|
## Template Structure
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ Substrate-based blockchain nodes expose a number of capabilities:
|
||||||
- Networking: Substrate nodes use the [`libp2p`](https://libp2p.io/) networking stack to allow the
|
- Networking: Substrate nodes use the [`libp2p`](https://libp2p.io/) networking stack to allow the
|
||||||
nodes in the network to communicate with one another.
|
nodes in the network to communicate with one another.
|
||||||
- Consensus: Blockchains must have a way to come to
|
- Consensus: Blockchains must have a way to come to
|
||||||
[consensus](https://substrate.dev/docs/en/knowledgebase/advanced/consensus) on the state of the
|
[consensus](https://docs.substrate.io/v3/advanced/consensus) on the state of the
|
||||||
network. Substrate makes it possible to supply custom consensus engines and also ships with
|
network. Substrate makes it possible to supply custom consensus engines and also ships with
|
||||||
several consensus mechanisms that have been built on top of
|
several consensus mechanisms that have been built on top of
|
||||||
[Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html).
|
[Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html).
|
||||||
|
@ -107,21 +107,21 @@ Substrate-based blockchain nodes expose a number of capabilities:
|
||||||
There are several files in the `node` directory - take special note of the following:
|
There are several files in the `node` directory - take special note of the following:
|
||||||
|
|
||||||
- [`chain_spec.rs`](./node/src/chain_spec.rs): A
|
- [`chain_spec.rs`](./node/src/chain_spec.rs): A
|
||||||
[chain specification](https://substrate.dev/docs/en/knowledgebase/integrate/chain-spec) is a
|
[chain specification](https://docs.substrate.io/v3/runtime/chain-specs) is a
|
||||||
source code file that defines a Substrate chain's initial (genesis) state. Chain specifications
|
source code file that defines a Substrate chain's initial (genesis) state. Chain specifications
|
||||||
are useful for development and testing, and critical when architecting the launch of a
|
are useful for development and testing, and critical when architecting the launch of a
|
||||||
production chain. Take note of the `development_config` and `testnet_genesis` functions, which
|
production chain. Take note of the `development_config` and `testnet_genesis` functions, which
|
||||||
are used to define the genesis state for the local development chain configuration. These
|
are used to define the genesis state for the local development chain configuration. These
|
||||||
functions identify some
|
functions identify some
|
||||||
[well-known accounts](https://substrate.dev/docs/en/knowledgebase/integrate/subkey#well-known-keys)
|
[well-known accounts](https://docs.substrate.io/v3/tools/subkey#well-known-keys)
|
||||||
and use them to configure the blockchain's initial state.
|
and use them to configure the blockchain's initial state.
|
||||||
- [`service.rs`](./node/src/service.rs): This file defines the node implementation. Take note of
|
- [`service.rs`](./node/src/service.rs): This file defines the node implementation. Take note of
|
||||||
the libraries that this file imports and the names of the functions it invokes. In particular,
|
the libraries that this file imports and the names of the functions it invokes. In particular,
|
||||||
there are references to consensus-related topics, such as the
|
there are references to consensus-related topics, such as the
|
||||||
[longest chain rule](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#longest-chain-rule),
|
[longest chain rule](https://docs.substrate.io/v3/advanced/consensus#longest-chain-rule),
|
||||||
the [Aura](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#aura) block authoring
|
the [Aura](https://docs.substrate.io/v3/advanced/consensus#aura) block authoring
|
||||||
mechanism and the
|
mechanism and the
|
||||||
[GRANDPA](https://substrate.dev/docs/en/knowledgebase/advanced/consensus#grandpa) finality
|
[GRANDPA](https://docs.substrate.io/v3/advanced/consensus#grandpa) finality
|
||||||
gadget.
|
gadget.
|
||||||
|
|
||||||
After the node has been [built](#build), refer to the embedded documentation to learn more about the
|
After the node has been [built](#build), refer to the embedded documentation to learn more about the
|
||||||
|
@ -134,14 +134,14 @@ capabilities and configuration parameters that it exposes:
|
||||||
### Runtime
|
### Runtime
|
||||||
|
|
||||||
In Substrate, the terms
|
In Substrate, the terms
|
||||||
"[runtime](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#runtime)" and
|
"[runtime](https://docs.substrate.io/v3/getting-started/glossary#runtime)" and
|
||||||
"[state transition function](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#stf-state-transition-function)"
|
"[state transition function](https://docs.substrate.io/v3/getting-started/glossary#state-transition-function-stf)"
|
||||||
are analogous - they refer to the core logic of the blockchain that is responsible for validating
|
are analogous - they refer to the core logic of the blockchain that is responsible for validating
|
||||||
blocks and executing the state changes they define. The Substrate project in this repository uses
|
blocks and executing the state changes they define. The Substrate project in this repository uses
|
||||||
the [FRAME](https://substrate.dev/docs/en/knowledgebase/runtime/frame) framework to construct a
|
the [FRAME](https://docs.substrate.io/v3/runtime/frame) framework to construct a
|
||||||
blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules
|
blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules
|
||||||
called "pallets". At the heart of FRAME is a helpful
|
called "pallets". At the heart of FRAME is a helpful
|
||||||
[macro language](https://substrate.dev/docs/en/knowledgebase/runtime/macros) that makes it easy to
|
[macro language](https://docs.substrate.io/v3/runtime/macros) that makes it easy to
|
||||||
create pallets and flexibly compose them to create blockchains that can address
|
create pallets and flexibly compose them to create blockchains that can address
|
||||||
[a variety of needs](https://www.substrate.io/substrate-users/).
|
[a variety of needs](https://www.substrate.io/substrate-users/).
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ the following:
|
||||||
- The pallets are composed into a single runtime by way of the
|
- The pallets are composed into a single runtime by way of the
|
||||||
[`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html)
|
[`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html)
|
||||||
macro, which is part of the core
|
macro, which is part of the core
|
||||||
[FRAME Support](https://substrate.dev/docs/en/knowledgebase/runtime/frame#support-library)
|
[FRAME Support](https://docs.substrate.io/v3/runtime/frame#support-crate)
|
||||||
library.
|
library.
|
||||||
|
|
||||||
### Pallets
|
### Pallets
|
||||||
|
@ -165,13 +165,13 @@ template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs
|
||||||
A FRAME pallet is compromised of a number of blockchain primitives:
|
A FRAME pallet is compromised of a number of blockchain primitives:
|
||||||
|
|
||||||
- Storage: FRAME defines a rich set of powerful
|
- Storage: FRAME defines a rich set of powerful
|
||||||
[storage abstractions](https://substrate.dev/docs/en/knowledgebase/runtime/storage) that makes
|
[storage abstractions](https://docs.substrate.io/v3/runtime/storage) that makes
|
||||||
it easy to use Substrate's efficient key-value database to manage the evolving state of a
|
it easy to use Substrate's efficient key-value database to manage the evolving state of a
|
||||||
blockchain.
|
blockchain.
|
||||||
- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched)
|
- Dispatchables: FRAME pallets define special types of functions that can be invoked (dispatched)
|
||||||
from outside of the runtime in order to update its state.
|
from outside of the runtime in order to update its state.
|
||||||
- Events: Substrate uses [events](https://substrate.dev/docs/en/knowledgebase/runtime/events) to
|
- Events: Substrate uses [events and errors](https://docs.substrate.io/v3/runtime/events-and-errors)
|
||||||
notify users of important changes in the runtime.
|
to notify users of important changes in the runtime.
|
||||||
- Errors: When a dispatchable fails, it returns an error.
|
- Errors: When a dispatchable fails, it returns an error.
|
||||||
- Config: The `Config` configuration interface is used to define the types and parameters upon
|
- Config: The `Config` configuration interface is used to define the types and parameters upon
|
||||||
which a FRAME pallet depends.
|
which a FRAME pallet depends.
|
||||||
|
|
|
@ -12,8 +12,9 @@ commands for Rust's toolchains will be the same for all supported, Unix-based op
|
||||||
## Unix-Based Operating Systems
|
## Unix-Based Operating Systems
|
||||||
|
|
||||||
Substrate development is easiest on Unix-based operating systems like macOS or Linux. The examples
|
Substrate development is easiest on Unix-based operating systems like macOS or Linux. The examples
|
||||||
in the Substrate [Tutorials](https://substrate.dev/tutorials) and [Recipes](https://substrate.dev/recipes/)
|
in the Substrate [Tutorials](https://docs.substrate.io/tutorials/v3) and
|
||||||
use Unix-style terminals to demonstrate how to interact with Substrate from the command line.
|
[How-to Guides](https://docs.substrate.io/how-to-guides/v3) use Unix-style terminals to demonstrate
|
||||||
|
how to interact with Substrate from the command line.
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = 'node-template'
|
||||||
version = '3.0.0-monthly-2021-10'
|
version = '3.0.0-monthly-2021-10'
|
||||||
description = 'A fresh FRAME-based Substrate node, ready for hacking.'
|
description = 'A fresh FRAME-based Substrate node, ready for hacking.'
|
||||||
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
||||||
homepage = 'https://substrate.dev'
|
homepage = 'https://docs.substrate.io/'
|
||||||
edition = '2018'
|
edition = '2018'
|
||||||
license = 'Unlicense'
|
license = 'Unlicense'
|
||||||
publish = false
|
publish = false
|
||||||
|
|
|
@ -16,7 +16,12 @@ use std::{sync::Arc, time::Duration};
|
||||||
pub struct ExecutorDispatch;
|
pub struct ExecutorDispatch;
|
||||||
|
|
||||||
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
|
||||||
|
/// Only enable the benchmarking host functions when we actually want to benchmark.
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||||
|
/// Otherwise we only use the default Substrate host functions.
|
||||||
|
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||||
|
type ExtendHostFunctions = ();
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
node_template_runtime::api::dispatch(method, data)
|
node_template_runtime::api::dispatch(method, data)
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = 'pallet-template'
|
||||||
version = '3.0.0-monthly-2021-10'
|
version = '3.0.0-monthly-2021-10'
|
||||||
description = 'FRAME pallet template for defining custom runtime logic.'
|
description = 'FRAME pallet template for defining custom runtime logic.'
|
||||||
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
||||||
homepage = 'https://substrate.dev'
|
homepage = 'https://docs.substrate.io/'
|
||||||
edition = '2018'
|
edition = '2018'
|
||||||
license = 'Unlicense'
|
license = 'Unlicense'
|
||||||
publish = false
|
publish = false
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/// Edit this file to define custom logic or remove it if it is not needed.
|
/// 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:
|
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
|
||||||
/// <https://substrate.dev/docs/en/knowledgebase/runtime/frame>
|
/// <https://docs.substrate.io/v3/runtime/frame>
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -31,15 +31,15 @@ pub mod pallet {
|
||||||
pub struct Pallet<T>(_);
|
pub struct Pallet<T>(_);
|
||||||
|
|
||||||
// The pallet's runtime storage items.
|
// The pallet's runtime storage items.
|
||||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage
|
// https://docs.substrate.io/v3/runtime/storage
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn something)]
|
#[pallet::getter(fn something)]
|
||||||
// Learn more about declaring storage items:
|
// Learn more about declaring storage items:
|
||||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items
|
// https://docs.substrate.io/v3/runtime/storage#declaring-storage-items
|
||||||
pub type Something<T> = StorageValue<_, u32>;
|
pub type Something<T> = StorageValue<_, u32>;
|
||||||
|
|
||||||
// Pallets use events to inform users when important changes are made.
|
// Pallets use events to inform users when important changes are made.
|
||||||
// https://substrate.dev/docs/en/knowledgebase/runtime/events
|
// https://docs.substrate.io/v3/runtime/events
|
||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
|
@ -68,7 +68,7 @@ pub mod pallet {
|
||||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
||||||
// Check that the extrinsic was signed and get the signer.
|
// Check that the extrinsic was signed and get the signer.
|
||||||
// This function will return an error if the extrinsic is not signed.
|
// This function will return an error if the extrinsic is not signed.
|
||||||
// https://substrate.dev/docs/en/knowledgebase/runtime/origin
|
// https://docs.substrate.io/v3/runtime/origins
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
// Update storage.
|
// Update storage.
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = 'node-template-runtime'
|
||||||
version = '3.0.0-monthly-2021-10'
|
version = '3.0.0-monthly-2021-10'
|
||||||
description = 'A fresh FRAME-based Substrate runtime, ready for hacking.'
|
description = 'A fresh FRAME-based Substrate runtime, ready for hacking.'
|
||||||
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
|
||||||
homepage = 'https://substrate.dev'
|
homepage = 'https://docs.substrate.io/'
|
||||||
edition = '2018'
|
edition = '2018'
|
||||||
license = 'Unlicense'
|
license = 'Unlicense'
|
||||||
publish = false
|
publish = false
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub mod opaque {
|
||||||
}
|
}
|
||||||
|
|
||||||
// To learn more about runtime versioning and what each of the following value means:
|
// To learn more about runtime versioning and what each of the following value means:
|
||||||
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
|
// https://docs.substrate.io/v3/runtime/origins#runtime-versioning
|
||||||
#[sp_version::runtime_version]
|
#[sp_version::runtime_version]
|
||||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
spec_name: create_runtime_str!("node-template"),
|
spec_name: create_runtime_str!("node-template"),
|
||||||
|
|
Loading…
Reference in New Issue