mirror of
https://github.com/pezkuwichain/pez-minimal-template.git
synced 2026-05-30 04:11:05 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c51346d98 | |||
| 10de7b33cb | |||
| a62d6d31eb | |||
| 3f74c0485e | |||
| 2d91027ab6 | |||
| b6770d6a5f | |||
| 419eb3efda | |||
| d31ced7974 | |||
| 331e79d33f | |||
| 7f8d3d018c | |||
| 1f38756e28 | |||
| b56b85e852 | |||
| 7b2ebf016f | |||
| 33067c2c1f | |||
| a5e12feede | |||
| 4c84ccd239 | |||
| 106c604993 | |||
| 670c29ab86 | |||
| 4b900d3081 | |||
| 722657deda | |||
| 5718deb606 | |||
| 8ad0586c25 | |||
| a150b7ee98 | |||
| 78fbe0b4c3 | |||
| 85e9f2d04b | |||
| 888d8eb81a | |||
| ce9fbe59b7 | |||
| 91e66fc7ea | |||
| 9b47a47b3a | |||
| 6b4829dd6c | |||
| a24d479c6d | |||
| 88063f9dbc | |||
| a9c96aa201 |
@@ -1 +0,0 @@
|
|||||||
./ubuntu-prerequisites.sh
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/env sh
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y curl git protobuf-compiler build-essential libclang-15-dev
|
|
||||||
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
||||||
. "$HOME/.cargo/env"
|
|
||||||
+54
-24
@@ -6,30 +6,41 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
- rzadp/prerequisites
|
- rzadp/test-produce-blocks
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
matrix:
|
||||||
container:
|
os: [ubuntu-latest, macos-latest]
|
||||||
- "ubuntu:22.04"
|
|
||||||
- "ubuntu:latest"
|
|
||||||
- "debian:latest"
|
|
||||||
container: ${{ matrix.container }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Run the prerequisites script
|
- name: Rust compilation prerequisites (Ubuntu)
|
||||||
|
if: contains(matrix.os, 'ubuntu')
|
||||||
run: |
|
run: |
|
||||||
DIST="$(echo "${{ matrix.container }}" | cut -d':' -f1)"
|
sudo apt update
|
||||||
sh ./.github/scripts/${DIST}-prerequisites.sh
|
sudo apt install -y \
|
||||||
|
protobuf-compiler
|
||||||
|
rustup target add wasm32-unknown-unknown
|
||||||
|
rustup component add rustfmt clippy rust-src
|
||||||
|
|
||||||
|
- name: Install Cargo (MacOS)
|
||||||
|
if: contains(matrix.os, 'macos')
|
||||||
|
run: |
|
||||||
|
curl https://sh.rustup.rs -sSf -y | sh
|
||||||
|
brew install protobuf
|
||||||
|
rustup target add wasm32-unknown-unknown --toolchain stable-aarch64-apple-darwin
|
||||||
|
rustup component add rust-src --toolchain stable-aarch64-apple-darwin
|
||||||
|
|
||||||
# We've run into out-of-disk error when compiling Polkadot in the next step, so we free up some space this way.
|
# We've run into out-of-disk error when compiling Polkadot in the next step, so we free up some space this way.
|
||||||
- name: Free Disk Space (Ubuntu)
|
- name: Free Disk Space (Ubuntu)
|
||||||
|
if: contains(matrix.os, 'ubuntu')
|
||||||
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # 1.3.1
|
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # 1.3.1
|
||||||
with:
|
with:
|
||||||
android: true # This alone is a 12 GB save.
|
android: true # This alone is a 12 GB save.
|
||||||
@@ -40,20 +51,39 @@ jobs:
|
|||||||
large-packages: false
|
large-packages: false
|
||||||
swap-storage: false
|
swap-storage: false
|
||||||
|
|
||||||
- name: Build the template
|
# This is mentioned as example in the README:
|
||||||
run: /github/home/.cargo/bin/cargo build
|
- name: Build the node individually in release mode
|
||||||
|
run: |
|
||||||
|
# Save some space from debug builds
|
||||||
|
rm -rf ./target
|
||||||
|
cargo build --package minimal-template-node --release
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Make sure the node is producing blocks
|
||||||
run: |
|
run: |
|
||||||
SKIP_WASM_BUILD=1 /github/home/.cargo/bin/cargo clippy --all-targets --locked --workspace --quiet
|
./target/release/minimal-template-node --dev 2>&1 | tee out.txt &
|
||||||
SKIP_WASM_BUILD=1 /github/home/.cargo/bin/cargo clippy --all-targets --all-features --locked --workspace --quiet
|
until curl -s '127.0.0.1:9944'; do sleep 5; done
|
||||||
timeout-minutes: 30
|
until cat out.txt | grep -s "Imported #2"; do sleep 5; done
|
||||||
|
shell: bash
|
||||||
|
timeout-minutes: 5
|
||||||
|
|
||||||
- name: Run the tests
|
# build-docker:
|
||||||
run: /github/home/.cargo/bin/cargo test
|
# runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
# steps:
|
||||||
|
# - uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build the docs
|
# # We've run into out-of-disk error when compiling Polkadot in the next step, so we free up some space this way.
|
||||||
run: /github/home/.cargo/bin/cargo doc --all-features --workspace --no-deps
|
# - name: Free Disk Space (Ubuntu)
|
||||||
timeout-minutes: 15
|
# uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # 1.3.1
|
||||||
|
# with:
|
||||||
|
# android: true # This alone is a 12 GB save.
|
||||||
|
# # We disable the rest because it caused some problems. (they're enabled by default)
|
||||||
|
# # The Android removal is enough.
|
||||||
|
# dotnet: false
|
||||||
|
# haskell: false
|
||||||
|
# large-packages: false
|
||||||
|
# swap-storage: false
|
||||||
|
|
||||||
|
# - name: Build the Dockerfile
|
||||||
|
# run: docker build . -t polkadot-sdk-minimal-template
|
||||||
|
# timeout-minutes: 90
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
name: PR Reminder
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pr-reminder:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Comment a reminder on a new PR
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.issues.createComment({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: 'Hello, this is an automatic reminder that any code changes should be made to [the source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/minimal).'
|
||||||
|
})
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# We've run into out-of-disk error when compiling Polkadot in the next step, so we free up some space this way.
|
||||||
|
- name: Free Disk Space (Ubuntu)
|
||||||
|
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # 1.3.1
|
||||||
|
with:
|
||||||
|
android: true # This alone is a 12 GB save.
|
||||||
|
# We disable the rest because it caused some problems. (they're enabled by default)
|
||||||
|
# The Android removal is enough.
|
||||||
|
dotnet: false
|
||||||
|
haskell: false
|
||||||
|
large-packages: false
|
||||||
|
swap-storage: false
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
|
||||||
|
|
||||||
|
release-binaries:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Rust compilation prerequisites
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y \
|
||||||
|
protobuf-compiler
|
||||||
|
rustup target add wasm32-unknown-unknown
|
||||||
|
rustup component add rust-src
|
||||||
|
|
||||||
|
- name: Build the template
|
||||||
|
run: cargo build --locked --release
|
||||||
|
timeout-minutes: 90
|
||||||
|
|
||||||
|
- name: Upload the binaries
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
target/release/minimal-template-node
|
||||||
|
target/release/wbuild/minimal-template-runtime/minimal_template_runtime.compact.compressed.wasm
|
||||||
Generated
+1310
-1148
File diff suppressed because it is too large
Load Diff
+40
-42
@@ -1,7 +1,7 @@
|
|||||||
[workspace.package]
|
[workspace.package]
|
||||||
license = "MIT-0"
|
license = "MIT-0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
homepage = "https://substrate.io"
|
homepage = "https://paritytech.github.io/polkadot-sdk/"
|
||||||
repository = "https://github.com/paritytech/polkadot-sdk-minimal-template.git"
|
repository = "https://github.com/paritytech/polkadot-sdk-minimal-template.git"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -13,46 +13,44 @@ members = [
|
|||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.lints.rust]
|
|
||||||
suspicious_double_ref_op = { level = "allow", priority = 2 }
|
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
|
||||||
all = { level = "allow", priority = 0 }
|
|
||||||
correctness = { level = "warn", priority = 1 }
|
|
||||||
complexity = { level = "warn", priority = 1 }
|
|
||||||
if-same-then-else = { level = "allow", priority = 2 }
|
|
||||||
zero-prefixed-literal = { level = "allow", priority = 2 } # 00_1000_000
|
|
||||||
type_complexity = { level = "allow", priority = 2 } # raison d'etre
|
|
||||||
nonminimal-bool = { level = "allow", priority = 2 } # maybe
|
|
||||||
borrowed-box = { level = "allow", priority = 2 } # Reasonable to fix this one
|
|
||||||
too-many-arguments = { level = "allow", priority = 2 } # (Turning this on would lead to)
|
|
||||||
needless-lifetimes = { level = "allow", priority = 2 } # generated code
|
|
||||||
unnecessary_cast = { level = "allow", priority = 2 } # Types may change
|
|
||||||
identity-op = { level = "allow", priority = 2 } # One case where we do 0 +
|
|
||||||
useless_conversion = { level = "allow", priority = 2 } # Types may change
|
|
||||||
unit_arg = { level = "allow", priority = 2 } # stylistic
|
|
||||||
option-map-unit-fn = { level = "allow", priority = 2 } # stylistic
|
|
||||||
bind_instead_of_map = { level = "allow", priority = 2 } # stylistic
|
|
||||||
erasing_op = { level = "allow", priority = 2 } # E.g. 0 * DOLLARS
|
|
||||||
eq_op = { level = "allow", priority = 2 } # In tests we test equality.
|
|
||||||
while_immutable_condition = { level = "allow", priority = 2 } # false positives
|
|
||||||
needless_option_as_deref = { level = "allow", priority = 2 } # false positives
|
|
||||||
derivable_impls = { level = "allow", priority = 2 } # false positives
|
|
||||||
stable_sort_primitive = { level = "allow", priority = 2 } # prefer stable sort
|
|
||||||
extra-unused-type-parameters = { level = "allow", priority = 2 } # stylistic
|
|
||||||
default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic
|
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
polkavm = "0.9.3"
|
minimal-template-runtime = { path = "./runtime", default-features = false }
|
||||||
polkavm-linker = "0.9.2"
|
pallet-minimal-template = { path = "./pallets/template", default-features = false }
|
||||||
polkavm-derive = "0.9.1"
|
clap = { version = "4.5.3" }
|
||||||
log = { version = "0.4.21", default-features = false }
|
docify = { version = "0.2.8" }
|
||||||
quote = { version = "1.0.33" }
|
frame = { version = "0.6.0", default-features = false, package = "polkadot-sdk-frame" }
|
||||||
serde = { version = "1.0.197", default-features = false }
|
futures = { version = "0.3.30" }
|
||||||
serde-big-array = { version = "0.3.2" }
|
futures-timer = { version = "3.0.2" }
|
||||||
serde_derive = { version = "1.0.117" }
|
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 }
|
serde_json = { version = "1.0.114", default-features = false }
|
||||||
serde_yaml = { version = "0.9" }
|
sp-api = { version = "34.0.0", default-features = false }
|
||||||
syn = { version = "2.0.53" }
|
sp-block-builder = { version = "34.0.0", default-features = false }
|
||||||
thiserror = { version = "1.0.48" }
|
sp-blockchain = { version = "37.0.0", default-features = false }
|
||||||
tracing-subscriber = { version = "0.3.18" }
|
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 }
|
||||||
|
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 }
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
FROM docker.io/paritytech/ci-unified:latest as builder
|
||||||
|
|
||||||
|
WORKDIR /polkadot
|
||||||
|
COPY . /polkadot
|
||||||
|
|
||||||
|
RUN cargo fetch
|
||||||
|
RUN cargo build --locked --release
|
||||||
|
|
||||||
|
FROM docker.io/parity/base-bin:latest
|
||||||
|
|
||||||
|
COPY --from=builder /polkadot/target/release/minimal-template-node /usr/local/bin
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN useradd -m -u 1001 -U -s /bin/sh -d /polkadot polkadot && \
|
||||||
|
mkdir -p /data /polkadot/.local/share && \
|
||||||
|
chown -R polkadot:polkadot /data && \
|
||||||
|
ln -s /data /polkadot/.local/share/polkadot && \
|
||||||
|
# unclutter and minimize the attack surface
|
||||||
|
rm -rf /usr/bin /usr/sbin && \
|
||||||
|
# check if executable works in this container
|
||||||
|
/usr/local/bin/minimal-template-node --version
|
||||||
|
|
||||||
|
USER polkadot
|
||||||
|
|
||||||
|
EXPOSE 30333 9933 9944 9615
|
||||||
|
VOLUME ["/data"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/minimal-template-node"]
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <http://unlicense.org>
|
||||||
@@ -1,13 +1,101 @@
|
|||||||
# Minimal Template
|
<div align="center">
|
||||||
|
|
||||||
This is a minimal template for creating a blockchain using the Polkadot SDK.
|
# Polkadot SDK's Minimal Template
|
||||||
|
|
||||||
# Docs
|
<img height="70px" alt="Polkadot SDK Logo" src="https://github.com/paritytech/polkadot-sdk/raw/master/docs/images/Polkadot_Logo_Horizontal_Pink_White.png#gh-dark-mode-only"/>
|
||||||
|
<img height="70px" alt="Polkadot SDK Logo" src="https://github.com/paritytech/polkadot-sdk/raw/master/docs/images/Polkadot_Logo_Horizontal_Pink_Black.png#gh-light-mode-only"/>
|
||||||
|
|
||||||
You can generate and view the [Rust
|
> This is a minimal template for creating a blockchain based on Polkadot SDK.
|
||||||
Docs](https://doc.rust-lang.org/cargo/commands/cargo-doc.html) for this template
|
>
|
||||||
with this command:
|
> This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
* 🤏 This template is a minimal (in terms of complexity and the number of components)
|
||||||
|
template for building a blockchain node.
|
||||||
|
|
||||||
|
* 🔧 Its runtime is configured with a single custom pallet as a starting point, and a handful of ready-made pallets
|
||||||
|
such as a [Balances pallet](https://paritytech.github.io/polkadot-sdk/master/pallet_balances/index.html).
|
||||||
|
|
||||||
|
* 👤 The template has no consensus configured - it is best for experimenting with a single node network.
|
||||||
|
|
||||||
|
## Template Structure
|
||||||
|
|
||||||
|
A Polkadot SDK based project such as this one consists of:
|
||||||
|
|
||||||
|
* 💿 a [Node](./node/README.md) - the binary application.
|
||||||
|
* 🧮 the [Runtime](./runtime/README.md) - the core logic of the blockchain.
|
||||||
|
* 🎨 the [Pallets](./pallets/README.md) - from which the runtime is constructed.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
* 🦀 The template is using the Rust language.
|
||||||
|
|
||||||
|
* 👉 Check the
|
||||||
|
[Rust installation instructions](https://www.rust-lang.org/tools/install) for your system.
|
||||||
|
|
||||||
|
* 🛠️ Depending on your operating system and Rust version, there might be additional
|
||||||
|
packages required to compile this template - please take note of the Rust compiler output.
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
🔨 Use the following command to build the node without launching it:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo doc -p minimal-template --open
|
cargo build --package minimal-template-node --release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
🐳 Alternatively, build the docker image:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build . -t polkadot-sdk-minimal-template
|
||||||
|
```
|
||||||
|
|
||||||
|
### Single-Node Development Chain
|
||||||
|
|
||||||
|
👤 The following command starts a single-node development chain:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./target/release/minimal-template-node --dev
|
||||||
|
|
||||||
|
# docker version:
|
||||||
|
docker run --rm polkadot-sdk-minimal-template --dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Development chains:
|
||||||
|
|
||||||
|
* 🧹 Do not persist the state.
|
||||||
|
* 💰 Are pre-configured with a genesis state that includes several pre-funded development accounts.
|
||||||
|
* 🧑⚖️ One development account (`ALICE`) is used as `sudo` accounts.
|
||||||
|
|
||||||
|
### Connect with the Polkadot-JS Apps Front-End
|
||||||
|
|
||||||
|
* 🌐 You can interact with your local node using the
|
||||||
|
hosted version of the [Polkadot/Substrate
|
||||||
|
Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944).
|
||||||
|
|
||||||
|
* 🪐 A hosted version is also
|
||||||
|
available on [IPFS](https://dotapps.io/).
|
||||||
|
|
||||||
|
* 🧑🔧 You can also find the source code and instructions for hosting your own instance in the
|
||||||
|
[`polkadot-js/apps`](https://github.com/polkadot-js/apps) repository.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
* 🔄 This template is automatically updated after releases in the main [Polkadot SDK monorepo](https://github.com/paritytech/polkadot-sdk).
|
||||||
|
|
||||||
|
* ➡️ Any pull requests should be directed to this [source](https://github.com/paritytech/polkadot-sdk/tree/master/templates/minimal).
|
||||||
|
|
||||||
|
* 😇 Please refer to the monorepo's
|
||||||
|
[contribution guidelines](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md) and
|
||||||
|
[Code of Conduct](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CODE_OF_CONDUCT.md).
|
||||||
|
|
||||||
|
## Getting Help
|
||||||
|
|
||||||
|
* 🧑🏫 To learn about Polkadot in general, [Polkadot.network](https://polkadot.network/) website is a good starting point.
|
||||||
|
|
||||||
|
* 🧑🔧 For technical introduction, [here](https://github.com/paritytech/polkadot-sdk#-documentation) are
|
||||||
|
the Polkadot SDK documentation resources.
|
||||||
|
|
||||||
|
* 👥 Additionally, there are [GitHub issues](https://github.com/paritytech/polkadot-sdk/issues) and
|
||||||
|
[Substrate StackExchange](https://substrate.stackexchange.com/).
|
||||||
|
|||||||
+57
-37
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "minimal-template-node"
|
name = "minimal-template-node"
|
||||||
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.12.0)"
|
description = "A minimal Substrate-based Substrate node, ready for hacking. (polkadot v1.15.0)"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
license = "MIT-0"
|
license = "Unlicense"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@@ -10,47 +10,67 @@ edition.workspace = true
|
|||||||
publish = false
|
publish = false
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.3", features = ["derive"] }
|
docify = { workspace = true }
|
||||||
futures = { version = "0.3.30", features = ["thread-pool"] }
|
clap = { features = ["derive"], workspace = true }
|
||||||
futures-timer = "3.0.1"
|
futures = { features = ["thread-pool"], workspace = true }
|
||||||
jsonrpsee = { version = "0.22", features = ["server"] }
|
futures-timer = { workspace = true }
|
||||||
|
jsonrpsee = { features = ["server"], workspace = true }
|
||||||
serde_json = { workspace = true, default-features = true }
|
serde_json = { workspace = true, default-features = true }
|
||||||
sc-cli = { version = "0.42.0" }
|
sc-cli.workspace = true
|
||||||
sc-executor = { version = "0.38.0" }
|
sc-cli.default-features = true
|
||||||
sc-network = { version = "0.40.0" }
|
sc-executor.workspace = true
|
||||||
sc-service = { version = "0.41.0" }
|
sc-executor.default-features = true
|
||||||
sc-telemetry = { version = "20.0.0" }
|
sc-network.workspace = true
|
||||||
sc-transaction-pool = { version = "34.0.0" }
|
sc-network.default-features = true
|
||||||
sc-transaction-pool-api = { version = "34.0.0" }
|
sc-service.workspace = true
|
||||||
sc-consensus = { version = "0.39.1" }
|
sc-service.default-features = true
|
||||||
sc-consensus-manual-seal = { version = "0.41.0" }
|
sc-telemetry.workspace = true
|
||||||
sc-rpc-api = { version = "0.39.0" }
|
sc-telemetry.default-features = true
|
||||||
sc-basic-authorship = { version = "0.40.0" }
|
sc-transaction-pool.workspace = true
|
||||||
sc-offchain = { version = "35.0.0" }
|
sc-transaction-pool.default-features = true
|
||||||
sc-client-api = { version = "34.0.0" }
|
sc-transaction-pool-api.workspace = true
|
||||||
sp-timestamp = { version = "32.0.0" }
|
sc-transaction-pool-api.default-features = true
|
||||||
sp-keyring = { version = "37.0.0" }
|
sc-consensus.workspace = true
|
||||||
sp-api = { version = "32.0.0" }
|
sc-consensus.default-features = true
|
||||||
sp-blockchain = { version = "34.0.0" }
|
sc-consensus-manual-seal.workspace = true
|
||||||
sp-block-builder = { version = "32.0.0" }
|
sc-consensus-manual-seal.default-features = true
|
||||||
sp-io = { version = "36.0.0" }
|
sc-rpc-api.workspace = true
|
||||||
sp-runtime = { version = "37.0.0" }
|
sc-rpc-api.default-features = true
|
||||||
substrate-frame-rpc-system = { version = "34.0.0" }
|
sc-basic-authorship.workspace = true
|
||||||
|
sc-basic-authorship.default-features = true
|
||||||
# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
|
sc-offchain.workspace = true
|
||||||
# certainly no dependency on the runtime.
|
sc-offchain.default-features = true
|
||||||
frame = { version = "0.3.0", package = "polkadot-sdk-frame", features = ["experimental", "runtime"] }
|
sc-client-api.workspace = true
|
||||||
runtime = { package = "minimal-template-runtime", path = "../runtime", version = "0.1.0" }
|
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 }
|
||||||
|
minimal-template-runtime.workspace = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-build-script-utils = { version = "11.0.0" }
|
substrate-build-script-utils.workspace = true
|
||||||
|
substrate-build-script-utils.default-features = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["std"]
|
||||||
|
std = [
|
||||||
|
"minimal-template-runtime/std",
|
||||||
|
]
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Node
|
||||||
|
|
||||||
|
ℹ️ A node - in Polkadot - is a binary executable, whose primary purpose is to execute the [runtime](../runtime/README.md).
|
||||||
|
|
||||||
|
🔗 It communicates with other nodes in the network, and aims for
|
||||||
|
[consensus](https://wiki.polkadot.network/docs/learn-consensus) among them.
|
||||||
|
|
||||||
|
⚙️ It acts as a remote procedure call (RPC) server, allowing interaction with the blockchain.
|
||||||
|
|
||||||
|
👉 Learn more about the architecture, and a difference between a node and a runtime
|
||||||
|
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/wasm_meta_protocol/index.html).
|
||||||
|
|
||||||
|
👇 Here are the most important files in this node template:
|
||||||
|
|
||||||
|
- [`chain_spec.rs`](./src/chain_spec.rs): A chain specification is a source code file that defines the chain's
|
||||||
|
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.
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use runtime::{BalancesConfig, SudoConfig, WASM_BINARY};
|
use minimal_template_runtime::{BalancesConfig, SudoConfig, WASM_BINARY};
|
||||||
use sc_service::{ChainType, Properties};
|
use sc_service::{ChainType, Properties};
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use sp_keyring::AccountKeyring;
|
use sp_keyring::AccountKeyring;
|
||||||
|
|
||||||
/// This is a specialization of the general Substrate ChainSpec type.
|
/// This is a specialization of the general Substrate ChainSpec type.
|
||||||
pub type ChainSpec = sc_service::GenericChainSpec<()>;
|
pub type ChainSpec = sc_service::GenericChainSpec;
|
||||||
|
|
||||||
fn props() -> Properties {
|
fn props() -> Properties {
|
||||||
let mut properties = Properties::new();
|
let mut properties = Properties::new();
|
||||||
@@ -43,7 +43,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
|
|||||||
/// Configure initial storage state for FRAME pallets.
|
/// Configure initial storage state for FRAME pallets.
|
||||||
fn testnet_genesis() -> Value {
|
fn testnet_genesis() -> Value {
|
||||||
use frame::traits::Get;
|
use frame::traits::Get;
|
||||||
use runtime::interface::{Balance, MinimumBalance};
|
use minimal_template_runtime::interface::{Balance, MinimumBalance};
|
||||||
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
|
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
|
||||||
let balances = AccountKeyring::iter()
|
let balances = AccountKeyring::iter()
|
||||||
.map(|a| (a.to_account_id(), endowment))
|
.map(|a| (a.to_account_id(), endowment))
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ impl std::str::FromStr for Consensus {
|
|||||||
} else if let Some(block_time) = s.strip_prefix("manual-seal-") {
|
} else if let Some(block_time) = s.strip_prefix("manual-seal-") {
|
||||||
Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?)
|
Consensus::ManualSeal(block_time.parse().map_err(|_| "invalid block time")?)
|
||||||
} else {
|
} else {
|
||||||
return Err("incorrect consensus identifier".into())
|
return Err("incorrect consensus identifier".into());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -114,7 +114,9 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
},
|
},
|
||||||
Some(Subcommand::ChainInfo(cmd)) => {
|
Some(Subcommand::ChainInfo(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.sync_run(|config| cmd.run::<runtime::interface::OpaqueBlock>(&config))
|
runner.sync_run(|config| {
|
||||||
|
cmd.run::<minimal_template_runtime::interface::OpaqueBlock>(&config)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let runner = cli.create_runner(&cli.run)?;
|
let runner = cli.create_runner(&cli.run)?;
|
||||||
|
|||||||
+3
-2
@@ -23,11 +23,10 @@
|
|||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
use jsonrpsee::RpcModule;
|
use jsonrpsee::RpcModule;
|
||||||
use runtime::interface::{AccountId, Nonce, OpaqueBlock};
|
use minimal_template_runtime::interface::{AccountId, Nonce, OpaqueBlock};
|
||||||
use sc_transaction_pool_api::TransactionPool;
|
use sc_transaction_pool_api::TransactionPool;
|
||||||
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use substrate_frame_rpc_system::{System, SystemApiServer};
|
|
||||||
|
|
||||||
pub use sc_rpc_api::DenyUnsafe;
|
pub use sc_rpc_api::DenyUnsafe;
|
||||||
|
|
||||||
@@ -41,6 +40,7 @@ pub struct FullDeps<C, P> {
|
|||||||
pub deny_unsafe: DenyUnsafe,
|
pub deny_unsafe: DenyUnsafe,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[docify::export]
|
||||||
/// Instantiate all full RPC extensions.
|
/// Instantiate all full RPC extensions.
|
||||||
pub fn create_full<C, P>(
|
pub fn create_full<C, P>(
|
||||||
deps: FullDeps<C, P>,
|
deps: FullDeps<C, P>,
|
||||||
@@ -57,6 +57,7 @@ where
|
|||||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
|
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
|
||||||
P: TransactionPool + 'static,
|
P: TransactionPool + 'static,
|
||||||
{
|
{
|
||||||
|
use substrate_frame_rpc_system::{System, SystemApiServer};
|
||||||
let mut module = RpcModule::new(());
|
let mut module = RpcModule::new(());
|
||||||
let FullDeps { client, pool, deny_unsafe } = deps;
|
let FullDeps { client, pool, deny_unsafe } = deps;
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -16,7 +16,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use runtime::{self, interface::OpaqueBlock as Block, RuntimeApi};
|
use minimal_template_runtime::{interface::OpaqueBlock as Block, RuntimeApi};
|
||||||
use sc_client_api::backend::Backend;
|
use sc_client_api::backend::Backend;
|
||||||
use sc_executor::WasmExecutor;
|
use sc_executor::WasmExecutor;
|
||||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
|
||||||
@@ -34,8 +34,10 @@ type HostFunctions =
|
|||||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||||
type HostFunctions = sp_io::SubstrateHostFunctions;
|
type HostFunctions = sp_io::SubstrateHostFunctions;
|
||||||
|
|
||||||
|
#[docify::export]
|
||||||
pub(crate) type FullClient =
|
pub(crate) type FullClient =
|
||||||
sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
|
sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
|
||||||
|
|
||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
type FullBackend = sc_service::TFullBackend<Block>;
|
||||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
|||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
let executor = sc_service::new_wasm_executor(&config);
|
let executor = sc_service::new_wasm_executor(config);
|
||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager) =
|
||||||
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Pallets
|
||||||
|
|
||||||
|
ℹ️ A pallet is a unit of encapsulated logic, with a clearly defined responsibility. A pallet is analogous to a
|
||||||
|
module in the runtime.
|
||||||
|
|
||||||
|
💁 In this template, there is a simple custom pallet based on the FRAME framework.
|
||||||
|
|
||||||
|
👉 Learn more about FRAME
|
||||||
|
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html).
|
||||||
|
|
||||||
|
🧑🏫 Please refer to
|
||||||
|
[this guide](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html)
|
||||||
|
to learn how to write a basic pallet.
|
||||||
@@ -1,28 +1,25 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pallet-minimal-template"
|
name = "pallet-minimal-template"
|
||||||
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.12.0)"
|
description = "A minimal pallet built with FRAME, part of Polkadot Sdk. (polkadot v1.15.0)"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
license = "MIT-0"
|
license = "Unlicense"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
|
codec = { features = [
|
||||||
"derive",
|
"derive",
|
||||||
], default-features = false }
|
], workspace = true }
|
||||||
scale-info = { version = "2.11.1", default-features = false, features = [
|
scale-info = { features = [
|
||||||
"derive",
|
"derive",
|
||||||
] }
|
], workspace = true }
|
||||||
frame = { version = "0.3.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
|
frame = { features = ["experimental", "runtime"], workspace = true }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
//! A shell pallet built with [`frame`].
|
//! A shell pallet built with [`frame`].
|
||||||
|
//!
|
||||||
|
//! To get started with this pallet, try implementing the guide in
|
||||||
|
//! <https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/your_first_pallet/index.html>
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
|
|||||||
+15
-26
@@ -1,45 +1,34 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "minimal-template-runtime"
|
name = "minimal-template-runtime"
|
||||||
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.12.0)"
|
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.15.0)"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
license = "MIT-0"
|
license = "Unlicense"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-scale-codec = { version = "3.0.0", default-features = false }
|
codec = { workspace = true }
|
||||||
scale-info = { version = "2.6.0", default-features = false }
|
scale-info = { workspace = true }
|
||||||
|
frame = { features = ["experimental", "runtime"], workspace = true }
|
||||||
# this is a frame-based runtime, thus importing `frame` with runtime feature enabled.
|
pallet-balances.workspace = true
|
||||||
frame = { version = "0.3.0", package = "polkadot-sdk-frame", default-features = false, features = ["experimental", "runtime"] }
|
pallet-sudo.workspace = true
|
||||||
|
pallet-timestamp.workspace = true
|
||||||
# pallets that we want to use
|
pallet-transaction-payment.workspace = true
|
||||||
pallet-balances = { version = "35.0.0", default-features = false }
|
pallet-transaction-payment-rpc-runtime-api.workspace = true
|
||||||
pallet-sudo = { version = "34.0.0", default-features = false }
|
sp-genesis-builder.workspace = true
|
||||||
pallet-timestamp = { version = "33.0.0", default-features = false }
|
sp-runtime = { features = ["serde"], workspace = true }
|
||||||
pallet-transaction-payment = { version = "34.0.0", default-features = false }
|
pallet-minimal-template.workspace = true
|
||||||
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.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" }
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "22.0.0", optional = true }
|
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"parity-scale-codec/std",
|
"codec/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
|
|
||||||
"frame/std",
|
"frame/std",
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Runtime
|
||||||
|
|
||||||
|
ℹ️ The runtime (in other words, a state transition function), refers to the core logic of the blockchain that is
|
||||||
|
responsible for validating blocks and executing the state changes they define.
|
||||||
|
|
||||||
|
💁 The runtime in this template is constructed using ready-made FRAME pallets that ship with
|
||||||
|
[Polkadot SDK](https://github.com/paritytech/polkadot-sdk), and a [template for a custom pallet](../pallets/README.md).
|
||||||
|
|
||||||
|
👉 Learn more about FRAME
|
||||||
|
[here](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/frame_runtime/index.html).
|
||||||
+9
-6
@@ -23,6 +23,9 @@
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use alloc::{vec, vec::Vec};
|
||||||
use frame::{
|
use frame::{
|
||||||
deps::frame_support::{
|
deps::frame_support::{
|
||||||
genesis_builder_helper::{build_state, get_preset},
|
genesis_builder_helper::{build_state, get_preset},
|
||||||
@@ -99,27 +102,27 @@ mod runtime {
|
|||||||
|
|
||||||
/// Mandatory system pallet that should always be included in a FRAME runtime.
|
/// Mandatory system pallet that should always be included in a FRAME runtime.
|
||||||
#[runtime::pallet_index(0)]
|
#[runtime::pallet_index(0)]
|
||||||
pub type System = frame_system;
|
pub type System = frame_system::Pallet<Runtime>;
|
||||||
|
|
||||||
/// Provides a way for consensus systems to set and check the onchain time.
|
/// Provides a way for consensus systems to set and check the onchain time.
|
||||||
#[runtime::pallet_index(1)]
|
#[runtime::pallet_index(1)]
|
||||||
pub type Timestamp = pallet_timestamp;
|
pub type Timestamp = pallet_timestamp::Pallet<Runtime>;
|
||||||
|
|
||||||
/// Provides the ability to keep track of balances.
|
/// Provides the ability to keep track of balances.
|
||||||
#[runtime::pallet_index(2)]
|
#[runtime::pallet_index(2)]
|
||||||
pub type Balances = pallet_balances;
|
pub type Balances = pallet_balances::Pallet<Runtime>;
|
||||||
|
|
||||||
/// Provides a way to execute privileged functions.
|
/// Provides a way to execute privileged functions.
|
||||||
#[runtime::pallet_index(3)]
|
#[runtime::pallet_index(3)]
|
||||||
pub type Sudo = pallet_sudo;
|
pub type Sudo = pallet_sudo::Pallet<Runtime>;
|
||||||
|
|
||||||
/// Provides the ability to charge for extrinsic execution.
|
/// Provides the ability to charge for extrinsic execution.
|
||||||
#[runtime::pallet_index(4)]
|
#[runtime::pallet_index(4)]
|
||||||
pub type TransactionPayment = pallet_transaction_payment;
|
pub type TransactionPayment = pallet_transaction_payment::Pallet<Runtime>;
|
||||||
|
|
||||||
/// A minimal pallet template.
|
/// A minimal pallet template.
|
||||||
#[runtime::pallet_index(5)]
|
#[runtime::pallet_index(5)]
|
||||||
pub type Template = pallet_minimal_template;
|
pub type Template = pallet_minimal_template::Pallet<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
[toolchain]
|
|
||||||
channel = "stable"
|
|
||||||
components = [
|
|
||||||
"cargo",
|
|
||||||
"clippy",
|
|
||||||
"rust-analyzer",
|
|
||||||
"rust-src",
|
|
||||||
"rust-std",
|
|
||||||
"rustc",
|
|
||||||
"rustc-dev",
|
|
||||||
"rustfmt",
|
|
||||||
]
|
|
||||||
targets = ["wasm32-unknown-unknown"]
|
|
||||||
profile = "minimal"
|
|
||||||
Reference in New Issue
Block a user