Repot all templates into a single directory (#3460)

The first step towards
https://github.com/paritytech/polkadot-sdk/issues/3155

Brings all templates under the following structure

```
templates
|   parachain
|   |   polkadot-launch
|   |   runtime              --> parachain-template-runtime
|   |   pallets              --> pallet-parachain-template
|   |   node                 --> parachain-template-node
|   minimal
|   |   runtime              --> minimal-template-runtime
|   |   pallets              --> pallet-minimal-template
|   |   node                 --> minimal-template-node
|   solochain
|   |   runtime              --> solochain-template-runtime
|   |   pallets              --> pallet-template (the naming is not consistent here)
|   |   node                 --> solochain-template-node
```

The only note-worthy changes in this PR are: 

- More `Cargo.toml` fields are forwarded to use the one from the
workspace.
- parachain template now has weights and benchmarks
- adds a shell pallet to the minimal template
- remove a few unused deps 


A list of possible follow-ups: 

- [ ] Unify READMEs, create a parent README for all
- [ ] remove references to `docs.substrate.io` in templates
- [ ] make all templates use `#[derive_impl]`
- [ ] update and unify all licenses
- [ ] Remove polkadot launch, use
https://github.com/paritytech/polkadot-sdk/blob/35349df993ea2e7c4769914ef5d199e787b23d4c/cumulus/zombienet/examples/small_network.toml
instead.
This commit is contained in:
Kian Paimani
2024-03-05 11:40:37 +00:00
committed by GitHub
parent a71f018c7a
commit 4c810609d6
85 changed files with 819 additions and 576 deletions
+11 -11
View File
@@ -18,7 +18,7 @@ def parse_args():
parser.add_argument('workspace_dir', help='The directory to check', metavar='workspace_dir', type=str, nargs=1)
parser.add_argument('--exclude', help='Exclude crate paths from the check', metavar='exclude', type=str, nargs='*', default=[])
args = parser.parse_args()
return (args.workspace_dir[0], args.exclude)
@@ -26,7 +26,7 @@ def main(root, exclude):
workspace_crates = get_members(root, exclude)
all_crates = get_crates(root, exclude)
print(f'📦 Found {len(all_crates)} crates in total')
check_duplicates(workspace_crates)
check_missing(workspace_crates, all_crates)
check_links(all_crates)
@@ -48,14 +48,14 @@ def get_members(workspace_dir, exclude):
if not 'members' in root_manifest['workspace']:
return []
members = []
for member in root_manifest['workspace']['members']:
if member in exclude:
print(f'❌ Excluded member should not appear in the workspace {member}')
sys.exit(1)
members.append(member)
return members
# List all members of the workspace.
@@ -74,12 +74,12 @@ def get_crates(workspace_dir, exclude_crates) -> dict:
with open(path, "r") as f:
content = f.read()
manifest = toml.loads(content)
if 'workspace' in manifest:
if root != workspace_dir:
print("⏩ Excluded recursive workspace at %s" % path)
continue
# Cut off the root path and the trailing /Cargo.toml.
path = path[len(workspace_dir)+1:-11]
name = manifest['package']['name']
@@ -87,7 +87,7 @@ def get_crates(workspace_dir, exclude_crates) -> dict:
print("⏩ Excluded crate %s at %s" % (name, path))
continue
crates[name] = (path, manifest)
return crates
# Check that there are no duplicate entries in the workspace.
@@ -138,23 +138,23 @@ def check_links(all_crates):
if not 'path' in deps[dep]:
broken.append((name, dep_name, "crate must be linked via `path`"))
return
def check_crate(deps):
to_checks = ['dependencies', 'dev-dependencies', 'build-dependencies']
for to_check in to_checks:
if to_check in deps:
check_deps(deps[to_check])
# There could possibly target dependant deps:
if 'target' in manifest:
# Target dependant deps can only have one level of nesting:
for _, target in manifest['target'].items():
check_crate(target)
check_crate(manifest)
links.sort()
broken.sort()
-1
View File
@@ -42,5 +42,4 @@ jobs:
shopt -s globstar
npx @paritytech/license-scanner scan \
--ensure-licenses ${{ env.LICENSES }} \
--exclude ./substrate/bin/node-template \
-- ./substrate/**/*.rs
+1 -1
View File
@@ -337,7 +337,7 @@ build-runtimes-polkavm:
- .common-refs
- .run-immediately
script:
- SUBSTRATE_RUNTIME_TARGET=riscv cargo check -p minimal-runtime
- SUBSTRATE_RUNTIME_TARGET=riscv cargo check -p minimal-template-runtime
- SUBSTRATE_RUNTIME_TARGET=riscv cargo check -p westend-runtime
- SUBSTRATE_RUNTIME_TARGET=riscv cargo check -p rococo-runtime
- SUBSTRATE_RUNTIME_TARGET=riscv cargo check -p polkadot-test-runtime
Generated
+100 -95
View File
@@ -8172,15 +8172,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "minimal-node"
version = "4.0.0-dev"
name = "minimal-template-node"
version = "0.0.0"
dependencies = [
"clap 4.5.1",
"frame",
"futures",
"futures-timer",
"jsonrpsee",
"minimal-runtime",
"minimal-template-runtime",
"sc-basic-authorship",
"sc-cli",
"sc-client-api",
@@ -8207,12 +8207,12 @@ dependencies = [
]
[[package]]
name = "minimal-runtime"
version = "0.1.0"
name = "minimal-template-runtime"
version = "0.0.0"
dependencies = [
"frame",
"frame-support",
"pallet-balances",
"pallet-minimal-template",
"pallet-sudo",
"pallet-timestamp",
"pallet-transaction-payment",
@@ -8726,50 +8726,6 @@ dependencies = [
"kitchensink-runtime",
]
[[package]]
name = "node-template"
version = "4.0.0-dev"
dependencies = [
"clap 4.5.1",
"frame-benchmarking",
"frame-benchmarking-cli",
"frame-system",
"futures",
"jsonrpsee",
"node-template-runtime",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc",
"sc-basic-authorship",
"sc-cli",
"sc-client-api",
"sc-consensus",
"sc-consensus-aura",
"sc-consensus-grandpa",
"sc-executor",
"sc-network",
"sc-offchain",
"sc-rpc-api",
"sc-service",
"sc-telemetry",
"sc-transaction-pool",
"sc-transaction-pool-api",
"serde_json",
"sp-api",
"sp-block-builder",
"sp-blockchain",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-inherents",
"sp-io",
"sp-keyring",
"sp-runtime",
"sp-timestamp",
"substrate-build-script-utils",
"substrate-frame-rpc-system",
"try-runtime-cli",
]
[[package]]
name = "node-template-release"
version = "3.0.0"
@@ -8784,45 +8740,6 @@ dependencies = [
"toml_edit 0.19.15",
]
[[package]]
name = "node-template-runtime"
version = "4.0.0-dev"
dependencies = [
"frame-benchmarking",
"frame-executive",
"frame-support",
"frame-system",
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"pallet-aura",
"pallet-balances",
"pallet-grandpa",
"pallet-sudo",
"pallet-template",
"pallet-timestamp",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
"parity-scale-codec",
"scale-info",
"serde_json",
"sp-api",
"sp-block-builder",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-genesis-builder",
"sp-inherents",
"sp-offchain",
"sp-runtime",
"sp-session",
"sp-std 14.0.0",
"sp-storage 19.0.0",
"sp-transaction-pool",
"sp-version",
"substrate-wasm-builder",
]
[[package]]
name = "node-testing"
version = "3.0.0-dev"
@@ -10302,6 +10219,15 @@ dependencies = [
"sp-version",
]
[[package]]
name = "pallet-minimal-template"
version = "0.0.0"
dependencies = [
"frame",
"parity-scale-codec",
"scale-info",
]
[[package]]
name = "pallet-mixnet"
version = "0.4.0"
@@ -10603,14 +10529,13 @@ dependencies = [
[[package]]
name = "pallet-parachain-template"
version = "0.7.0"
version = "0.0.0"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"parity-scale-codec",
"scale-info",
"serde",
"sp-core",
"sp-io",
"sp-runtime",
@@ -11065,7 +10990,7 @@ dependencies = [
[[package]]
name = "pallet-template"
version = "4.0.0-dev"
version = "0.0.0"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -11075,7 +11000,6 @@ dependencies = [
"sp-core",
"sp-io",
"sp-runtime",
"sp-std 14.0.0",
]
[[package]]
@@ -11389,7 +11313,7 @@ dependencies = [
[[package]]
name = "parachain-template-node"
version = "0.1.0"
version = "0.0.0"
dependencies = [
"clap 4.5.1",
"color-print",
@@ -11447,7 +11371,7 @@ dependencies = [
[[package]]
name = "parachain-template-runtime"
version = "0.7.0"
version = "0.0.0"
dependencies = [
"cumulus-pallet-aura-ext",
"cumulus-pallet-parachain-system",
@@ -18356,6 +18280,87 @@ dependencies = [
"sha-1 0.9.8",
]
[[package]]
name = "solochain-template-node"
version = "0.0.0"
dependencies = [
"clap 4.5.1",
"frame-benchmarking-cli",
"frame-system",
"futures",
"jsonrpsee",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc",
"sc-basic-authorship",
"sc-cli",
"sc-client-api",
"sc-consensus",
"sc-consensus-aura",
"sc-consensus-grandpa",
"sc-executor",
"sc-network",
"sc-offchain",
"sc-rpc-api",
"sc-service",
"sc-telemetry",
"sc-transaction-pool",
"sc-transaction-pool-api",
"serde_json",
"solochain-template-runtime",
"sp-api",
"sp-block-builder",
"sp-blockchain",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-inherents",
"sp-io",
"sp-keyring",
"sp-runtime",
"sp-timestamp",
"substrate-build-script-utils",
"substrate-frame-rpc-system",
"try-runtime-cli",
]
[[package]]
name = "solochain-template-runtime"
version = "0.0.0"
dependencies = [
"frame-benchmarking",
"frame-executive",
"frame-support",
"frame-system",
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"pallet-aura",
"pallet-balances",
"pallet-grandpa",
"pallet-sudo",
"pallet-template",
"pallet-timestamp",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
"parity-scale-codec",
"scale-info",
"sp-api",
"sp-block-builder",
"sp-consensus-aura",
"sp-consensus-grandpa",
"sp-core",
"sp-genesis-builder",
"sp-inherents",
"sp-offchain",
"sp-runtime",
"sp-session",
"sp-std 14.0.0",
"sp-storage 19.0.0",
"sp-transaction-pool",
"sp-version",
"substrate-wasm-builder",
]
[[package]]
name = "sp-api"
version = "26.0.0"
+13 -8
View File
@@ -3,6 +3,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
repository = "https://github.com/paritytech/polkadot-sdk.git"
license = "GPL-3.0-only"
homepage = "https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/index.html"
[workspace]
resolver = "2"
@@ -74,9 +75,6 @@ members = [
"cumulus/pallets/solo-to-para",
"cumulus/pallets/xcm",
"cumulus/pallets/xcmp-queue",
"cumulus/parachain-template/node",
"cumulus/parachain-template/pallets/template",
"cumulus/parachain-template/runtime",
"cumulus/parachains/common",
"cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend",
@@ -219,11 +217,6 @@ members = [
"polkadot/xcm/xcm-simulator",
"polkadot/xcm/xcm-simulator/example",
"polkadot/xcm/xcm-simulator/fuzzer",
"substrate/bin/minimal/node",
"substrate/bin/minimal/runtime",
"substrate/bin/node-template/node",
"substrate/bin/node-template/pallets/template",
"substrate/bin/node-template/runtime",
"substrate/bin/node/bench",
"substrate/bin/node/cli",
"substrate/bin/node/inspect",
@@ -504,6 +497,18 @@ members = [
"substrate/utils/frame/try-runtime/cli",
"substrate/utils/prometheus",
"substrate/utils/wasm-builder",
"templates/minimal/node",
"templates/minimal/pallets/template",
"templates/minimal/runtime",
"templates/solochain/node",
"templates/solochain/pallets/template",
"templates/solochain/runtime",
"templates/parachain/node",
"templates/parachain/pallets/template",
"templates/parachain/runtime",
]
default-members = ["polkadot", "substrate/bin/node/cli"]
@@ -1 +0,0 @@
License: Unlicense
@@ -1,20 +0,0 @@
//! Benchmarking setup for pallet-parachain-template
use super::*;
#[allow(unused)]
use crate::Pallet as Template;
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_system::RawOrigin;
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,);
+26
View File
@@ -0,0 +1,26 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
title: Repot all templates
doc:
- audience: Runtime Dev
description: |
This PR moves all templates into a single folder in the polkadot-sdk repo (`/templates`) and
unifies their crate names as well. Most notably, the crate name for what was formerly known
as `node-template` is no `solochain-template-node`. The other two crates in the template are
consequently called: `solochain-runtime-template` and `pallet-solochain-template`.
The other two template crate names follow a similar patter, just replacing `solochain` with
`parachain` or `minimal`.
This PR is part of a bigger step toward automating the template repositories, see the
following: https://github.com/paritytech/polkadot-sdk/issues/3155
# the following crates are removed and renamed, although none are released.
crates:
- name: minimal-template-runtime # formerly called minimal-runtime
- name: minimal-template-node # formerly called minimal-node
- name: solochain-template-node # formerly called node-template
- name: solochain-template-runtime # formerly called node-template-runtime
- name: parachain-template-runtime # formerly called parachain-runtime
- name: parachain-template-runtime # formerly called parachain-node
-60
View File
@@ -1,60 +0,0 @@
[package]
name = "minimal-node"
version = "4.0.0-dev"
description = "A fresh FRAME-based Substrate node, ready for hacking."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io/"
edition = "2021"
license = "MIT-0"
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
build = "build.rs"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[[bin]]
name = "minimal-node"
[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
futures = { version = "0.3.21", features = ["thread-pool"] }
futures-timer = "3.0.1"
jsonrpsee = { version = "0.22", features = ["server"] }
serde_json = { workspace = true, default-features = true }
sc-cli = { path = "../../../client/cli" }
sc-executor = { path = "../../../client/executor" }
sc-network = { path = "../../../client/network" }
sc-service = { path = "../../../client/service" }
sc-telemetry = { path = "../../../client/telemetry" }
sc-transaction-pool = { path = "../../../client/transaction-pool" }
sc-transaction-pool-api = { path = "../../../client/transaction-pool/api" }
sc-consensus = { path = "../../../client/consensus/common" }
sc-consensus-manual-seal = { path = "../../../client/consensus/manual-seal" }
sc-rpc-api = { path = "../../../client/rpc-api" }
sc-basic-authorship = { path = "../../../client/basic-authorship" }
sc-offchain = { path = "../../../client/offchain" }
sc-client-api = { path = "../../../client/api" }
sp-timestamp = { path = "../../../primitives/timestamp" }
sp-keyring = { path = "../../../primitives/keyring" }
sp-api = { path = "../../../primitives/api" }
sp-blockchain = { path = "../../../primitives/blockchain" }
sp-block-builder = { path = "../../../primitives/block-builder" }
sp-io = { path = "../../../primitives/io" }
sp-runtime = { path = "../../../primitives/runtime" }
substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" }
frame = { path = "../../../frame", features = ["experimental", "runtime"] }
runtime = { package = "minimal-runtime", path = "../runtime" }
[build-dependencies]
substrate-build-script-utils = { path = "../../../utils/build-script-utils" }
[features]
default = []
-50
View File
@@ -1,50 +0,0 @@
[package]
name = "minimal-runtime"
version = "0.1.0"
authors.workspace = true
description = "A minimal Substrate example runtime"
edition.workspace = true
repository.workspace = true
license.workspace = true
publish = false
[lints]
workspace = true
[dependencies]
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 = { path = "../../../frame", default-features = false, features = ["experimental", "runtime"] }
frame-support = { path = "../../../frame/support", default-features = false }
# pallets that we want to use
pallet-balances = { path = "../../../frame/balances", default-features = false }
pallet-sudo = { path = "../../../frame/sudo", default-features = false }
pallet-timestamp = { path = "../../../frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../frame/transaction-payment/rpc/runtime-api", default-features = false }
# genesis builder that allows us to interacto with runtime genesis config
sp-genesis-builder = { path = "../../../primitives/genesis-builder", default-features = false }
[build-dependencies]
substrate-wasm-builder = { path = "../../../utils/wasm-builder", optional = true }
[features]
default = ["std"]
std = [
"frame-support/std",
"frame/std",
"pallet-balances/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"parity-scale-codec/std",
"scale-info/std",
"sp-genesis-builder/std",
"substrate-wasm-builder",
]
-16
View File
@@ -1,16 +0,0 @@
root = true
[*]
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
@@ -1 +0,0 @@
use flake
@@ -1,93 +0,0 @@
[package]
name = "node-template"
version = "4.0.0-dev"
description = "A fresh FRAME-based Substrate node, ready for hacking."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io/"
edition.workspace = true
license = "MIT-0"
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
build = "build.rs"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[[bin]]
name = "node-template"
[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
futures = { version = "0.3.21", features = ["thread-pool"] }
serde_json = { workspace = true, default-features = true }
sc-cli = { path = "../../../client/cli" }
sp-core = { path = "../../../primitives/core" }
sc-executor = { path = "../../../client/executor" }
sc-network = { path = "../../../client/network" }
sc-service = { path = "../../../client/service" }
sc-telemetry = { path = "../../../client/telemetry" }
sc-transaction-pool = { path = "../../../client/transaction-pool" }
sc-transaction-pool-api = { path = "../../../client/transaction-pool/api" }
sc-offchain = { path = "../../../client/offchain" }
sc-consensus-aura = { path = "../../../client/consensus/aura" }
sp-consensus-aura = { path = "../../../primitives/consensus/aura" }
sc-consensus = { path = "../../../client/consensus/common" }
sc-consensus-grandpa = { path = "../../../client/consensus/grandpa" }
sp-consensus-grandpa = { path = "../../../primitives/consensus/grandpa" }
sc-client-api = { path = "../../../client/api" }
sp-runtime = { path = "../../../primitives/runtime" }
sp-io = { path = "../../../primitives/io" }
sp-timestamp = { path = "../../../primitives/timestamp" }
sp-inherents = { path = "../../../primitives/inherents" }
sp-keyring = { path = "../../../primitives/keyring" }
frame-system = { path = "../../../frame/system" }
pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false }
# These dependencies are used for the node template's RPCs
jsonrpsee = { version = "0.22", features = ["server"] }
sp-api = { path = "../../../primitives/api" }
sc-rpc-api = { path = "../../../client/rpc-api" }
sp-blockchain = { path = "../../../primitives/blockchain" }
sp-block-builder = { path = "../../../primitives/block-builder" }
sc-basic-authorship = { path = "../../../client/basic-authorship" }
substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" }
pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc" }
# These dependencies are used for runtime benchmarking
frame-benchmarking = { path = "../../../frame/benchmarking" }
frame-benchmarking-cli = { path = "../../../utils/frame/benchmarking-cli" }
# Local Dependencies
node-template-runtime = { path = "../runtime" }
# CLI-specific dependencies
try-runtime-cli = { path = "../../../utils/frame/try-runtime/cli", optional = true }
[build-dependencies]
substrate-build-script-utils = { path = "../../../utils/build-script-utils" }
[features]
default = []
# Dependencies that are only required if runtime benchmarking should be build.
runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"node-template-runtime/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = [
"frame-system/try-runtime",
"node-template-runtime/try-runtime",
"pallet-transaction-payment/try-runtime",
"sp-runtime/try-runtime",
"try-runtime-cli/try-runtime",
]
@@ -1,126 +0,0 @@
[package]
name = "node-template-runtime"
version = "4.0.0-dev"
description = "A fresh FRAME-based Substrate node, ready for hacking."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io/"
edition.workspace = true
license = "MIT-0"
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] }
pallet-aura = { path = "../../../frame/aura", default-features = false }
pallet-balances = { path = "../../../frame/balances", default-features = false }
frame-support = { path = "../../../frame/support", default-features = false }
pallet-grandpa = { path = "../../../frame/grandpa", default-features = false }
pallet-sudo = { path = "../../../frame/sudo", default-features = false }
frame-system = { path = "../../../frame/system", default-features = false }
frame-try-runtime = { path = "../../../frame/try-runtime", default-features = false, optional = true }
pallet-timestamp = { path = "../../../frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false }
frame-executive = { path = "../../../frame/executive", default-features = false }
sp-api = { path = "../../../primitives/api", default-features = false }
sp-block-builder = { path = "../../../primitives/block-builder", default-features = false }
sp-consensus-aura = { path = "../../../primitives/consensus/aura", default-features = false, features = ["serde"] }
sp-consensus-grandpa = { path = "../../../primitives/consensus/grandpa", default-features = false, features = ["serde"] }
sp-core = { path = "../../../primitives/core", default-features = false, features = ["serde"] }
sp-inherents = { path = "../../../primitives/inherents", default-features = false }
sp-offchain = { path = "../../../primitives/offchain", default-features = false }
sp-runtime = { path = "../../../primitives/runtime", default-features = false, features = ["serde"] }
sp-session = { path = "../../../primitives/session", default-features = false }
sp-std = { path = "../../../primitives/std", default-features = false }
sp-storage = { path = "../../../primitives/storage", default-features = false }
sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false }
sp-version = { path = "../../../primitives/version", default-features = false, features = ["serde"] }
serde_json = { features = ["alloc"], workspace = true }
sp-genesis-builder = { default-features = false, path = "../../../primitives/genesis-builder" }
# Used for the node template's RPCs
frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../frame/transaction-payment/rpc/runtime-api", default-features = false }
# Used for runtime benchmarking
frame-benchmarking = { path = "../../../frame/benchmarking", default-features = false, optional = true }
frame-system-benchmarking = { path = "../../../frame/system/benchmarking", default-features = false, optional = true }
# Local Dependencies
pallet-template = { path = "../pallets/template", default-features = false }
[build-dependencies]
substrate-wasm-builder = { path = "../../../utils/wasm-builder", optional = true }
[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-executive/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime?/std",
"pallet-aura/std",
"pallet-balances/std",
"pallet-grandpa/std",
"pallet-sudo/std",
"pallet-template/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"scale-info/std",
"serde_json/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-storage/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-template/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-aura/try-runtime",
"pallet-balances/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-sudo/try-runtime",
"pallet-template/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"sp-runtime/try-runtime",
]
experimental = ["pallet-aura/experimental"]
+9 -4
View File
@@ -19,8 +19,12 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
# external deps
parity-scale-codec = { version = "3.2.2", default-features = false, features = ["derive"] }
scale-info = { version = "2.6.0", default-features = false, features = ["derive"] }
parity-scale-codec = { version = "3.2.2", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.6.0", default-features = false, features = [
"derive",
] }
# primitive deps, used for developing FRAME pallets.
sp-runtime = { default-features = false, path = "../primitives/runtime" }
@@ -57,8 +61,6 @@ pallet-examples = { path = "./examples" }
default = ["runtime", "std"]
experimental = ["frame-support/experimental"]
runtime = [
"frame-executive",
"frame-system-rpc-runtime-api",
"sp-api",
"sp-block-builder",
"sp-consensus-aura",
@@ -68,6 +70,9 @@ runtime = [
"sp-session",
"sp-transaction-pool",
"sp-version",
"frame-executive",
"frame-system-rpc-runtime-api",
]
std = [
"frame-executive?/std",
@@ -108,7 +108,7 @@ pub mod pallet {
}
/// A type providing default configurations for this pallet in another environment. Examples
/// could be a parachain, or a solo-chain.
/// could be a parachain, or a solochain.
///
/// Appropriate derive for `frame_system::DefaultConfig` needs to be provided. In this
/// example, we simple derive `frame_system::config_preludes::TestDefaultConfig` again.
+1 -1
View File
@@ -310,7 +310,7 @@ pub mod pallet {
type PostTransactions = ();
}
/// Default configurations of this pallet in a solo-chain environment.
/// Default configurations of this pallet in a solochain environment.
///
/// ## Considerations:
///
View File
+62
View File
@@ -0,0 +1,62 @@
[package]
name = "minimal-template-node"
description = "A miniaml Substrate-based Substrate node, ready for hacking."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
build = "build.rs"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
futures = { version = "0.3.21", features = ["thread-pool"] }
futures-timer = "3.0.1"
jsonrpsee = { version = "0.22", features = ["server"] }
serde_json = { workspace = true, default-features = true }
sc-cli = { path = "../../../substrate/client/cli" }
sc-executor = { path = "../../../substrate/client/executor" }
sc-network = { path = "../../../substrate/client/network" }
sc-service = { path = "../../../substrate/client/service" }
sc-telemetry = { path = "../../../substrate/client/telemetry" }
sc-transaction-pool = { path = "../../../substrate/client/transaction-pool" }
sc-transaction-pool-api = { path = "../../../substrate/client/transaction-pool/api" }
sc-consensus = { path = "../../../substrate/client/consensus/common" }
sc-consensus-manual-seal = { path = "../../../substrate/client/consensus/manual-seal" }
sc-rpc-api = { path = "../../../substrate/client/rpc-api" }
sc-basic-authorship = { path = "../../../substrate/client/basic-authorship" }
sc-offchain = { path = "../../../substrate/client/offchain" }
sc-client-api = { path = "../../../substrate/client/api" }
sp-timestamp = { path = "../../../substrate/primitives/timestamp" }
sp-keyring = { path = "../../../substrate/primitives/keyring" }
sp-api = { path = "../../../substrate/primitives/api" }
sp-blockchain = { path = "../../../substrate/primitives/blockchain" }
sp-block-builder = { path = "../../../substrate/primitives/block-builder" }
sp-io = { path = "../../../substrate/primitives/io" }
sp-runtime = { path = "../../../substrate/primitives/runtime" }
substrate-frame-rpc-system = { path = "../../../substrate/utils/frame/rpc/system" }
# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
# certainly no dependency on the runtime.
frame = { path = "../../../substrate/frame", features = [
"experimental",
"runtime",
] }
runtime = { package = "minimal-template-runtime", path = "../runtime" }
[build-dependencies]
substrate-build-script-utils = { path = "../../../substrate/utils/build-script-utils" }
[features]
default = []
@@ -1,4 +1,4 @@
// This file is part of Substrate.
// This file is part of Polkadot Sdk.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,33 @@
[package]
name = "pallet-minimal-template"
description = "A minimal pallet built with FRAME, part of Polkadot Sdk."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
], default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
frame = { path = "../../../../substrate/frame", default-features = false, features = [
"experimental",
"runtime",
] }
[features]
default = ["std"]
std = ["codec/std", "frame/std", "scale-info/std"]
@@ -0,0 +1,19 @@
//! A shell pallet built with [`frame`].
#![cfg_attr(not(feature = "std"), no_std)]
use frame::prelude::*;
// Re-export all pallet parts, this is needed to properly import the pallet into the runtime.
pub use pallet::*;
#[frame::pallet]
pub mod pallet {
use super::*;
#[pallet::config]
pub trait Config: frame_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
}
+59
View File
@@ -0,0 +1,59 @@
[package]
name = "minimal-template-runtime"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[lints]
workspace = true
[dependencies]
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 = { path = "../../../substrate/frame", default-features = false, features = [
"experimental",
"runtime",
] }
# pallets that we want to use
pallet-balances = { path = "../../../substrate/frame/balances", default-features = false }
pallet-sudo = { path = "../../../substrate/frame/sudo", default-features = false }
pallet-timestamp = { path = "../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
# genesis builder that allows us to interacto with runtime genesis config
sp-genesis-builder = { path = "../../../substrate/primitives/genesis-builder", default-features = false }
# local pallet templates
pallet-minimal-template = { path = "../pallets/template", default-features = false }
[build-dependencies]
substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder", optional = true }
[features]
default = ["std"]
std = [
"parity-scale-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",
"substrate-wasm-builder",
]
@@ -22,7 +22,10 @@
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use frame::{
deps::frame_support::weights::{FixedFee, NoFee},
deps::frame_support::{
genesis_builder_helper::{build_config, create_default_config},
weights::{FixedFee, NoFee},
},
prelude::*,
runtime::{
apis::{
@@ -32,12 +35,11 @@ use frame::{
prelude::*,
},
};
use frame_support::genesis_builder_helper::{build_config, create_default_config};
#[runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("minimal-runtime"),
impl_name: create_runtime_str!("minimal-runtime"),
spec_name: create_runtime_str!("minimal-template-runtime"),
impl_name: create_runtime_str!("minimal-template-runtime"),
authoring_version: 1,
spec_version: 0,
impl_version: 1,
@@ -71,6 +73,9 @@ construct_runtime!(
Balances: pallet_balances,
Sudo: pallet_sudo,
TransactionPayment: pallet_transaction_payment,
// our local pallet
Template: pallet_minimal_template,
}
);
@@ -104,6 +109,8 @@ impl pallet_transaction_payment::Config for Runtime {
type LengthToFee = FixedFee<1, <Self as pallet_balances::Config>::Balance>;
}
impl pallet_minimal_template::Config for Runtime {}
type Block = frame::runtime::types_common::BlockOf<Runtime, TxExtension>;
type Header = HeaderFor<Runtime>;
@@ -1,18 +1,21 @@
[package]
name = "parachain-template-node"
version = "0.1.0"
authors = ["Anonymous"]
description = "A new Cumulus FRAME-based Substrate Node, ready for hacking together a parachain."
license = "Unlicense"
homepage = "https://substrate.io"
description = "A parachain node template built with Substrate and Cumulus, part of Polkadot Sdk."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
build = "build.rs"
publish = false
build = "build.rs"
[lints]
workspace = true
# [[bin]]
# name = "parachain-template-node"
[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
log = { workspace = true, default-features = true }
@@ -63,15 +66,15 @@ polkadot-primitives = { path = "../../../polkadot/primitives" }
xcm = { package = "staging-xcm", path = "../../../polkadot/xcm", default-features = false }
# Cumulus
cumulus-client-cli = { path = "../../client/cli" }
cumulus-client-collator = { path = "../../client/collator" }
cumulus-client-consensus-aura = { path = "../../client/consensus/aura" }
cumulus-client-consensus-common = { path = "../../client/consensus/common" }
cumulus-client-consensus-proposer = { path = "../../client/consensus/proposer" }
cumulus-client-service = { path = "../../client/service" }
cumulus-primitives-core = { path = "../../primitives/core" }
cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inherent" }
cumulus-relay-chain-interface = { path = "../../client/relay-chain-interface" }
cumulus-client-cli = { path = "../../../cumulus/client/cli" }
cumulus-client-collator = { path = "../../../cumulus/client/collator" }
cumulus-client-consensus-aura = { path = "../../../cumulus/client/consensus/aura" }
cumulus-client-consensus-common = { path = "../../../cumulus/client/consensus/common" }
cumulus-client-consensus-proposer = { path = "../../../cumulus/client/consensus/proposer" }
cumulus-client-service = { path = "../../../cumulus/client/service" }
cumulus-primitives-core = { path = "../../../cumulus/primitives/core" }
cumulus-primitives-parachain-inherent = { path = "../../../cumulus/primitives/parachain-inherent" }
cumulus-relay-chain-interface = { path = "../../../cumulus/client/relay-chain-interface" }
color-print = "0.3.4"
[build-dependencies]
@@ -1,5 +1,6 @@
use cumulus_primitives_core::ParaId;
use parachain_template_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use parachain_template_runtime as runtime;
use runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
@@ -56,8 +57,8 @@ where
/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn template_session_keys(keys: AuraId) -> parachain_template_runtime::SessionKeys {
parachain_template_runtime::SessionKeys { aura: keys }
pub fn template_session_keys(keys: AuraId) -> runtime::SessionKeys {
runtime::SessionKeys { aura: keys }
}
pub fn development_config() -> ChainSpec {
@@ -68,8 +69,7 @@ pub fn development_config() -> ChainSpec {
properties.insert("ss58Format".into(), 42.into());
ChainSpec::builder(
parachain_template_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
@@ -120,8 +120,7 @@ pub fn local_testnet_config() -> ChainSpec {
#[allow(deprecated)]
ChainSpec::builder(
parachain_template_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
@@ -1,12 +1,13 @@
[package]
name = "pallet-parachain-template"
authors = ["Anonymous"]
description = "FRAME pallet template for defining custom runtime logic."
version = "0.7.0"
license = "Unlicense"
homepage = "https://substrate.io"
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[lints]
workspace = true
@@ -15,21 +16,22 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
# Substrate
# frame deps
frame-benchmarking = { path = "../../../../substrate/frame/benchmarking", default-features = false, optional = true }
frame-support = { path = "../../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../../substrate/frame/system", default-features = false }
[dev-dependencies]
serde = { workspace = true, default-features = true }
# Substrate
sp-core = { path = "../../../../substrate/primitives/core", default-features = false }
sp-io = { path = "../../../../substrate/primitives/io", default-features = false }
sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false }
sp-core = { path = "../../../../substrate/primitives/core" }
sp-io = { path = "../../../../substrate/primitives/io" }
sp-runtime = { path = "../../../../substrate/primitives/runtime" }
[features]
default = ["std"]
@@ -41,7 +43,7 @@ runtime-benchmarks = [
]
std = [
"codec/std",
"frame-benchmarking/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
@@ -11,6 +11,8 @@ mod mock;
#[cfg(test)]
mod tests;
pub mod weights;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
@@ -24,6 +26,8 @@ pub mod pallet {
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// A type representing the weights required by the dispatchables of this pallet.
type WeightInfo: crate::weights::WeightInfo;
}
#[pallet::pallet]
@@ -51,6 +51,7 @@ impl system::Config for Test {
impl crate::Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
}
// Build genesis storage according to the mock runtime.
@@ -1,12 +1,13 @@
[package]
name = "parachain-template-runtime"
version = "0.7.0"
authors = ["Anonymous"]
description = "A new Cumulus FRAME-based Substrate Runtime, ready for hacking together a parachain."
license = "Unlicense"
homepage = "https://substrate.io"
description = "A parachain runtime template built with Substrate and Cumulus, part of Polkadot Sdk."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[lints]
workspace = true
@@ -18,16 +19,20 @@ targets = ["x86_64-unknown-linux-gnu"]
substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder", optional = true }
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
] }
hex-literal = { version = "0.4.1", optional = true }
log = { workspace = true }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
smallvec = "1.11.0"
# Local
pallet-parachain-template = { path = "../pallets/template", default-features = false }
# Substrate
# Substrate / FRAME
frame-benchmarking = { path = "../../../substrate/frame/benchmarking", default-features = false, optional = true }
frame-executive = { path = "../../../substrate/frame/executive", default-features = false }
frame-support = { path = "../../../substrate/frame/support", default-features = false }
@@ -35,6 +40,8 @@ frame-system = { path = "../../../substrate/frame/system", default-features = fa
frame-system-benchmarking = { path = "../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
frame-system-rpc-runtime-api = { path = "../../../substrate/frame/system/rpc/runtime-api", default-features = false }
frame-try-runtime = { path = "../../../substrate/frame/try-runtime", default-features = false, optional = true }
# FRAME Pallets
pallet-aura = { path = "../../../substrate/frame/aura", default-features = false }
pallet-authorship = { path = "../../../substrate/frame/authorship", default-features = false }
pallet-balances = { path = "../../../substrate/frame/balances", default-features = false }
@@ -44,6 +51,8 @@ pallet-sudo = { path = "../../../substrate/frame/sudo", default-features = false
pallet-timestamp = { path = "../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
# Substrate Primitives
sp-api = { path = "../../../substrate/primitives/api", default-features = false }
sp-block-builder = { path = "../../../substrate/primitives/block-builder", default-features = false }
sp-consensus-aura = { path = "../../../substrate/primitives/consensus/aura", default-features = false }
@@ -66,17 +75,19 @@ xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/x
xcm-executor = { package = "staging-xcm-executor", path = "../../../polkadot/xcm/xcm-executor", default-features = false }
# Cumulus
cumulus-pallet-aura-ext = { path = "../../pallets/aura-ext", default-features = false }
cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook"] }
cumulus-pallet-session-benchmarking = { path = "../../pallets/session-benchmarking", default-features = false }
cumulus-pallet-xcm = { path = "../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../pallets/xcmp-queue", default-features = false }
cumulus-primitives-core = { path = "../../primitives/core", default-features = false }
cumulus-primitives-utility = { path = "../../primitives/utility", default-features = false }
cumulus-primitives-storage-weight-reclaim = { path = "../../primitives/storage-weight-reclaim", default-features = false }
pallet-collator-selection = { path = "../../pallets/collator-selection", default-features = false }
parachains-common = { path = "../../parachains/common", default-features = false }
parachain-info = { package = "staging-parachain-info", path = "../../parachains/pallets/parachain-info", default-features = false }
cumulus-pallet-aura-ext = { path = "../../../cumulus/pallets/aura-ext", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../cumulus/pallets/parachain-system", default-features = false, features = [
"parameterized-consensus-hook",
] }
cumulus-pallet-session-benchmarking = { path = "../../../cumulus/pallets/session-benchmarking", default-features = false }
cumulus-pallet-xcm = { path = "../../../cumulus/pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../cumulus/pallets/xcmp-queue", default-features = false }
cumulus-primitives-core = { path = "../../../cumulus/primitives/core", default-features = false }
cumulus-primitives-utility = { path = "../../../cumulus/primitives/utility", default-features = false }
cumulus-primitives-storage-weight-reclaim = { path = "../../../cumulus/primitives/storage-weight-reclaim", default-features = false }
pallet-collator-selection = { path = "../../../cumulus/pallets/collator-selection", default-features = false }
parachains-common = { path = "../../../cumulus/parachains/common", default-features = false }
parachain-info = { package = "staging-parachain-info", path = "../../../cumulus/parachains/pallets/parachain-info", default-features = false }
[features]
default = ["std"]
@@ -180,8 +180,8 @@ impl_opaque_keys! {
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("template-parachain"),
impl_name: create_runtime_str!("template-parachain"),
spec_name: create_runtime_str!("parachain-template-runtime"),
impl_name: create_runtime_str!("parachain-template-runtime"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
@@ -490,6 +490,7 @@ impl pallet_collator_selection::Config for Runtime {
/// Configure the pallet template in pallets/template.
impl pallet_parachain_template::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_parachain_template::weights::SubstrateWeight<Runtime>;
}
// Create the runtime by composing the FRAME pallets that were previously configured.
+92
View File
@@ -0,0 +1,92 @@
[package]
name = "solochain-template-node"
description = "A solochain node template built with Substrate, part of Polkadot Sdk."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
build = "build.rs"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
futures = { version = "0.3.21", features = ["thread-pool"] }
serde_json = { workspace = true, default-features = true }
jsonrpsee = { version = "0.22", features = ["server"] }
# substrate client
sc-cli = { path = "../../../substrate/client/cli" }
sp-core = { path = "../../../substrate/primitives/core" }
sc-executor = { path = "../../../substrate/client/executor" }
sc-network = { path = "../../../substrate/client/network" }
sc-service = { path = "../../../substrate/client/service" }
sc-telemetry = { path = "../../../substrate/client/telemetry" }
sc-transaction-pool = { path = "../../../substrate/client/transaction-pool" }
sc-transaction-pool-api = { path = "../../../substrate/client/transaction-pool/api" }
sc-offchain = { path = "../../../substrate/client/offchain" }
sc-consensus-aura = { path = "../../../substrate/client/consensus/aura" }
sp-consensus-aura = { path = "../../../substrate/primitives/consensus/aura" }
sc-consensus = { path = "../../../substrate/client/consensus/common" }
sc-consensus-grandpa = { path = "../../../substrate/client/consensus/grandpa" }
sp-consensus-grandpa = { path = "../../../substrate/primitives/consensus/grandpa" }
sc-client-api = { path = "../../../substrate/client/api" }
sc-rpc-api = { path = "../../../substrate/client/rpc-api" }
sc-basic-authorship = { path = "../../../substrate/client/basic-authorship" }
# substrate primitives
sp-runtime = { path = "../../../substrate/primitives/runtime" }
sp-io = { path = "../../../substrate/primitives/io" }
sp-timestamp = { path = "../../../substrate/primitives/timestamp" }
sp-inherents = { path = "../../../substrate/primitives/inherents" }
sp-keyring = { path = "../../../substrate/primitives/keyring" }
sp-api = { path = "../../../substrate/primitives/api" }
sp-blockchain = { path = "../../../substrate/primitives/blockchain" }
sp-block-builder = { path = "../../../substrate/primitives/block-builder" }
# frame and pallets
frame-system = { path = "../../../substrate/frame/system" }
pallet-transaction-payment = { path = "../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc = { path = "../../../substrate/frame/transaction-payment/rpc" }
substrate-frame-rpc-system = { path = "../../../substrate/utils/frame/rpc/system" }
# These dependencies are used for runtime benchmarking
frame-benchmarking-cli = { path = "../../../substrate/utils/frame/benchmarking-cli" }
# Local Dependencies
solochain-template-runtime = { path = "../runtime" }
# CLI-specific dependencies
try-runtime-cli = { path = "../../../substrate/utils/frame/try-runtime/cli", optional = true }
[build-dependencies]
substrate-build-script-utils = { path = "../../../substrate/utils/build-script-utils" }
[features]
default = []
# Dependencies that are only required if runtime benchmarking should be build.
runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"solochain-template-runtime/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = [
"frame-system/try-runtime",
"pallet-transaction-payment/try-runtime",
"solochain-template-runtime/try-runtime",
"sp-runtime/try-runtime",
"try-runtime-cli/try-runtime",
]
@@ -4,10 +4,10 @@
use crate::service::FullClient;
use node_template_runtime as runtime;
use runtime::{AccountId, Balance, BalancesCall, SystemCall};
use sc_cli::Result;
use sc_client_api::BlockBackend;
use solochain_template_runtime as runtime;
use sp_core::{Encode, Pair};
use sp_inherents::{InherentData, InherentDataProvider};
use sp_keyring::Sr25519Keyring;
@@ -1,5 +1,5 @@
use node_template_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY};
use sc_service::ChainType;
use solochain_template_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, Pair, Public};
@@ -5,9 +5,9 @@ use crate::{
service,
};
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
use node_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;
use solochain_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
use sp_keyring::Sr25519Keyring;
impl SubstrateCli for Cli {
@@ -8,8 +8,8 @@
use std::sync::Arc;
use jsonrpsee::RpcModule;
use node_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
use sc_transaction_pool_api::TransactionPool;
use solochain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
@@ -1,13 +1,13 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use futures::FutureExt;
use node_template_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::{Backend, BlockBackend};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_grandpa::SharedVoterState;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use solochain_template_runtime::{self, opaque::Block, RuntimeApi};
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use std::{sync::Arc, time::Duration};
@@ -1,13 +1,13 @@
[package]
name = "pallet-template"
version = "4.0.0-dev"
description = "FRAME pallet template for defining custom runtime logic."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io"
edition.workspace = true
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
[lints]
workspace = true
@@ -19,16 +19,19 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
frame-benchmarking = { path = "../../../../frame/benchmarking", default-features = false, optional = true }
frame-support = { path = "../../../../frame/support", default-features = false }
frame-system = { path = "../../../../frame/system", default-features = false }
sp-std = { path = "../../../../primitives/std", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
# frame deps
frame-benchmarking = { path = "../../../../substrate/frame/benchmarking", default-features = false, optional = true }
frame-support = { path = "../../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../../substrate/frame/system", default-features = false }
[dev-dependencies]
sp-core = { path = "../../../../primitives/core" }
sp-io = { path = "../../../../primitives/io" }
sp-runtime = { path = "../../../../primitives/runtime" }
sp-core = { path = "../../../../substrate/primitives/core" }
sp-io = { path = "../../../../substrate/primitives/io" }
sp-runtime = { path = "../../../../substrate/primitives/runtime" }
[features]
default = ["std"]
@@ -41,7 +44,6 @@ std = [
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
@@ -0,0 +1 @@
License: MIT-0
@@ -0,0 +1,35 @@
//! Benchmarking setup for pallet-template
#![cfg(feature = "runtime-benchmarks")]
use super::*;
#[allow(unused)]
use crate::Pallet as Template;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
#[benchmarks]
mod benchmarks {
use super::*;
#[benchmark]
fn do_something() {
let value = 100u32.into();
let caller: T::AccountId = whitelisted_caller();
#[extrinsic_call]
do_something(RawOrigin::Signed(caller), value);
assert_eq!(Something::<T>::get(), Some(value));
}
#[benchmark]
fn cause_error() {
Something::<T>::put(100u32);
let caller: T::AccountId = whitelisted_caller();
#[extrinsic_call]
cause_error(RawOrigin::Signed(caller));
assert_eq!(Something::<T>::get(), Some(101u32));
}
impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test);
}
@@ -0,0 +1,90 @@
//! Autogenerated weights for pallet_template
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `<UNKNOWN>`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ../../target/release/node-template
// benchmark
// pallet
// --chain
// dev
// --pallet
// pallet_template
// --extrinsic
// *
// --steps=50
// --repeat=20
// --wasm-execution=compiled
// --output
// pallets/template/src/weights.rs
// --template
// ../../.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weight functions needed for pallet_template.
pub trait WeightInfo {
fn do_something() -> Weight;
fn cause_error() -> Weight;
}
/// Weights for pallet_template using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Storage: TemplateModule Something (r:0 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn do_something() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_000_000 picoseconds.
Weight::from_parts(9_000_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: TemplateModule Something (r:1 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn cause_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1489`
// Minimum execution time: 6_000_000 picoseconds.
Weight::from_parts(6_000_000, 1489)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
/// Storage: TemplateModule Something (r:0 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn do_something() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_000_000 picoseconds.
Weight::from_parts(9_000_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: TemplateModule Something (r:1 w:1)
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
fn cause_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `32`
// Estimated: `1489`
// Minimum execution time: 6_000_000 picoseconds.
Weight::from_parts(6_000_000, 1489)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
+152
View File
@@ -0,0 +1,152 @@
[package]
name = "solochain-template-runtime"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk."
version = "0.0.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
publish = false
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
"derive",
] }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
"serde",
] }
# frame
frame-support = { path = "../../../substrate/frame/support", default-features = false }
frame-system = { path = "../../../substrate/frame/system", default-features = false }
frame-try-runtime = { path = "../../../substrate/frame/try-runtime", default-features = false, optional = true }
frame-executive = { path = "../../../substrate/frame/executive", default-features = false }
# frame pallets
pallet-aura = { path = "../../../substrate/frame/aura", default-features = false }
pallet-balances = { path = "../../../substrate/frame/balances", default-features = false }
pallet-grandpa = { path = "../../../substrate/frame/grandpa", default-features = false }
pallet-sudo = { path = "../../../substrate/frame/sudo", default-features = false }
pallet-timestamp = { path = "../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../substrate/frame/transaction-payment", default-features = false }
# primitives
sp-api = { path = "../../../substrate/primitives/api", default-features = false }
sp-block-builder = { path = "../../../substrate/primitives/block-builder", default-features = false }
sp-consensus-aura = { path = "../../../substrate/primitives/consensus/aura", default-features = false, features = [
"serde",
] }
sp-consensus-grandpa = { path = "../../../substrate/primitives/consensus/grandpa", default-features = false, features = [
"serde",
] }
sp-core = { path = "../../../substrate/primitives/core", default-features = false, features = [
"serde",
] }
sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false }
sp-offchain = { path = "../../../substrate/primitives/offchain", default-features = false }
sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false, features = [
"serde",
] }
sp-session = { path = "../../../substrate/primitives/session", default-features = false }
sp-std = { path = "../../../substrate/primitives/std", default-features = false }
sp-storage = { path = "../../../substrate/primitives/storage", default-features = false }
sp-transaction-pool = { path = "../../../substrate/primitives/transaction-pool", default-features = false }
sp-version = { path = "../../../substrate/primitives/version", default-features = false, features = [
"serde",
] }
sp-genesis-builder = { default-features = false, path = "../../../substrate/primitives/genesis-builder" }
# RPC related
frame-system-rpc-runtime-api = { path = "../../../substrate/frame/system/rpc/runtime-api", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
# Used for runtime benchmarking
frame-benchmarking = { path = "../../../substrate/frame/benchmarking", default-features = false, optional = true }
frame-system-benchmarking = { path = "../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
# The pallet in this template.
pallet-template = { path = "../pallets/template", default-features = false }
[build-dependencies]
substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder", optional = true }
[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"frame-executive/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-benchmarking?/std",
"frame-try-runtime?/std",
"pallet-aura/std",
"pallet-balances/std",
"pallet-grandpa/std",
"pallet-sudo/std",
"pallet-template/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-storage/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-template/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-aura/try-runtime",
"pallet-balances/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-sudo/try-runtime",
"pallet-template/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"sp-runtime/try-runtime",
]
experimental = ["pallet-aura/experimental"]
@@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
@@ -22,7 +19,6 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use frame_support::genesis_builder_helper::{build_config, create_default_config};
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, derive_impl, parameter_types,
traits::{
@@ -95,8 +91,8 @@ pub mod opaque {
// https://docs.substrate.io/main-docs/build/upgrade#runtime-versioning
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node-template"),
impl_name: create_runtime_str!("node-template"),
spec_name: create_runtime_str!("solochain-template-runtime"),
impl_name: create_runtime_str!("solochain-template-runtime"),
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`,
@@ -266,6 +262,7 @@ construct_runtime!(
Balances: pallet_balances,
TransactionPayment: pallet_transaction_payment,
Sudo: pallet_sudo,
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template,
}