mirror of
https://github.com/pezkuwichain/pez-minimal-template.git
synced 2026-04-21 23:47:57 +00:00
Update template triggered by workflow_dispatch
This commit is contained in:
Generated
+605
-486
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
# Minimal Template
|
||||
|
||||
This is a minimal template for creating a blockchain using the Polkadot SDK.
|
||||
|
||||
# Docs
|
||||
|
||||
You can generate and view the [Rust
|
||||
Docs](https://doc.rust-lang.org/cargo/commands/cargo-doc.html) for this template
|
||||
with this command:
|
||||
|
||||
```sh
|
||||
cargo doc -p minimal-template --open
|
||||
```
|
||||
|
||||
+23
-23
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "minimal-template-node"
|
||||
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.11.0)"
|
||||
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.12.0)"
|
||||
version = "0.1.0"
|
||||
license = "MIT-0"
|
||||
authors.workspace = true
|
||||
@@ -22,31 +22,31 @@ futures = { version = "0.3.30", features = ["thread-pool"] }
|
||||
futures-timer = "3.0.1"
|
||||
jsonrpsee = { version = "0.22", features = ["server"] }
|
||||
serde_json = { workspace = true, default-features = true }
|
||||
sc-cli = { version = "0.41.0" }
|
||||
sc-executor = { version = "0.37.0" }
|
||||
sc-network = { version = "0.39.0" }
|
||||
sc-service = { version = "0.40.0" }
|
||||
sc-telemetry = { version = "19.0.0" }
|
||||
sc-transaction-pool = { version = "33.0.0" }
|
||||
sc-transaction-pool-api = { version = "33.0.0" }
|
||||
sc-consensus = { version = "0.38.0" }
|
||||
sc-consensus-manual-seal = { version = "0.40.0" }
|
||||
sc-rpc-api = { version = "0.38.0" }
|
||||
sc-basic-authorship = { version = "0.39.0" }
|
||||
sc-offchain = { version = "34.0.0" }
|
||||
sc-client-api = { version = "33.0.0" }
|
||||
sp-timestamp = { version = "31.0.0" }
|
||||
sp-keyring = { version = "36.0.0" }
|
||||
sp-api = { version = "31.0.0" }
|
||||
sp-blockchain = { version = "33.0.0" }
|
||||
sp-block-builder = { version = "31.0.0" }
|
||||
sp-io = { version = "35.0.0" }
|
||||
sp-runtime = { version = "36.0.0" }
|
||||
substrate-frame-rpc-system = { version = "33.0.0" }
|
||||
sc-cli = { version = "0.42.0" }
|
||||
sc-executor = { version = "0.38.0" }
|
||||
sc-network = { version = "0.40.0" }
|
||||
sc-service = { version = "0.41.0" }
|
||||
sc-telemetry = { version = "20.0.0" }
|
||||
sc-transaction-pool = { version = "34.0.0" }
|
||||
sc-transaction-pool-api = { version = "34.0.0" }
|
||||
sc-consensus = { version = "0.39.1" }
|
||||
sc-consensus-manual-seal = { version = "0.41.0" }
|
||||
sc-rpc-api = { version = "0.39.0" }
|
||||
sc-basic-authorship = { version = "0.40.0" }
|
||||
sc-offchain = { version = "35.0.0" }
|
||||
sc-client-api = { version = "34.0.0" }
|
||||
sp-timestamp = { version = "32.0.0" }
|
||||
sp-keyring = { version = "37.0.0" }
|
||||
sp-api = { version = "32.0.0" }
|
||||
sp-blockchain = { version = "34.0.0" }
|
||||
sp-block-builder = { version = "32.0.0" }
|
||||
sp-io = { version = "36.0.0" }
|
||||
sp-runtime = { version = "37.0.0" }
|
||||
substrate-frame-rpc-system = { version = "34.0.0" }
|
||||
|
||||
# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
|
||||
# certainly no dependency on the runtime.
|
||||
frame = { version = "0.2.0", package = "polkadot-sdk-frame", features = ["experimental", "runtime"] }
|
||||
frame = { version = "0.3.0", package = "polkadot-sdk-frame", features = ["experimental", "runtime"] }
|
||||
runtime = { package = "minimal-template-runtime", path = "../runtime", version = "0.1.0" }
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pallet-minimal-template"
|
||||
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.11.0)"
|
||||
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.12.0)"
|
||||
version = "0.1.0"
|
||||
license = "MIT-0"
|
||||
authors.workspace = true
|
||||
@@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
|
||||
scale-info = { version = "2.11.1", default-features = false, features = [
|
||||
"derive",
|
||||
] }
|
||||
frame = { version = "0.2.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
|
||||
frame = { version = "0.3.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "minimal-template-runtime"
|
||||
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.11.0)"
|
||||
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.12.0)"
|
||||
version = "0.1.0"
|
||||
license = "MIT-0"
|
||||
authors.workspace = true
|
||||
@@ -17,18 +17,18 @@ parity-scale-codec = { version = "3.0.0", default-features = false }
|
||||
scale-info = { version = "2.6.0", default-features = false }
|
||||
|
||||
# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
|
||||
frame = { version = "0.2.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
|
||||
frame = { version = "0.3.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
|
||||
|
||||
# pallets that we want to use
|
||||
pallet-balances = { version = "34.0.0", default-features = false }
|
||||
pallet-sudo = { version = "33.0.0", default-features = false }
|
||||
pallet-timestamp = { version = "32.0.0", default-features = false }
|
||||
pallet-transaction-payment = { version = "33.0.0", default-features = false }
|
||||
pallet-transaction-payment-rpc-runtime-api = { version = "33.0.0", default-features = false }
|
||||
pallet-balances = { version = "35.0.0", default-features = false }
|
||||
pallet-sudo = { version = "34.0.0", default-features = false }
|
||||
pallet-timestamp = { version = "33.0.0", default-features = false }
|
||||
pallet-transaction-payment = { version = "34.0.0", default-features = false }
|
||||
pallet-transaction-payment-rpc-runtime-api = { version = "34.0.0", default-features = false }
|
||||
|
||||
# genesis builder that allows us to interact with runtime genesis config
|
||||
sp-genesis-builder = { version = "0.12.0", default-features = false }
|
||||
sp-runtime = { version = "36.0.0", default-features = false, features = ["serde"] }
|
||||
sp-genesis-builder = { version = "0.13.0", default-features = false }
|
||||
sp-runtime = { version = "37.0.0", default-features = false, features = ["serde"] }
|
||||
|
||||
# local pallet templates
|
||||
pallet-minimal-template = { path = "../pallets/template", default-features = false, version = "0.1.0" }
|
||||
|
||||
+63
-12
@@ -15,6 +15,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! A minimal runtime that includes the template [`pallet`](`pallet_minimal_template`).
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
// Make the WASM binary available.
|
||||
@@ -24,6 +26,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
use frame::{
|
||||
deps::frame_support::{
|
||||
genesis_builder_helper::{build_state, get_preset},
|
||||
runtime,
|
||||
weights::{FixedFee, NoFee},
|
||||
},
|
||||
prelude::*,
|
||||
@@ -36,6 +39,7 @@ use frame::{
|
||||
},
|
||||
};
|
||||
|
||||
/// The runtime version.
|
||||
#[runtime_version]
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("minimal-template-runtime"),
|
||||
@@ -54,61 +58,108 @@ pub fn native_version() -> NativeVersion {
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
/// The signed extensions that are added to the runtime.
|
||||
type SignedExtra = (
|
||||
// Checks that the sender is not the zero address.
|
||||
frame_system::CheckNonZeroSender<Runtime>,
|
||||
// Checks that the runtime version is correct.
|
||||
frame_system::CheckSpecVersion<Runtime>,
|
||||
// Checks that the transaction version is correct.
|
||||
frame_system::CheckTxVersion<Runtime>,
|
||||
// Checks that the genesis hash is correct.
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
// Checks that the era is valid.
|
||||
frame_system::CheckEra<Runtime>,
|
||||
// Checks that the nonce is valid.
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
// Checks that the weight is valid.
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
// Ensures that the sender has enough funds to pay for the transaction
|
||||
// and deducts the fee from the sender's account.
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
);
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Runtime {
|
||||
System: frame_system,
|
||||
Timestamp: pallet_timestamp,
|
||||
// Composes the runtime by adding all the used pallets and deriving necessary types.
|
||||
#[runtime]
|
||||
mod runtime {
|
||||
/// The main runtime type.
|
||||
#[runtime::runtime]
|
||||
#[runtime::derive(
|
||||
RuntimeCall,
|
||||
RuntimeEvent,
|
||||
RuntimeError,
|
||||
RuntimeOrigin,
|
||||
RuntimeFreezeReason,
|
||||
RuntimeHoldReason,
|
||||
RuntimeSlashReason,
|
||||
RuntimeLockId,
|
||||
RuntimeTask
|
||||
)]
|
||||
pub struct Runtime;
|
||||
|
||||
Balances: pallet_balances,
|
||||
Sudo: pallet_sudo,
|
||||
TransactionPayment: pallet_transaction_payment,
|
||||
/// Mandatory system pallet that should always be included in a FRAME runtime.
|
||||
#[runtime::pallet_index(0)]
|
||||
pub type System = frame_system;
|
||||
|
||||
// our local pallet
|
||||
Template: pallet_minimal_template,
|
||||
}
|
||||
);
|
||||
/// Provides a way for consensus systems to set and check the onchain time.
|
||||
#[runtime::pallet_index(1)]
|
||||
pub type Timestamp = pallet_timestamp;
|
||||
|
||||
/// Provides the ability to keep track of balances.
|
||||
#[runtime::pallet_index(2)]
|
||||
pub type Balances = pallet_balances;
|
||||
|
||||
/// Provides a way to execute privileged functions.
|
||||
#[runtime::pallet_index(3)]
|
||||
pub type Sudo = pallet_sudo;
|
||||
|
||||
/// Provides the ability to charge for extrinsic execution.
|
||||
#[runtime::pallet_index(4)]
|
||||
pub type TransactionPayment = pallet_transaction_payment;
|
||||
|
||||
/// A minimal pallet template.
|
||||
#[runtime::pallet_index(5)]
|
||||
pub type Template = pallet_minimal_template;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
}
|
||||
|
||||
/// Implements the types required for the system pallet.
|
||||
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
|
||||
impl frame_system::Config for Runtime {
|
||||
type Block = Block;
|
||||
type Version = Version;
|
||||
type BlockHashCount = ConstU32<1024>;
|
||||
// Use the account data from the balances pallet
|
||||
type AccountData = pallet_balances::AccountData<<Runtime as pallet_balances::Config>::Balance>;
|
||||
}
|
||||
|
||||
// Implements the types required for the balances pallet.
|
||||
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pallet_balances::Config for Runtime {
|
||||
type AccountStore = System;
|
||||
}
|
||||
|
||||
// Implements the types required for the sudo pallet.
|
||||
#[derive_impl(pallet_sudo::config_preludes::TestDefaultConfig)]
|
||||
impl pallet_sudo::Config for Runtime {}
|
||||
|
||||
// Implements the types required for the sudo pallet.
|
||||
#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)]
|
||||
impl pallet_timestamp::Config for Runtime {}
|
||||
|
||||
// Implements the types required for the transaction payment pallet.
|
||||
#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig)]
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
|
||||
// Setting fee as independent of the weight of the extrinsic for demo purposes
|
||||
type WeightToFee = NoFee<<Self as pallet_balances::Config>::Balance>;
|
||||
// Setting fee as fixed for any length of the call data for demo purposes
|
||||
type LengthToFee = FixedFee<1, <Self as pallet_balances::Config>::Balance>;
|
||||
}
|
||||
|
||||
// Implements the types required for the template pallet.
|
||||
impl pallet_minimal_template::Config for Runtime {}
|
||||
|
||||
type Block = frame::runtime::types_common::BlockOf<Runtime, SignedExtra>;
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
//! # Minimal Template
|
||||
//!
|
||||
//! This is a minimal template for creating a blockchain using the Polkadot SDK.
|
||||
//!
|
||||
//! ## Components
|
||||
//!
|
||||
//! The template consists of the following components:
|
||||
//!
|
||||
//! ### Node
|
||||
//!
|
||||
//! A minimal blockchain [`node`](`minimal_template_node`) that is capable of running a
|
||||
//! runtime. It uses a simple chain specification, provides an option to choose Manual or
|
||||
//! InstantSeal for consensus and exposes a few commands to interact with the node.
|
||||
//!
|
||||
//! ### Runtime
|
||||
//!
|
||||
//! A minimal [`runtime`](`minimal_template_runtime`) (or a state transition function) that
|
||||
//! is capable of being run on the node. It is built using the [`FRAME`](`frame`) framework
|
||||
//! that enables the composition of the core logic via separate modules called "pallets".
|
||||
//! FRAME defines a complete DSL for building such pallets and the runtime itself.
|
||||
//!
|
||||
//! #### Transaction Fees
|
||||
//!
|
||||
//! The runtime charges a transaction fee for every transaction that is executed. The fee is
|
||||
//! calculated based on the weight of the transaction (accouting for the execution time) and
|
||||
//! length of the call data. Please refer to
|
||||
//! [`benchmarking docs`](`polkadot_sdk_docs::reference_docs::frame_benchmarking_weight`) for
|
||||
//! more information on how the weight is calculated.
|
||||
//!
|
||||
//! This template sets the fee as independent of the weight of the extrinsic and fixed for any
|
||||
//! length of the call data for demo purposes.
|
||||
//!
|
||||
//! ### Pallet
|
||||
//!
|
||||
//! A minimal [`pallet`](`pallet_minimal_template`) that is built using FRAME. It is a unit of
|
||||
//! encapsulated logic that has a clearly defined responsibility and can be linked to other pallets.
|
||||
//!
|
||||
//! ## Getting Started
|
||||
//!
|
||||
//! To get started with the template, follow the steps below:
|
||||
//!
|
||||
//! ### Build the Node
|
||||
//!
|
||||
//! Build the node using the following command:
|
||||
//!
|
||||
//! ```bash
|
||||
//! cargo build -p minimal-template-node --release
|
||||
//! ```
|
||||
//!
|
||||
//! ### Run the Node
|
||||
//!
|
||||
//! Run the node using the following command:
|
||||
//!
|
||||
//! ```bash
|
||||
//! ./target/release/minimal-template-node --dev
|
||||
//! ```
|
||||
//!
|
||||
//! ### CLI Options
|
||||
//!
|
||||
//! The node exposes a few options that can be used to interact with the node. To see the list of
|
||||
//! available options, run the following command:
|
||||
//!
|
||||
//! ```bash
|
||||
//! ./target/release/minimal-template-node --help
|
||||
//! ```
|
||||
//!
|
||||
//! #### Consensus Algorithm
|
||||
//!
|
||||
//! In order to run the node with a specific consensus algorithm, use the `--consensus` flag. For
|
||||
//! example, to run the node with ManualSeal consensus with a block time of 5000ms, use the
|
||||
//! following command:
|
||||
//!
|
||||
//! ```bash
|
||||
//! ./target/release/minimal-template-node --dev --consensus manual-seal-5000
|
||||
//! ```
|
||||
Reference in New Issue
Block a user