Update the minimal template to stable2409 (#19)

The template has NOT been successfully built and needs to be inspected.
This commit is contained in:
Kian Paimani
2024-11-05 16:43:53 +00:00
committed by GitHub
20 changed files with 8899 additions and 1060 deletions
Generated
+8818 -811
View File
File diff suppressed because it is too large Load Diff
+5 -38
View File
@@ -6,51 +6,18 @@ repository = "https://github.com/paritytech/polkadot-sdk-minimal-template.git"
edition = "2021"
[workspace]
members = [
"node",
"pallets/template",
"runtime",
]
members = ["node", "pallets/template", "runtime"]
resolver = "2"
[workspace.dependencies]
minimal-template-runtime = { path = "./runtime", default-features = false }
pallet-minimal-template = { path = "./pallets/template", default-features = false }
clap = { version = "4.5.3" }
clap = { version = "4.5.10" }
docify = { version = "0.2.8" }
frame = { version = "0.6.0", default-features = false, package = "polkadot-sdk-frame" }
futures = { version = "0.3.30" }
futures-timer = { version = "3.0.2" }
jsonrpsee = { version = "0.23.2" }
sc-basic-authorship = { version = "0.44.0", default-features = false }
sc-cli = { version = "0.46.0", default-features = false }
sc-client-api = { version = "37.0.0", default-features = false }
sc-consensus = { version = "0.43.0", default-features = false }
sc-consensus-manual-seal = { version = "0.45.0", default-features = false }
sc-executor = { version = "0.40.0", default-features = false }
sc-network = { version = "0.44.0", default-features = false }
sc-offchain = { version = "39.0.0", default-features = false }
sc-rpc-api = { version = "0.43.0", default-features = false }
sc-service = { version = "0.45.0", default-features = false }
sc-telemetry = { version = "24.0.0", default-features = false }
sc-transaction-pool = { version = "37.0.0", default-features = false }
sc-transaction-pool-api = { version = "37.0.0", default-features = false }
serde_json = { version = "1.0.114", default-features = false }
sp-api = { version = "34.0.0", default-features = false }
sp-block-builder = { version = "34.0.0", default-features = false }
sp-blockchain = { version = "37.0.0", default-features = false }
sp-io = { version = "38.0.0", default-features = false }
sp-keyring = { version = "39.0.0", default-features = false }
sp-runtime = { version = "39.0.0", default-features = false }
sp-timestamp = { version = "34.0.0", default-features = false }
substrate-frame-rpc-system = { version = "38.0.0", default-features = false }
substrate-build-script-utils = { version = "11.0.0", default-features = false }
jsonrpsee = { version = "0.24.3" }
polkadot-sdk = { version = "0.7.0", default-features = false }
serde_json = { version = "1.0.127", default-features = false }
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
pallet-balances = { version = "38.0.0", default-features = false }
pallet-sudo = { version = "37.0.0", default-features = false }
pallet-timestamp = { version = "36.0.0", default-features = false }
pallet-transaction-payment = { version = "37.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "37.0.0", default-features = false }
scale-info = { version = "2.11.1", default-features = false }
sp-genesis-builder = { version = "0.15.0", default-features = false }
substrate-wasm-builder = { version = "24.0.0", default-features = false }
+1 -1
View File
@@ -42,7 +42,7 @@ packages required to compile this template - please take note of the Rust compil
🔨 Use the following command to build the node without launching it:
```sh
cargo build --package minimal-template-node --release
cargo build --release
```
🐳 Alternatively, build the docker image:
+4 -46
View File
@@ -1,6 +1,6 @@
[package]
name = "minimal-template-node"
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.15.0)"
description = "A minimal Substrate-based Substrate node, ready for hacking."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
@@ -20,57 +20,15 @@ futures = { features = ["thread-pool"], workspace = true }
futures-timer = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
serde_json = { workspace = true, default-features = true }
sc-cli.workspace = true
sc-cli.default-features = true
sc-executor.workspace = true
sc-executor.default-features = true
sc-network.workspace = true
sc-network.default-features = true
sc-service.workspace = true
sc-service.default-features = true
sc-telemetry.workspace = true
sc-telemetry.default-features = true
sc-transaction-pool.workspace = true
sc-transaction-pool.default-features = true
sc-transaction-pool-api.workspace = true
sc-transaction-pool-api.default-features = true
sc-consensus.workspace = true
sc-consensus.default-features = true
sc-consensus-manual-seal.workspace = true
sc-consensus-manual-seal.default-features = true
sc-rpc-api.workspace = true
sc-rpc-api.default-features = true
sc-basic-authorship.workspace = true
sc-basic-authorship.default-features = true
sc-offchain.workspace = true
sc-offchain.default-features = true
sc-client-api.workspace = true
sc-client-api.default-features = true
sp-timestamp.workspace = true
sp-timestamp.default-features = true
sp-keyring.workspace = true
sp-keyring.default-features = true
sp-api.workspace = true
sp-api.default-features = true
sp-blockchain.workspace = true
sp-blockchain.default-features = true
sp-block-builder.workspace = true
sp-block-builder.default-features = true
sp-io.workspace = true
sp-io.default-features = true
sp-runtime.workspace = true
sp-runtime.default-features = true
substrate-frame-rpc-system.workspace = true
substrate-frame-rpc-system.default-features = true
frame = { features = ["experimental", "runtime"], workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["experimental", "node"] }
minimal-template-runtime.workspace = true
[build-dependencies]
substrate-build-script-utils.workspace = true
substrate-build-script-utils.default-features = true
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }
[features]
default = ["std"]
std = [
"minimal-template-runtime/std",
"polkadot-sdk/std",
]
+5
View File
@@ -16,3 +16,8 @@
initial (genesis) state.
- [`service.rs`](./src/service.rs): This file defines the node implementation.
It's a place to configure consensus-related topics. In favor of minimalism, this template has no consensus configured.
## Release
Polkadot SDK stable2409
+1 -1
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
use polkadot_sdk::substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
fn main() {
generate_cargo_keys();
+6 -3
View File
@@ -16,9 +16,12 @@
// limitations under the License.
use minimal_template_runtime::{BalancesConfig, SudoConfig, WASM_BINARY};
use sc_service::{ChainType, Properties};
use polkadot_sdk::{
sc_service::{ChainType, Properties},
sp_keyring::AccountKeyring,
*,
};
use serde_json::{json, Value};
use sp_keyring::AccountKeyring;
/// This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec;
@@ -42,8 +45,8 @@ pub fn development_config() -> Result<ChainSpec, String> {
/// Configure initial storage state for FRAME pallets.
fn testnet_genesis() -> Value {
use frame::traits::Get;
use minimal_template_runtime::interface::{Balance, MinimumBalance};
use polkadot_sdk::polkadot_sdk_frame::traits::Get;
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
let balances = AccountKeyring::iter()
.map(|a| (a.to_account_id(), endowment))
+1 -1
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use sc_cli::RunCmd;
use polkadot_sdk::{sc_cli::RunCmd, *};
#[derive(Debug, Clone)]
pub enum Consensus {
+1 -5
View File
@@ -20,11 +20,7 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;
#[cfg(feature = "try-runtime")]
use try_runtime_cli::block_building_info::timestamp_with_aura_info;
use polkadot_sdk::{sc_cli::SubstrateCli, sc_service::PartialComponents, *};
impl SubstrateCli for Cli {
fn impl_name() -> String {
+1 -1
View File
@@ -24,6 +24,6 @@ mod command;
mod rpc;
mod service;
fn main() -> sc_cli::Result<()> {
fn main() -> polkadot_sdk::sc_cli::Result<()> {
command::run()
}
+8 -9
View File
@@ -24,20 +24,19 @@
use jsonrpsee::RpcModule;
use minimal_template_runtime::interface::{AccountId, Nonce, OpaqueBlock};
use sc_transaction_pool_api::TransactionPool;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use polkadot_sdk::{
sc_transaction_pool_api::TransactionPool,
sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
*,
};
use std::sync::Arc;
pub use sc_rpc_api::DenyUnsafe;
/// Full client dependencies.
pub struct FullDeps<C, P> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
}
#[docify::export]
@@ -57,11 +56,11 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
P: TransactionPool + 'static,
{
use substrate_frame_rpc_system::{System, SystemApiServer};
use polkadot_sdk::substrate_frame_rpc_system::{System, SystemApiServer};
let mut module = RpcModule::new(());
let FullDeps { client, pool, deny_unsafe } = deps;
let FullDeps { client, pool } = deps;
module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
Ok(module)
}
+17 -17
View File
@@ -17,21 +17,19 @@
use futures::FutureExt;
use minimal_template_runtime::{interface::OpaqueBlock as Block, RuntimeApi};
use sc_client_api::backend::Backend;
use sc_executor::WasmExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_runtime::traits::Block as BlockT;
use polkadot_sdk::{
sc_client_api::backend::Backend,
sc_executor::WasmExecutor,
sc_service::{error::Error as ServiceError, Configuration, TaskManager},
sc_telemetry::{Telemetry, TelemetryWorker},
sc_transaction_pool_api::OffchainTransactionPoolFactory,
sp_runtime::traits::Block as BlockT,
*,
};
use std::sync::Arc;
use crate::cli::Consensus;
#[cfg(feature = "runtime-benchmarks")]
type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions = sp_io::SubstrateHostFunctions;
#[docify::export]
@@ -63,7 +61,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
})
.transpose()?;
let executor = sc_service::new_wasm_executor(config);
let executor = sc_service::new_wasm_executor(&config.executor);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
@@ -126,7 +124,10 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
Block,
<Block as BlockT>::Hash,
Network,
>::new(&config.network);
>::new(
&config.network,
config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()),
);
let metrics = Network::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);
@@ -140,7 +141,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
import_queue,
net_config,
block_announce_validator_builder: None,
warp_sync_params: None,
warp_sync_config: None,
block_relay: None,
metrics,
})?;
@@ -170,9 +171,8 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
let client = client.clone();
let pool = transaction_pool.clone();
Box::new(move |deny_unsafe, _| {
let deps =
crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), deny_unsafe };
Box::new(move |_| {
let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone() };
crate::rpc::create_full(deps).map_err(Into::into)
})
};
+5 -9
View File
@@ -1,6 +1,6 @@
[package]
name = "pallet-minimal-template"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.15.0)"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
@@ -13,15 +13,11 @@ publish = false
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { features = [
"derive",
], workspace = true }
scale-info = { features = [
"derive",
], workspace = true }
frame = { features = ["experimental", "runtime"], workspace = true }
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
polkadot-sdk = { workspace = true, features = ["experimental", "runtime"], default-features = false }
[features]
default = ["std"]
std = ["codec/std", "frame/std", "scale-info/std"]
std = ["codec/std", "polkadot-sdk/std", "scale-info/std"]
+5
View File
@@ -0,0 +1,5 @@
## Release
Polkadot SDK stable2409
+2 -2
View File
@@ -5,7 +5,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use frame::prelude::*;
use polkadot_sdk::polkadot_sdk_frame as frame;
// Re-export all pallet parts, this is needed to properly import the pallet into the runtime.
pub use pallet::*;
@@ -15,7 +15,7 @@ pub mod pallet {
use super::*;
#[pallet::config]
pub trait Config: frame_system::Config {}
pub trait Config: polkadot_sdk::frame_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
+5 -24
View File
@@ -1,6 +1,6 @@
[package]
name = "minimal-template-runtime"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.15.0)"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk."
version = "0.1.0"
license = "Unlicense"
authors.workspace = true
@@ -12,36 +12,17 @@ publish = false
[dependencies]
codec = { workspace = true }
scale-info = { workspace = true }
frame = { features = ["experimental", "runtime"], workspace = true }
pallet-balances.workspace = true
pallet-sudo.workspace = true
pallet-timestamp.workspace = true
pallet-transaction-payment.workspace = true
pallet-transaction-payment-rpc-runtime-api.workspace = true
sp-genesis-builder.workspace = true
sp-runtime = { features = ["serde"], workspace = true }
polkadot-sdk = { workspace = true, features = ["experimental", "pallet-balances", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "runtime"] }
pallet-minimal-template.workspace = true
[build-dependencies]
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }
polkadot-sdk = { optional = true, workspace = true, features = ["substrate-wasm-builder"] }
[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"frame/std",
"pallet-balances/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-minimal-template/std",
"sp-genesis-builder/std",
"sp-runtime/std",
"substrate-wasm-builder",
"polkadot-sdk/std",
"scale-info/std",
]
+5
View File
@@ -8,3 +8,8 @@ responsible for validating blocks and executing the state changes they define.
👉 Learn more about FRAME
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html).
## Release
Polkadot SDK stable2409
+1 -1
View File
@@ -18,6 +18,6 @@
fn main() {
#[cfg(feature = "std")]
{
substrate_wasm_builder::WasmBuilder::build_using_defaults();
polkadot_sdk::substrate_wasm_builder::WasmBuilder::build_using_defaults();
}
}
+8 -16
View File
@@ -26,20 +26,14 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
extern crate alloc;
use alloc::{vec, vec::Vec};
use frame::{
deps::frame_support::{
genesis_builder_helper::{build_state, get_preset},
runtime,
weights::{FixedFee, NoFee},
},
prelude::*,
runtime::{
apis::{
self, impl_runtime_apis, ApplyExtrinsicResult, CheckInherentsResult,
ExtrinsicInclusionMode, OpaqueMetadata,
},
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use polkadot_sdk::{
polkadot_sdk_frame::{
self as frame,
prelude::*,
runtime::{apis, prelude::*},
},
*,
};
/// The runtime version.
@@ -83,7 +77,7 @@ type SignedExtra = (
);
// Composes the runtime by adding all the used pallets and deriving necessary types.
#[runtime]
#[frame_construct_runtime]
mod runtime {
/// The main runtime type.
#[runtime::runtime]
@@ -171,8 +165,6 @@ type Header = HeaderFor<Runtime>;
type RuntimeExecutive =
Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllPalletsWithSystem>;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
impl_runtime_apis! {
impl apis::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
@@ -296,7 +288,7 @@ impl_runtime_apis! {
// https://github.com/paritytech/substrate/issues/10579#issuecomment-1600537558
pub mod interface {
use super::Runtime;
use frame::deps::frame_system;
use polkadot_sdk::{polkadot_sdk_frame as frame, *};
pub type Block = super::Block;
pub use frame::runtime::types_common::OpaqueBlock;
-75
View File
@@ -1,75 +0,0 @@
//! # 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
//! ```