mirror of
https://github.com/pezkuwichain/pez-solochain-template.git
synced 2026-04-22 06:48:02 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d2f52f6b8 | |||
| 8613d353f1 | |||
| a380089b8e | |||
| 1a81a0f2f7 | |||
| 7fa612e9e8 | |||
| bf97b9a0e2 | |||
| c297b0f009 | |||
| 2610f22b83 | |||
| 7582c5ea84 | |||
| 1af6d764d3 | |||
| e4c83d4c89 | |||
| 93f30a2356 | |||
| 8599efc46a | |||
| af8901fed9 | |||
| 1c62506267 | |||
| ef08431ae0 | |||
| 94e47b6e47 | |||
| a41ab75c30 | |||
| a9e0db20dd | |||
| f5608df8bf |
@@ -0,0 +1,16 @@
|
|||||||
|
name: Free disk space
|
||||||
|
description: We've run into out-of-disk error when compiling Rust projects, so we free up some space this way.
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Free Disk Space
|
||||||
|
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
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
name: Install macOS dependencies
|
||||||
|
description: Installs dependencies required to compile the template on macOS
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- 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
|
||||||
|
shell: sh
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
name: Install Ubuntu dependencies
|
||||||
|
description: Installs dependencies required to compile the template in Ubuntu
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Rust compilation prerequisites (Ubuntu)
|
||||||
|
if: contains(matrix.os, 'ubuntu')
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y \
|
||||||
|
protobuf-compiler
|
||||||
|
rustup target add wasm32-unknown-unknown
|
||||||
|
rustup component add rustfmt clippy rust-src
|
||||||
|
shell: bash
|
||||||
+43
-36
@@ -12,30 +12,20 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Rust compilation prerequisites
|
- if: contains(matrix.os, 'ubuntu')
|
||||||
run: |
|
uses: ./.github/actions/free-disk-space
|
||||||
sudo apt update
|
- if: contains(matrix.os, 'ubuntu')
|
||||||
sudo apt install -y \
|
uses: ./.github/actions/ubuntu-dependencies
|
||||||
protobuf-compiler
|
- if: contains(matrix.os, 'macos')
|
||||||
rustup target add wasm32-unknown-unknown
|
uses: ./.github/actions/macos-dependencies
|
||||||
rustup component add rustfmt clippy rust-src
|
|
||||||
|
|
||||||
# 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 the template
|
- name: Build the template
|
||||||
run: cargo build
|
run: cargo build
|
||||||
@@ -48,29 +38,46 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
|
||||||
- name: Run the tests
|
- name: Run the tests
|
||||||
run: cargo test
|
run: SKIP_WASM_BUILD=1 cargo test
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
- name: Build the docs
|
- name: Build the docs
|
||||||
run: cargo doc --all-features --workspace --no-deps
|
run: SKIP_WASM_BUILD=1 cargo doc --workspace --no-deps
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
|
run-node:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- if: contains(matrix.os, 'ubuntu')
|
||||||
|
uses: ./.github/actions/free-disk-space
|
||||||
|
- if: contains(matrix.os, 'ubuntu')
|
||||||
|
uses: ./.github/actions/ubuntu-dependencies
|
||||||
|
- if: contains(matrix.os, 'macos')
|
||||||
|
uses: ./.github/actions/macos-dependencies
|
||||||
|
|
||||||
|
- name: Build the node individually in release mode
|
||||||
|
run: cargo build --package solochain-template-node --release
|
||||||
|
timeout-minutes: 90
|
||||||
|
|
||||||
|
- name: Make sure the node is producing blocks
|
||||||
|
run: |
|
||||||
|
./target/release/solochain-template-node --dev 2>&1 | tee out.txt &
|
||||||
|
until curl -s '127.0.0.1:9944'; do sleep 5; done
|
||||||
|
until cat out.txt | grep -s "Imported #2"; do sleep 5; done
|
||||||
|
shell: bash
|
||||||
|
timeout-minutes: 5
|
||||||
|
|
||||||
build-docker:
|
build-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# We've run into out-of-disk error when compiling Polkadot in the next step, so we free up some space this way.
|
- uses: ./.github/actions/free-disk-space
|
||||||
- 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 the Dockerfile
|
- name: Build the Dockerfile
|
||||||
run: docker build . -t polkadot-sdk-solochain-template
|
run: docker build . -t polkadot-sdk-solochain-template
|
||||||
|
|||||||
@@ -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/solochain).'
|
||||||
|
})
|
||||||
Generated
+7189
-4649
File diff suppressed because it is too large
Load Diff
+110
-4
@@ -1,8 +1,8 @@
|
|||||||
[workspace.package]
|
[workspace.package]
|
||||||
license = "MIT-0"
|
license = "MIT-0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["PezkuwiChain <admin@pezkuwichain.io>"]
|
||||||
homepage = "https://substrate.io"
|
homepage = "https://pezkuwichain.io/"
|
||||||
repository = "https://github.com/paritytech/polkadot-sdk-solochain-template.git"
|
repository = "https://git.pezkuwichain.io/pezkuwichain/pez-solochain-template.git"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
@@ -13,5 +13,111 @@ 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 }
|
||||||
|
type_complexity = { level = "allow", priority = 2 }
|
||||||
|
nonminimal-bool = { level = "allow", priority = 2 }
|
||||||
|
borrowed-box = { level = "allow", priority = 2 }
|
||||||
|
too-many-arguments = { level = "allow", priority = 2 }
|
||||||
|
needless-lifetimes = { level = "allow", priority = 2 }
|
||||||
|
unnecessary_cast = { level = "allow", priority = 2 }
|
||||||
|
identity-op = { level = "allow", priority = 2 }
|
||||||
|
useless_conversion = { level = "allow", priority = 2 }
|
||||||
|
unit_arg = { level = "allow", priority = 2 }
|
||||||
|
option-map-unit-fn = { level = "allow", priority = 2 }
|
||||||
|
bind_instead_of_map = { level = "allow", priority = 2 }
|
||||||
|
erasing_op = { level = "allow", priority = 2 }
|
||||||
|
eq_op = { level = "allow", priority = 2 }
|
||||||
|
while_immutable_condition = { level = "allow", priority = 2 }
|
||||||
|
needless_option_as_deref = { level = "allow", priority = 2 }
|
||||||
|
derivable_impls = { level = "allow", priority = 2 }
|
||||||
|
stable_sort_primitive = { level = "allow", priority = 2 }
|
||||||
|
extra-unused-type-parameters = { level = "allow", priority = 2 }
|
||||||
|
default_constructed_unit_structs = { level = "allow", priority = 2 }
|
||||||
|
self-named-module-files = { level = "allow", priority = 2 }
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
serde_json = { version = "1.0.114", default-features = false }
|
# Local crates
|
||||||
|
pez-solochain-template-runtime = { path = "./runtime", default-features = false }
|
||||||
|
pezpallet-template = { path = "./pallets/template", default-features = false }
|
||||||
|
|
||||||
|
# External crates
|
||||||
|
clap = { version = "4.5" }
|
||||||
|
codec = { version = "3.7", default-features = false, package = "parity-scale-codec" }
|
||||||
|
futures = { version = "0.3" }
|
||||||
|
jsonrpsee = { version = "0.24" }
|
||||||
|
log = { version = "0.4", default-features = false }
|
||||||
|
scale-info = { version = "2.11", default-features = false }
|
||||||
|
serde_json = { version = "1.0", default-features = false }
|
||||||
|
|
||||||
|
# Pezkuwi SDK dependencies (path to local pezkuwi-sdk - update to git/crates.io when published)
|
||||||
|
pezframe-benchmarking = { version = "28.0.0", default-features = false }
|
||||||
|
pezframe-benchmarking-cli = { version = "32.0.1" }
|
||||||
|
pezframe-executive = { version = "28.0.0" , default-features = false }
|
||||||
|
pezframe-metadata-hash-extension = { version = "0.1.0" , default-features = false }
|
||||||
|
pezframe-support = { version = "28.0.0" , default-features = false }
|
||||||
|
pezframe-system = { version = "28.0.0" , default-features = false }
|
||||||
|
pezframe-system-benchmarking = { version = "28.0.0" , default-features = false }
|
||||||
|
pezframe-system-rpc-runtime-api = { version = "26.0.0" , default-features = false }
|
||||||
|
pezframe-try-runtime = { version = "0.34.0" , default-features = false }
|
||||||
|
|
||||||
|
pezpallet-aura = { version = "27.0.0" , default-features = false }
|
||||||
|
pezpallet-balances = { version = "28.0.0" , default-features = false }
|
||||||
|
pezpallet-grandpa = { version = "28.0.0" , default-features = false }
|
||||||
|
pezpallet-sudo = { version = "28.0.0" , default-features = false }
|
||||||
|
pezpallet-timestamp = { version = "27.0.0" , default-features = false }
|
||||||
|
pezpallet-transaction-payment = { version = "28.0.0" , default-features = false }
|
||||||
|
pezpallet-transaction-payment-rpc = { version = "30.0.0" }
|
||||||
|
pezpallet-transaction-payment-rpc-runtime-api = { version = "28.0.0" , default-features = false }
|
||||||
|
|
||||||
|
pezsc-basic-authorship = { version = "0.34.0" }
|
||||||
|
pezsc-cli = { version = "0.36.0" }
|
||||||
|
pezsc-client-api = { version = "28.0.0" }
|
||||||
|
pezsc-consensus = { version = "0.33.0" }
|
||||||
|
pezsc-consensus-aura = { version = "0.34.0" }
|
||||||
|
pezsc-consensus-grandpa = { version = "0.19.0" }
|
||||||
|
pezsc-executor = { version = "0.32.0" }
|
||||||
|
pezsc-network = { version = "0.34.0" }
|
||||||
|
pezsc-offchain = { version = "29.0.0" }
|
||||||
|
pezsc-service = { version = "0.35.0" }
|
||||||
|
pezsc-telemetry = { version = "15.0.0" }
|
||||||
|
pezsc-transaction-pool = { version = "28.0.0" }
|
||||||
|
pezsc-transaction-pool-api = { version = "28.0.0" }
|
||||||
|
|
||||||
|
pezsp-api = { version = "26.0.0" , default-features = false }
|
||||||
|
pezsp-block-builder = { version = "26.0.0" , default-features = false }
|
||||||
|
pezsp-blockchain = { version = "28.0.0" , default-features = false }
|
||||||
|
pezsp-consensus-aura = { version = "0.32.0" , default-features = false }
|
||||||
|
pezsp-consensus-grandpa = { version = "13.0.0" , default-features = false }
|
||||||
|
pezsp-core = { version = "28.0.0" , default-features = false }
|
||||||
|
pezsp-genesis-builder = { version = "0.8.0" , default-features = false }
|
||||||
|
pezsp-inherents = { version = "26.0.0" , default-features = false }
|
||||||
|
pezsp-io = { version = "30.0.0" , default-features = false }
|
||||||
|
pezsp-keyring = { version = "31.0.0" , default-features = false }
|
||||||
|
pezsp-offchain = { version = "26.0.0" , default-features = false }
|
||||||
|
pezsp-runtime = { version = "31.0.1" , default-features = false }
|
||||||
|
pezsp-session = { version = "27.0.0" , default-features = false }
|
||||||
|
pezsp-storage = { version = "19.0.0" , default-features = false }
|
||||||
|
pezsp-timestamp = { version = "26.0.0" , default-features = false }
|
||||||
|
pezsp-transaction-pool = { version = "26.0.0" , default-features = false }
|
||||||
|
pezsp-version = { version = "29.0.0" , default-features = false }
|
||||||
|
|
||||||
|
bizinikiwi-build-script-utils = { version = "11.0.0" }
|
||||||
|
bizinikiwi-frame-rpc-system = { version = "28.0.0" }
|
||||||
|
bizinikiwi-wasm-builder = { version = "17.0.0" }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level = 3
|
||||||
|
panic = "unwind"
|
||||||
|
|
||||||
|
[profile.production]
|
||||||
|
codegen-units = 1
|
||||||
|
inherits = "release"
|
||||||
|
lto = true
|
||||||
|
|||||||
+10
-10
@@ -1,28 +1,28 @@
|
|||||||
FROM docker.io/paritytech/ci-unified:latest as builder
|
FROM docker.io/paritytech/ci-unified:latest as builder
|
||||||
|
|
||||||
WORKDIR /polkadot
|
WORKDIR /pezkuwi
|
||||||
COPY . /polkadot
|
COPY . /pezkuwi
|
||||||
|
|
||||||
RUN cargo fetch
|
RUN cargo fetch
|
||||||
RUN cargo build --locked --release
|
RUN cargo build --locked --release
|
||||||
|
|
||||||
FROM docker.io/parity/base-bin:latest
|
FROM docker.io/parity/base-bin:latest
|
||||||
|
|
||||||
COPY --from=builder /polkadot/target/release/solochain-template-node /usr/local/bin
|
COPY --from=builder /pezkuwi/target/release/pez-solochain-template-node /usr/local/bin
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
RUN useradd -m -u 1001 -U -s /bin/sh -d /polkadot polkadot && \
|
RUN useradd -m -u 1001 -U -s /bin/sh -d /pezkuwi pezkuwi && \
|
||||||
mkdir -p /data /polkadot/.local/share && \
|
mkdir -p /data /pezkuwi/.local/share && \
|
||||||
chown -R polkadot:polkadot /data && \
|
chown -R pezkuwi:pezkuwi /data && \
|
||||||
ln -s /data /polkadot/.local/share/polkadot && \
|
ln -s /data /pezkuwi/.local/share/pezkuwi && \
|
||||||
# unclutter and minimize the attack surface
|
# unclutter and minimize the attack surface
|
||||||
rm -rf /usr/bin /usr/sbin && \
|
rm -rf /usr/bin /usr/sbin && \
|
||||||
# check if executable works in this container
|
# check if executable works in this container
|
||||||
/usr/local/bin/solochain-template-node --version
|
/usr/local/bin/pez-solochain-template-node --version
|
||||||
|
|
||||||
USER polkadot
|
USER pezkuwi
|
||||||
|
|
||||||
EXPOSE 30333 9933 9944 9615
|
EXPOSE 30333 9933 9944 9615
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/solochain-template-node"]
|
ENTRYPOINT ["/usr/local/bin/pez-solochain-template-node"]
|
||||||
@@ -1,224 +1,61 @@
|
|||||||
# Substrate Node Template
|
# Pezkuwi Solochain Template
|
||||||
|
|
||||||
A fresh [Substrate](https://substrate.io/) node, ready for hacking :rocket:
|
A minimal, ready-to-use solochain template built with the **Pezkuwi SDK**. This template provides a starting point for building custom blockchains (Solochains) within the Pezkuwi ecosystem using **Bizinikiwi** (our Substrate fork) and **Pezframe**.
|
||||||
|
|
||||||
A standalone version of this template is available for each release of Polkadot
|
## 🚀 Getting Started
|
||||||
in the [Substrate Developer Hub Parachain
|
|
||||||
Template](https://github.com/substrate-developer-hub/substrate-node-template/)
|
|
||||||
repository. The parachain template is generated directly at each Polkadot
|
|
||||||
release branch from the [Solochain Template in
|
|
||||||
Substrate](https://github.com/paritytech/polkadot-sdk/tree/master/templates/solochain)
|
|
||||||
upstream
|
|
||||||
|
|
||||||
It is usually best to use the stand-alone version to start a new project. All
|
Follow these steps to get started with the Pezkuwi Solochain Template:
|
||||||
bugs, suggestions, and feature requests should be made upstream in the
|
|
||||||
[Substrate](https://github.com/paritytech/polkadot-sdk/tree/master/substrate)
|
|
||||||
repository.
|
|
||||||
|
|
||||||
## Getting Started
|
### 1. Prerequisites
|
||||||
|
|
||||||
Depending on your operating system and Rust version, there might be additional
|
Ensure you have the following installed:
|
||||||
packages required to compile this template. Check the
|
- Rust (stable and nightly)
|
||||||
[Install](https://docs.substrate.io/install/) instructions for your platform for
|
- Clang and LLVM
|
||||||
the most common dependencies. Alternatively, you can use one of the [alternative
|
- Pezkuwi SDK environment (see [docs.pezkuwichain.io](https://docs.pezkuwichain.io))
|
||||||
installation](#alternatives-installations) options.
|
|
||||||
|
|
||||||
### Build
|
### 2. Build
|
||||||
|
|
||||||
Use the following command to build the node without launching it:
|
Build the node in release mode:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo build --release
|
cargo build --release
|
||||||
```
|
```
|
||||||
|
|
||||||
### Embedded Docs
|
### 3. Run
|
||||||
|
|
||||||
After you build the project, you can use the following command to explore its
|
Run the temporary node in developer mode:
|
||||||
parameters and subcommands:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./target/release/node-template -h
|
./target/release/pez-solochain-template-node --dev
|
||||||
```
|
```
|
||||||
|
|
||||||
You can generate and view the [Rust
|
This command will:
|
||||||
Docs](https://doc.rust-lang.org/cargo/commands/cargo-doc.html) for this template
|
- Start a single-node development chain.
|
||||||
with this command:
|
- Keep the state in a temporary directory.
|
||||||
|
- Expose RPC and WebSocket ports.
|
||||||
|
|
||||||
```sh
|
## 🏗️ Structure
|
||||||
cargo +nightly doc --open
|
|
||||||
```
|
|
||||||
|
|
||||||
### Single-Node Development Chain
|
This repository is structured as follows:
|
||||||
|
|
||||||
The following command starts a single-node development chain that doesn't
|
- **`node/`**: The blockchain node logic (CLI, RPC, Service).
|
||||||
persist state:
|
- **`runtime/`**: The runtime logic, aggregating all pezpallets.
|
||||||
|
- **`pallets/`**: Custom runtime modules (Pezpallets).
|
||||||
|
- **`template/`**: A sample pezpallet demonstrating storage, events, and errors.
|
||||||
|
|
||||||
```sh
|
## 🛠️ Customization
|
||||||
./target/release/node-template --dev
|
|
||||||
```
|
|
||||||
|
|
||||||
To purge the development chain's state, run the following command:
|
To customize this template:
|
||||||
|
|
||||||
```sh
|
1. **Modify the Runtime:** Edit `runtime/src/lib.rs` to add or remove pezpallets.
|
||||||
./target/release/node-template purge-chain --dev
|
2. **Add Logic:** Modify `pallets/template/src/lib.rs` to implement your custom business logic.
|
||||||
```
|
3. **Chain Spec:** Update `node/src/chain_spec.rs` to define your chain's genesis state.
|
||||||
|
|
||||||
To start the development chain with detailed logging, run the following command:
|
## 📚 Documentation
|
||||||
|
|
||||||
```sh
|
- [Pezkuwi Documentation](https://docs.pezkuwichain.io)
|
||||||
RUST_BACKTRACE=1 ./target/release/node-template -ldebug --dev
|
- [Pezkuwi SDK Repository](https://github.com/pezkuwichain/pezkuwi-sdk)
|
||||||
```
|
|
||||||
|
|
||||||
Development chains:
|
## 📜 License
|
||||||
|
|
||||||
- Maintain state in a `tmp` folder while the node is running.
|
Unlicense
|
||||||
- Use the **Alice** and **Bob** accounts as default validator authorities.
|
|
||||||
- Use the **Alice** account as the default `sudo` account.
|
|
||||||
- Are preconfigured with a genesis state (`/node/src/chain_spec.rs`) that
|
|
||||||
includes several prefunded development accounts.
|
|
||||||
|
|
||||||
|
|
||||||
To persist chain state between runs, specify a base path by running a command
|
|
||||||
similar to the following:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
// Create a folder to use as the db base path
|
|
||||||
$ mkdir my-chain-state
|
|
||||||
|
|
||||||
// Use of that folder to store the chain state
|
|
||||||
$ ./target/release/node-template --dev --base-path ./my-chain-state/
|
|
||||||
|
|
||||||
// Check the folder structure created inside the base path after running the chain
|
|
||||||
$ ls ./my-chain-state
|
|
||||||
chains
|
|
||||||
$ ls ./my-chain-state/chains/
|
|
||||||
dev
|
|
||||||
$ ls ./my-chain-state/chains/dev
|
|
||||||
db keystore network
|
|
||||||
```
|
|
||||||
|
|
||||||
### Connect with Polkadot-JS Apps Front-End
|
|
||||||
|
|
||||||
After you start the node template locally, you can interact with it using the
|
|
||||||
hosted version of the [Polkadot/Substrate
|
|
||||||
Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944)
|
|
||||||
front-end by connecting to the local node endpoint. 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.
|
|
||||||
|
|
||||||
### Multi-Node Local Testnet
|
|
||||||
|
|
||||||
If you want to see the multi-node consensus algorithm in action, see [Simulate a
|
|
||||||
network](https://docs.substrate.io/tutorials/build-a-blockchain/simulate-network/).
|
|
||||||
|
|
||||||
## Template Structure
|
|
||||||
|
|
||||||
A Substrate project such as this consists of a number of components that are
|
|
||||||
spread across a few directories.
|
|
||||||
|
|
||||||
### Node
|
|
||||||
|
|
||||||
A blockchain node is an application that allows users to participate in a
|
|
||||||
blockchain network. Substrate-based blockchain nodes expose a number of
|
|
||||||
capabilities:
|
|
||||||
|
|
||||||
- Networking: Substrate nodes use the [`libp2p`](https://libp2p.io/) networking
|
|
||||||
stack to allow the nodes in the network to communicate with one another.
|
|
||||||
- Consensus: Blockchains must have a way to come to
|
|
||||||
[consensus](https://docs.substrate.io/fundamentals/consensus/) on the state of
|
|
||||||
the network. Substrate makes it possible to supply custom consensus engines
|
|
||||||
and also ships with several consensus mechanisms that have been built on top
|
|
||||||
of [Web3 Foundation
|
|
||||||
research](https://research.web3.foundation/Polkadot/protocols/NPoS).
|
|
||||||
- RPC Server: A remote procedure call (RPC) server is used to interact with
|
|
||||||
Substrate nodes.
|
|
||||||
|
|
||||||
There are several files in the `node` directory. Take special note of the
|
|
||||||
following:
|
|
||||||
|
|
||||||
- [`chain_spec.rs`](./node/src/chain_spec.rs): A [chain
|
|
||||||
specification](https://docs.substrate.io/build/chain-spec/) is a source code
|
|
||||||
file that defines a Substrate chain's initial (genesis) state. Chain
|
|
||||||
specifications are useful for development and testing, and critical when
|
|
||||||
architecting the launch of a production chain. Take note of the
|
|
||||||
`development_config` and `testnet_genesis` functions,. These functions are
|
|
||||||
used to define the genesis state for the local development chain
|
|
||||||
configuration. These functions identify some [well-known
|
|
||||||
accounts](https://docs.substrate.io/reference/command-line-tools/subkey/) and
|
|
||||||
use them to configure the blockchain's initial state.
|
|
||||||
- [`service.rs`](./node/src/service.rs): This file defines the node
|
|
||||||
implementation. Take note of the libraries that this file imports and the
|
|
||||||
names of the functions it invokes. In particular, there are references to
|
|
||||||
consensus-related topics, such as the [block finalization and
|
|
||||||
forks](https://docs.substrate.io/fundamentals/consensus/#finalization-and-forks)
|
|
||||||
and other [consensus
|
|
||||||
mechanisms](https://docs.substrate.io/fundamentals/consensus/#default-consensus-models)
|
|
||||||
such as Aura for block authoring and GRANDPA for finality.
|
|
||||||
|
|
||||||
|
|
||||||
### Runtime
|
|
||||||
|
|
||||||
In Substrate, the terms "runtime" and "state transition function" are analogous.
|
|
||||||
Both terms refer to the core logic of the blockchain that is responsible for
|
|
||||||
validating blocks and executing the state changes they define. The Substrate
|
|
||||||
project in this repository uses
|
|
||||||
[FRAME](https://docs.substrate.io/learn/runtime-development/#frame) to construct
|
|
||||||
a blockchain runtime. FRAME allows runtime developers to declare domain-specific
|
|
||||||
logic in modules called "pallets". At the heart of FRAME is a helpful [macro
|
|
||||||
language](https://docs.substrate.io/reference/frame-macros/) that makes it easy
|
|
||||||
to create pallets and flexibly compose them to create blockchains that can
|
|
||||||
address [a variety of needs](https://substrate.io/ecosystem/projects/).
|
|
||||||
|
|
||||||
Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this
|
|
||||||
template and note the following:
|
|
||||||
|
|
||||||
- This file configures several pallets to include in the runtime. Each pallet
|
|
||||||
configuration is defined by a code block that begins with `impl
|
|
||||||
$PALLET_NAME::Config for Runtime`.
|
|
||||||
- The pallets are composed into a single runtime by way of the
|
|
||||||
[`construct_runtime!`](https://paritytech.github.io/substrate/master/frame_support/macro.construct_runtime.html)
|
|
||||||
macro, which is part of the [core FRAME pallet
|
|
||||||
library](https://docs.substrate.io/reference/frame-pallets/#system-pallets).
|
|
||||||
|
|
||||||
### Pallets
|
|
||||||
|
|
||||||
The runtime in this project is constructed using many FRAME pallets that ship
|
|
||||||
with [the Substrate
|
|
||||||
repository](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame) and a
|
|
||||||
template pallet that is [defined in the
|
|
||||||
`pallets`](./pallets/template/src/lib.rs) directory.
|
|
||||||
|
|
||||||
A FRAME pallet is comprised of a number of blockchain primitives, including:
|
|
||||||
|
|
||||||
- Storage: FRAME defines a rich set of powerful [storage
|
|
||||||
abstractions](https://docs.substrate.io/build/runtime-storage/) that makes it
|
|
||||||
easy to use Substrate's efficient key-value database to manage the evolving
|
|
||||||
state of a blockchain.
|
|
||||||
- Dispatchables: FRAME pallets define special types of functions that can be
|
|
||||||
invoked (dispatched) from outside of the runtime in order to update its state.
|
|
||||||
- Events: Substrate uses
|
|
||||||
[events](https://docs.substrate.io/build/events-and-errors/) to notify users
|
|
||||||
of significant state changes.
|
|
||||||
- Errors: When a dispatchable fails, it returns an error.
|
|
||||||
|
|
||||||
Each pallet has its own `Config` trait which serves as a configuration interface
|
|
||||||
to generically define the types and parameters it depends on.
|
|
||||||
|
|
||||||
## Alternatives Installations
|
|
||||||
|
|
||||||
Instead of installing dependencies and building this source directly, consider
|
|
||||||
the following alternatives.
|
|
||||||
|
|
||||||
### Nix
|
|
||||||
|
|
||||||
Install [nix](https://nixos.org/) and
|
|
||||||
[nix-direnv](https://github.com/nix-community/nix-direnv) for a fully
|
|
||||||
plug-and-play experience for setting up the development environment. To get all
|
|
||||||
the correct dependencies, activate direnv `direnv allow`.
|
|
||||||
|
|
||||||
### Docker
|
|
||||||
|
|
||||||
Please follow the [Substrate Docker instructions
|
|
||||||
here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/docker/README.md) to
|
|
||||||
build the Docker container with the Substrate Node Template binary.
|
|
||||||
+88
-49
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solochain-template-node"
|
name = "pez-solochain-template-node"
|
||||||
description = "A solochain node template built with Substrate, part of Polkadot Sdk. (polkadot v1.13.0)"
|
description = "A solochain node template built with Bizinikiwi, part of Pezkuwi Sdk."
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
license = "Unlicense"
|
license = "Unlicense"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
@@ -10,65 +10,104 @@ edition.workspace = true
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
documentation = "https://docs.rs/pez-solochain-template-node"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.3", features = ["derive"] }
|
clap = { features = ["derive"], workspace = true }
|
||||||
futures = { version = "0.3.30", features = ["thread-pool"] }
|
futures = { features = ["thread-pool"], workspace = true }
|
||||||
serde_json = { workspace = true, default-features = true }
|
jsonrpsee = { features = ["server"], workspace = true }
|
||||||
jsonrpsee = { version = "0.22", features = ["server"] }
|
|
||||||
sc-cli = { version = "0.43.0" }
|
# bizinikiwi client
|
||||||
sp-core = { version = "34.0.0" }
|
pezsc-basic-authorship = { workspace = true, default-features = true }
|
||||||
sc-executor = { version = "0.39.0" }
|
pezsc-cli = { workspace = true, default-features = true }
|
||||||
sc-network = { version = "0.41.0" }
|
pezsc-client-api = { workspace = true, default-features = true }
|
||||||
sc-service = { version = "0.42.0" }
|
pezsc-consensus = { workspace = true, default-features = true }
|
||||||
sc-telemetry = { version = "21.0.0" }
|
pezsc-consensus-aura = { workspace = true, default-features = true }
|
||||||
sc-transaction-pool = { version = "35.0.0" }
|
pezsc-consensus-grandpa = { workspace = true, default-features = true }
|
||||||
sc-transaction-pool-api = { version = "35.0.0" }
|
pezsc-executor = { workspace = true, default-features = true }
|
||||||
sc-offchain = { version = "36.0.0" }
|
pezsc-network = { workspace = true, default-features = true }
|
||||||
sc-consensus-aura = { version = "0.41.0" }
|
pezsc-offchain = { workspace = true, default-features = true }
|
||||||
sp-consensus-aura = { version = "0.39.0" }
|
pezsc-service = { workspace = true, default-features = true }
|
||||||
sc-consensus = { version = "0.40.0" }
|
pezsc-telemetry = { workspace = true, default-features = true }
|
||||||
sc-consensus-grandpa = { version = "0.26.0" }
|
pezsc-transaction-pool = { workspace = true, default-features = true }
|
||||||
sp-consensus-grandpa = { version = "20.0.0" }
|
pezsc-transaction-pool-api = { workspace = true, default-features = true }
|
||||||
sc-client-api = { version = "35.0.0" }
|
pezsp-consensus-aura = { workspace = true, default-features = true }
|
||||||
sc-rpc-api = { version = "0.40.0" }
|
pezsp-core = { workspace = true, default-features = true }
|
||||||
sc-basic-authorship = { version = "0.41.0" }
|
pezsp-genesis-builder = { workspace = true, default-features = true }
|
||||||
sp-runtime = { version = "38.0.0" }
|
|
||||||
sp-io = { version = "37.0.0" }
|
# bizinikiwi primitives
|
||||||
sp-timestamp = { version = "33.0.0" }
|
pezsp-api = { workspace = true, default-features = true }
|
||||||
sp-inherents = { version = "33.0.0" }
|
pezsp-block-builder = { workspace = true, default-features = true }
|
||||||
sp-keyring = { version = "38.0.0" }
|
pezsp-blockchain = { workspace = true, default-features = true }
|
||||||
sp-api = { version = "33.0.0" }
|
pezsp-inherents = { workspace = true, default-features = true }
|
||||||
sp-blockchain = { version = "35.0.0" }
|
pezsp-io = { workspace = true, default-features = true }
|
||||||
sp-block-builder = { version = "33.0.0" }
|
pezsp-keyring = { workspace = true, default-features = true }
|
||||||
frame-system = { version = "35.0.0" }
|
pezsp-runtime = { workspace = true, default-features = true }
|
||||||
pallet-transaction-payment = { version = "35.0.0", default-features = false }
|
pezsp-timestamp = { workspace = true, default-features = true }
|
||||||
pallet-transaction-payment-rpc = { version = "37.0.0" }
|
|
||||||
substrate-frame-rpc-system = { version = "35.0.0" }
|
# pezframe and pezpallets
|
||||||
frame-benchmarking-cli = { version = "39.0.0" }
|
bizinikiwi-frame-rpc-system = { workspace = true, default-features = true }
|
||||||
solochain-template-runtime = { version = "0.1.0", path = "../runtime" }
|
pezframe-metadata-hash-extension = { workspace = true, default-features = true }
|
||||||
|
pezframe-system = { workspace = true, default-features = true }
|
||||||
|
pezpallet-transaction-payment = { workspace = true, default-features = true }
|
||||||
|
pezpallet-transaction-payment-rpc = { workspace = true, default-features = true }
|
||||||
|
|
||||||
|
# These dependencies are used for runtime benchmarking
|
||||||
|
pezframe-benchmarking-cli = { workspace = true, default-features = true }
|
||||||
|
|
||||||
|
# Local Dependencies
|
||||||
|
pez-solochain-template-runtime = { workspace = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-build-script-utils = { version = "11.0.0" }
|
bizinikiwi-build-script-utils = { workspace = true, default-features = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["std"]
|
||||||
|
std = ["pez-solochain-template-runtime/std"]
|
||||||
# Dependencies that are only required if runtime benchmarking should be build.
|
# Dependencies that are only required if runtime benchmarking should be build.
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking-cli/runtime-benchmarks",
|
"bizinikiwi-frame-rpc-system/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"pez-solochain-template-runtime/runtime-benchmarks",
|
||||||
"sc-service/runtime-benchmarks",
|
"pezframe-benchmarking-cli/runtime-benchmarks",
|
||||||
"solochain-template-runtime/runtime-benchmarks",
|
"pezframe-benchmarking-cli/storage-benchmark",
|
||||||
"sp-runtime/runtime-benchmarks",
|
"pezframe-metadata-hash-extension/runtime-benchmarks",
|
||||||
|
"pezframe-system/runtime-benchmarks",
|
||||||
|
"pezpallet-transaction-payment-rpc/runtime-benchmarks",
|
||||||
|
"pezpallet-transaction-payment/runtime-benchmarks",
|
||||||
|
"pezsc-basic-authorship/runtime-benchmarks",
|
||||||
|
"pezsc-cli/runtime-benchmarks",
|
||||||
|
"pezsc-client-api/runtime-benchmarks",
|
||||||
|
"pezsc-consensus-aura/runtime-benchmarks",
|
||||||
|
"pezsc-consensus-grandpa/runtime-benchmarks",
|
||||||
|
"pezsc-consensus/runtime-benchmarks",
|
||||||
|
"pezsc-executor/runtime-benchmarks",
|
||||||
|
"pezsc-network/runtime-benchmarks",
|
||||||
|
"pezsc-offchain/runtime-benchmarks",
|
||||||
|
"pezsc-service/runtime-benchmarks",
|
||||||
|
"pezsc-transaction-pool-api/runtime-benchmarks",
|
||||||
|
"pezsc-transaction-pool/runtime-benchmarks",
|
||||||
|
"pezsp-api/runtime-benchmarks",
|
||||||
|
"pezsp-block-builder/runtime-benchmarks",
|
||||||
|
"pezsp-blockchain/runtime-benchmarks",
|
||||||
|
"pezsp-consensus-aura/runtime-benchmarks",
|
||||||
|
"pezsp-genesis-builder/runtime-benchmarks",
|
||||||
|
"pezsp-inherents/runtime-benchmarks",
|
||||||
|
"pezsp-io/runtime-benchmarks",
|
||||||
|
"pezsp-keyring/runtime-benchmarks",
|
||||||
|
"pezsp-runtime/runtime-benchmarks",
|
||||||
|
"pezsp-timestamp/runtime-benchmarks",
|
||||||
]
|
]
|
||||||
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
|
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
|
||||||
# in the near future.
|
# in the near future.
|
||||||
try-runtime = [
|
try-runtime = [
|
||||||
"frame-system/try-runtime",
|
"pez-solochain-template-runtime/try-runtime",
|
||||||
"pallet-transaction-payment/try-runtime",
|
"pezframe-system/try-runtime",
|
||||||
"solochain-template-runtime/try-runtime",
|
"pezpallet-transaction-payment/try-runtime",
|
||||||
"sp-runtime/try-runtime",
|
"pezsp-runtime/try-runtime",
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
|
use bizinikiwi_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
generate_cargo_keys();
|
generate_cargo_keys();
|
||||||
|
|||||||
+33
-27
@@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
use crate::service::FullClient;
|
use crate::service::FullClient;
|
||||||
|
|
||||||
|
use pez_solochain_template_runtime as runtime;
|
||||||
|
use pezsc_cli::Result;
|
||||||
|
use pezsc_client_api::BlockBackend;
|
||||||
|
use pezsp_core::{Encode, Pair};
|
||||||
|
use pezsp_inherents::{InherentData, InherentDataProvider};
|
||||||
|
use pezsp_keyring::Sr25519Keyring;
|
||||||
|
use pezsp_runtime::{OpaqueExtrinsic, SaturatedConversion};
|
||||||
use runtime::{AccountId, Balance, BalancesCall, SystemCall};
|
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;
|
|
||||||
use sp_runtime::{OpaqueExtrinsic, SaturatedConversion};
|
|
||||||
|
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ impl RemarkBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
|
impl pezframe_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
|
||||||
fn pallet(&self) -> &str {
|
fn pezpallet(&self) -> &str {
|
||||||
"system"
|
"system"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +68,8 @@ impl TransferKeepAliveBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
impl pezframe_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
||||||
fn pallet(&self) -> &str {
|
fn pezpallet(&self) -> &str {
|
||||||
"balances"
|
"balances"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
|||||||
/// Note: Should only be used for benchmarking.
|
/// Note: Should only be used for benchmarking.
|
||||||
pub fn create_benchmark_extrinsic(
|
pub fn create_benchmark_extrinsic(
|
||||||
client: &FullClient,
|
client: &FullClient,
|
||||||
sender: sp_core::sr25519::Pair,
|
sender: pezsp_core::sr25519::Pair,
|
||||||
call: runtime::RuntimeCall,
|
call: runtime::RuntimeCall,
|
||||||
nonce: u32,
|
nonce: u32,
|
||||||
) -> runtime::UncheckedExtrinsic {
|
) -> runtime::UncheckedExtrinsic {
|
||||||
@@ -105,28 +105,32 @@ pub fn create_benchmark_extrinsic(
|
|||||||
let best_hash = client.chain_info().best_hash;
|
let best_hash = client.chain_info().best_hash;
|
||||||
let best_block = client.chain_info().best_number;
|
let best_block = client.chain_info().best_number;
|
||||||
|
|
||||||
let period = runtime::BlockHashCount::get()
|
let period = runtime::configs::BlockHashCount::get()
|
||||||
.checked_next_power_of_two()
|
.checked_next_power_of_two()
|
||||||
.map(|c| c / 2)
|
.map(|c| c / 2)
|
||||||
.unwrap_or(2) as u64;
|
.unwrap_or(2) as u64;
|
||||||
let extra: runtime::SignedExtra = (
|
let tx_ext: runtime::TxExtension = (
|
||||||
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
|
pezframe_system::AuthorizeCall::<runtime::Runtime>::new(),
|
||||||
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
|
pezframe_system::CheckNonZeroSender::<runtime::Runtime>::new(),
|
||||||
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
|
pezframe_system::CheckSpecVersion::<runtime::Runtime>::new(),
|
||||||
frame_system::CheckGenesis::<runtime::Runtime>::new(),
|
pezframe_system::CheckTxVersion::<runtime::Runtime>::new(),
|
||||||
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
|
pezframe_system::CheckGenesis::<runtime::Runtime>::new(),
|
||||||
|
pezframe_system::CheckEra::<runtime::Runtime>::from(pezsp_runtime::generic::Era::mortal(
|
||||||
period,
|
period,
|
||||||
best_block.saturated_into(),
|
best_block.saturated_into(),
|
||||||
)),
|
)),
|
||||||
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
|
pezframe_system::CheckNonce::<runtime::Runtime>::from(nonce),
|
||||||
frame_system::CheckWeight::<runtime::Runtime>::new(),
|
pezframe_system::CheckWeight::<runtime::Runtime>::new(),
|
||||||
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
|
pezpallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
|
||||||
|
pezframe_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
|
||||||
|
pezframe_system::WeightReclaim::<runtime::Runtime>::new(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let raw_payload = runtime::SignedPayload::from_raw(
|
let raw_payload = runtime::SignedPayload::from_raw(
|
||||||
call.clone(),
|
call.clone(),
|
||||||
extra.clone(),
|
tx_ext.clone(),
|
||||||
(
|
(
|
||||||
|
(),
|
||||||
(),
|
(),
|
||||||
runtime::VERSION.spec_version,
|
runtime::VERSION.spec_version,
|
||||||
runtime::VERSION.transaction_version,
|
runtime::VERSION.transaction_version,
|
||||||
@@ -135,15 +139,17 @@ pub fn create_benchmark_extrinsic(
|
|||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
|
None,
|
||||||
|
(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
let signature = raw_payload.using_encoded(|e| sender.sign(e));
|
let signature = raw_payload.using_encoded(|e| sender.sign(e));
|
||||||
|
|
||||||
runtime::UncheckedExtrinsic::new_signed(
|
runtime::UncheckedExtrinsic::new_signed(
|
||||||
call,
|
call,
|
||||||
sp_runtime::AccountId32::from(sender.public()).into(),
|
pezsp_runtime::AccountId32::from(sender.public()).into(),
|
||||||
runtime::Signature::Sr25519(signature),
|
runtime::Signature::Sr25519(signature),
|
||||||
extra,
|
tx_ext,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,9 +159,9 @@ pub fn create_benchmark_extrinsic(
|
|||||||
pub fn inherent_benchmark_data() -> Result<InherentData> {
|
pub fn inherent_benchmark_data() -> Result<InherentData> {
|
||||||
let mut inherent_data = InherentData::new();
|
let mut inherent_data = InherentData::new();
|
||||||
let d = Duration::from_millis(0);
|
let d = Duration::from_millis(0);
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::new(d.into());
|
let timestamp = pezsp_timestamp::InherentDataProvider::new(d.into());
|
||||||
|
|
||||||
futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data))
|
futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data))
|
||||||
.map_err(|e| format!("creating inherent data: {:?}", e))?;
|
.map_err(|e| format!("creating inherent data: {e:?}"))?;
|
||||||
Ok(inherent_data)
|
Ok(inherent_data)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-96
@@ -1,39 +1,10 @@
|
|||||||
use sc_service::ChainType;
|
use pez_solochain_template_runtime::WASM_BINARY;
|
||||||
use solochain_template_runtime::{AccountId, Signature, WASM_BINARY};
|
use pezsc_service::ChainType;
|
||||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
|
||||||
use sp_consensus_grandpa::AuthorityId as GrandpaId;
|
|
||||||
use sp_core::{sr25519, Pair, Public};
|
|
||||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
|
||||||
|
|
||||||
// The URL for the telemetry server.
|
/// Specialized `ChainSpec`. This is a specialization of the general Bizinikiwi ChainSpec type.
|
||||||
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
pub type ChainSpec = pezsc_service::GenericChainSpec;
|
||||||
|
|
||||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
pub fn development_chain_spec() -> Result<ChainSpec, String> {
|
||||||
pub type ChainSpec = sc_service::GenericChainSpec;
|
|
||||||
|
|
||||||
/// Generate a crypto pair from seed.
|
|
||||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
|
||||||
TPublic::Pair::from_string(&format!("//{}", seed), None)
|
|
||||||
.expect("static values are valid; qed")
|
|
||||||
.public()
|
|
||||||
}
|
|
||||||
|
|
||||||
type AccountPublic = <Signature as Verify>::Signer;
|
|
||||||
|
|
||||||
/// Generate an account ID from seed.
|
|
||||||
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
|
|
||||||
where
|
|
||||||
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
|
||||||
{
|
|
||||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate an Aura authority key.
|
|
||||||
pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
|
|
||||||
(get_from_seed::<AuraId>(s), get_from_seed::<GrandpaId>(s))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn development_config() -> Result<ChainSpec, String> {
|
|
||||||
Ok(ChainSpec::builder(
|
Ok(ChainSpec::builder(
|
||||||
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
|
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
|
||||||
None,
|
None,
|
||||||
@@ -41,24 +12,11 @@ pub fn development_config() -> Result<ChainSpec, String> {
|
|||||||
.with_name("Development")
|
.with_name("Development")
|
||||||
.with_id("dev")
|
.with_id("dev")
|
||||||
.with_chain_type(ChainType::Development)
|
.with_chain_type(ChainType::Development)
|
||||||
.with_genesis_config_patch(testnet_genesis(
|
.with_genesis_config_preset_name(pezsp_genesis_builder::DEV_RUNTIME_PRESET)
|
||||||
// Initial PoA authorities
|
|
||||||
vec![authority_keys_from_seed("Alice")],
|
|
||||||
// Sudo account
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
// Pre-funded accounts
|
|
||||||
vec![
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
||||||
],
|
|
||||||
true,
|
|
||||||
))
|
|
||||||
.build())
|
.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_testnet_config() -> Result<ChainSpec, String> {
|
pub fn local_chain_spec() -> Result<ChainSpec, String> {
|
||||||
Ok(ChainSpec::builder(
|
Ok(ChainSpec::builder(
|
||||||
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
|
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?,
|
||||||
None,
|
None,
|
||||||
@@ -66,52 +24,6 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
|
|||||||
.with_name("Local Testnet")
|
.with_name("Local Testnet")
|
||||||
.with_id("local_testnet")
|
.with_id("local_testnet")
|
||||||
.with_chain_type(ChainType::Local)
|
.with_chain_type(ChainType::Local)
|
||||||
.with_genesis_config_patch(testnet_genesis(
|
.with_genesis_config_preset_name(pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
|
||||||
// Initial PoA authorities
|
|
||||||
vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")],
|
|
||||||
// Sudo account
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
// Pre-funded accounts
|
|
||||||
vec![
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
|
||||||
],
|
|
||||||
true,
|
|
||||||
))
|
|
||||||
.build())
|
.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configure initial storage state for FRAME modules.
|
|
||||||
fn testnet_genesis(
|
|
||||||
initial_authorities: Vec<(AuraId, GrandpaId)>,
|
|
||||||
root_key: AccountId,
|
|
||||||
endowed_accounts: Vec<AccountId>,
|
|
||||||
_enable_println: bool,
|
|
||||||
) -> serde_json::Value {
|
|
||||||
serde_json::json!({
|
|
||||||
"balances": {
|
|
||||||
// Configure endowed accounts with initial balance of 1 << 60.
|
|
||||||
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
|
|
||||||
},
|
|
||||||
"aura": {
|
|
||||||
"authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::<Vec<_>>(),
|
|
||||||
},
|
|
||||||
"grandpa": {
|
|
||||||
"authorities": initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect::<Vec<_>>(),
|
|
||||||
},
|
|
||||||
"sudo": {
|
|
||||||
// Assign network admin rights.
|
|
||||||
"key": Some(root_key),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
+19
-13
@@ -1,12 +1,10 @@
|
|||||||
use sc_cli::RunCmd;
|
|
||||||
|
|
||||||
#[derive(Debug, clap::Parser)]
|
#[derive(Debug, clap::Parser)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub subcommand: Option<Subcommand>,
|
pub subcommand: Option<Subcommand>,
|
||||||
|
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
pub run: RunCmd,
|
pub run: pezsc_cli::RunCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, clap::Subcommand)]
|
#[derive(Debug, clap::Subcommand)]
|
||||||
@@ -14,33 +12,41 @@ pub struct Cli {
|
|||||||
pub enum Subcommand {
|
pub enum Subcommand {
|
||||||
/// Key management cli utilities
|
/// Key management cli utilities
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
Key(sc_cli::KeySubcommand),
|
Key(pezsc_cli::KeySubcommand),
|
||||||
|
|
||||||
/// Build a chain specification.
|
/// Build a chain specification.
|
||||||
BuildSpec(sc_cli::BuildSpecCmd),
|
/// DEPRECATED: `build-spec` command will be removed after 1/04/2026. Use `export-chain-spec`
|
||||||
|
/// command instead.
|
||||||
|
#[deprecated(
|
||||||
|
note = "build-spec command will be removed after 1/04/2026. Use export-chain-spec command instead"
|
||||||
|
)]
|
||||||
|
BuildSpec(pezsc_cli::BuildSpecCmd),
|
||||||
|
|
||||||
|
/// Export the chain specification.
|
||||||
|
ExportChainSpec(pezsc_cli::ExportChainSpecCmd),
|
||||||
|
|
||||||
/// Validate blocks.
|
/// Validate blocks.
|
||||||
CheckBlock(sc_cli::CheckBlockCmd),
|
CheckBlock(pezsc_cli::CheckBlockCmd),
|
||||||
|
|
||||||
/// Export blocks.
|
/// Export blocks.
|
||||||
ExportBlocks(sc_cli::ExportBlocksCmd),
|
ExportBlocks(pezsc_cli::ExportBlocksCmd),
|
||||||
|
|
||||||
/// Export the state of a given block into a chain spec.
|
/// Export the state of a given block into a chain spec.
|
||||||
ExportState(sc_cli::ExportStateCmd),
|
ExportState(pezsc_cli::ExportStateCmd),
|
||||||
|
|
||||||
/// Import blocks.
|
/// Import blocks.
|
||||||
ImportBlocks(sc_cli::ImportBlocksCmd),
|
ImportBlocks(pezsc_cli::ImportBlocksCmd),
|
||||||
|
|
||||||
/// Remove the whole chain.
|
/// Remove the whole chain.
|
||||||
PurgeChain(sc_cli::PurgeChainCmd),
|
PurgeChain(pezsc_cli::PurgeChainCmd),
|
||||||
|
|
||||||
/// Revert the chain to a previous state.
|
/// Revert the chain to a previous state.
|
||||||
Revert(sc_cli::RevertCmd),
|
Revert(pezsc_cli::RevertCmd),
|
||||||
|
|
||||||
/// Sub-commands concerned with benchmarking.
|
/// Sub-commands concerned with benchmarking.
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
Benchmark(pezframe_benchmarking_cli::BenchmarkCmd),
|
||||||
|
|
||||||
/// Db meta columns information.
|
/// Db meta columns information.
|
||||||
ChainInfo(sc_cli::ChainInfoCmd),
|
ChainInfo(pezsc_cli::ChainInfoCmd),
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-34
@@ -4,19 +4,19 @@ use crate::{
|
|||||||
cli::{Cli, Subcommand},
|
cli::{Cli, Subcommand},
|
||||||
service,
|
service,
|
||||||
};
|
};
|
||||||
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
|
use pez_solochain_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
|
||||||
use sc_cli::SubstrateCli;
|
use pezframe_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, BIZINIKIWI_REFERENCE_HARDWARE};
|
||||||
use sc_service::PartialComponents;
|
use pezsc_cli::BizinikiwiCli;
|
||||||
use solochain_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
|
use pezsc_service::PartialComponents;
|
||||||
use sp_keyring::Sr25519Keyring;
|
use pezsp_keyring::Sr25519Keyring;
|
||||||
|
|
||||||
impl SubstrateCli for Cli {
|
impl BizinikiwiCli for Cli {
|
||||||
fn impl_name() -> String {
|
fn impl_name() -> String {
|
||||||
"Substrate Node".into()
|
"Bizinikiwi Node".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn impl_version() -> String {
|
fn impl_version() -> String {
|
||||||
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
|
env!("BIZINIKIWI_CLI_IMPL_VERSION").into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description() -> String {
|
fn description() -> String {
|
||||||
@@ -35,22 +35,24 @@ impl SubstrateCli for Cli {
|
|||||||
2017
|
2017
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
fn load_spec(&self, id: &str) -> Result<Box<dyn pezsc_service::ChainSpec>, String> {
|
||||||
Ok(match id {
|
Ok(match id {
|
||||||
"dev" => Box::new(chain_spec::development_config()?),
|
"dev" => Box::new(chain_spec::development_chain_spec()?),
|
||||||
"" | "local" => Box::new(chain_spec::local_testnet_config()?),
|
"" | "local" => Box::new(chain_spec::local_chain_spec()?),
|
||||||
path =>
|
path => {
|
||||||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse and run command line arguments
|
/// Parse and run command line arguments
|
||||||
pub fn run() -> sc_cli::Result<()> {
|
pub fn run() -> pezsc_cli::Result<()> {
|
||||||
let cli = Cli::from_args();
|
let cli = Cli::from_args();
|
||||||
|
|
||||||
match &cli.subcommand {
|
match &cli.subcommand {
|
||||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||||
|
#[allow(deprecated)]
|
||||||
Some(Subcommand::BuildSpec(cmd)) => {
|
Some(Subcommand::BuildSpec(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||||
@@ -63,6 +65,10 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
Ok((cmd.run(client, import_queue), task_manager))
|
Ok((cmd.run(client, import_queue), task_manager))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Some(Subcommand::ExportChainSpec(cmd)) => {
|
||||||
|
let chain_spec = cli.load_spec(&cmd.chain)?;
|
||||||
|
cmd.run(chain_spec)
|
||||||
|
},
|
||||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||||
let runner = cli.create_runner(cmd)?;
|
let runner = cli.create_runner(cmd)?;
|
||||||
runner.async_run(|config| {
|
runner.async_run(|config| {
|
||||||
@@ -95,7 +101,7 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
let PartialComponents { client, task_manager, backend, .. } =
|
let PartialComponents { client, task_manager, backend, .. } =
|
||||||
service::new_partial(&config)?;
|
service::new_partial(&config)?;
|
||||||
let aux_revert = Box::new(|client, _, blocks| {
|
let aux_revert = Box::new(|client, _, blocks| {
|
||||||
sc_consensus_grandpa::revert(client, blocks)?;
|
pezsc_consensus_grandpa::revert(client, blocks)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
|
Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
|
||||||
@@ -108,7 +114,7 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
// This switch needs to be in the client, since the client decides
|
// This switch needs to be in the client, since the client decides
|
||||||
// which sub-commands it wants to support.
|
// which sub-commands it wants to support.
|
||||||
match cmd {
|
match cmd {
|
||||||
BenchmarkCmd::Pallet(cmd) => {
|
BenchmarkCmd::Pezpallet(cmd) => {
|
||||||
if !cfg!(feature = "runtime-benchmarks") {
|
if !cfg!(feature = "runtime-benchmarks") {
|
||||||
return Err(
|
return Err(
|
||||||
"Runtime benchmarking wasn't enabled when building the node. \
|
"Runtime benchmarking wasn't enabled when building the node. \
|
||||||
@@ -117,7 +123,7 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, ()>(Some(
|
cmd.run_with_spec::<pezsp_runtime::traits::HashingFor<Block>, ()>(Some(
|
||||||
config.chain_spec,
|
config.chain_spec,
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
@@ -125,30 +131,28 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
||||||
cmd.run(client)
|
cmd.run(client)
|
||||||
},
|
},
|
||||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
|
||||||
BenchmarkCmd::Storage(_) => Err(
|
|
||||||
"Storage benchmarking can be enabled with `--features runtime-benchmarks`."
|
|
||||||
.into(),
|
|
||||||
),
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
BenchmarkCmd::Storage(cmd) => {
|
BenchmarkCmd::Storage(cmd) => {
|
||||||
let PartialComponents { client, backend, .. } =
|
let PartialComponents { client, backend, .. } =
|
||||||
service::new_partial(&config)?;
|
service::new_partial(&config)?;
|
||||||
let db = backend.expose_db();
|
let db = backend.expose_db();
|
||||||
let storage = backend.expose_storage();
|
let storage = backend.expose_storage();
|
||||||
|
let shared_cache = backend.expose_shared_trie_cache();
|
||||||
|
|
||||||
cmd.run(config, client, db, storage)
|
cmd.run(config, client, db, storage, shared_cache)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Overhead(cmd) => {
|
BenchmarkCmd::Overhead(cmd) => {
|
||||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
||||||
let ext_builder = RemarkBuilder::new(client.clone());
|
let ext_builder = RemarkBuilder::new(client.clone());
|
||||||
|
|
||||||
cmd.run(
|
cmd.run(
|
||||||
config,
|
config.chain_spec.name().into(),
|
||||||
client,
|
client,
|
||||||
inherent_benchmark_data()?,
|
inherent_benchmark_data()?,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ext_builder,
|
&ext_builder,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Extrinsic(cmd) => {
|
BenchmarkCmd::Extrinsic(cmd) => {
|
||||||
@@ -165,8 +169,9 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
|
|
||||||
cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory)
|
cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Machine(cmd) =>
|
BenchmarkCmd::Machine(cmd) => {
|
||||||
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
cmd.run(&config, BIZINIKIWI_REFERENCE_HARDWARE.clone())
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -178,16 +183,16 @@ pub fn run() -> sc_cli::Result<()> {
|
|||||||
let runner = cli.create_runner(&cli.run)?;
|
let runner = cli.create_runner(&cli.run)?;
|
||||||
runner.run_node_until_exit(|config| async move {
|
runner.run_node_until_exit(|config| async move {
|
||||||
match config.network.network_backend {
|
match config.network.network_backend {
|
||||||
sc_network::config::NetworkBackendType::Libp2p => service::new_full::<
|
pezsc_network::config::NetworkBackendType::Libp2p => service::new_full::<
|
||||||
sc_network::NetworkWorker<
|
pezsc_network::NetworkWorker<
|
||||||
solochain_template_runtime::opaque::Block,
|
pez_solochain_template_runtime::opaque::Block,
|
||||||
<solochain_template_runtime::opaque::Block as sp_runtime::traits::Block>::Hash,
|
<pez_solochain_template_runtime::opaque::Block as pezsp_runtime::traits::Block>::Hash,
|
||||||
>,
|
>,
|
||||||
>(config)
|
>(config)
|
||||||
.map_err(sc_cli::Error::Service),
|
.map_err(pezsc_cli::Error::Service),
|
||||||
sc_network::config::NetworkBackendType::Litep2p =>
|
pezsc_network::config::NetworkBackendType::Litep2p =>
|
||||||
service::new_full::<sc_network::Litep2pNetworkBackend>(config)
|
service::new_full::<pezsc_network::Litep2pNetworkBackend>(config)
|
||||||
.map_err(sc_cli::Error::Service),
|
.map_err(pezsc_cli::Error::Service),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
//! Substrate Node Template CLI library.
|
//! Bizinikiwi Node Template CLI library.
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
@@ -8,6 +8,6 @@ mod command;
|
|||||||
mod rpc;
|
mod rpc;
|
||||||
mod service;
|
mod service;
|
||||||
|
|
||||||
fn main() -> sc_cli::Result<()> {
|
fn main() -> pezsc_cli::Result<()> {
|
||||||
command::run()
|
command::run()
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-17
@@ -1,6 +1,6 @@
|
|||||||
//! A collection of node-specific RPC methods.
|
//! A collection of node-specific RPC methods.
|
||||||
//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
|
//! Bizinikiwi provides the `sc-rpc` crate, which defines the core RPC layer
|
||||||
//! used by Substrate nodes. This file extends those RPC definitions with
|
//! used by Bizinikiwi nodes. This file extends those RPC definitions with
|
||||||
//! capabilities that are specific to this project's runtime configuration.
|
//! capabilities that are specific to this project's runtime configuration.
|
||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
@@ -8,13 +8,11 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use jsonrpsee::RpcModule;
|
use jsonrpsee::RpcModule;
|
||||||
use sc_transaction_pool_api::TransactionPool;
|
use pez_solochain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
|
||||||
use solochain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
|
use pezsc_transaction_pool_api::TransactionPool;
|
||||||
use sp_api::ProvideRuntimeApi;
|
use pezsp_api::ProvideRuntimeApi;
|
||||||
use sp_block_builder::BlockBuilder;
|
use pezsp_block_builder::BlockBuilder;
|
||||||
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
use pezsp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
||||||
|
|
||||||
pub use sc_rpc_api::DenyUnsafe;
|
|
||||||
|
|
||||||
/// Full client dependencies.
|
/// Full client dependencies.
|
||||||
pub struct FullDeps<C, P> {
|
pub struct FullDeps<C, P> {
|
||||||
@@ -22,8 +20,6 @@ pub struct FullDeps<C, P> {
|
|||||||
pub client: Arc<C>,
|
pub client: Arc<C>,
|
||||||
/// Transaction pool instance.
|
/// Transaction pool instance.
|
||||||
pub pool: Arc<P>,
|
pub pool: Arc<P>,
|
||||||
/// Whether to deny unsafe calls
|
|
||||||
pub deny_unsafe: DenyUnsafe,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Instantiate all full RPC extensions.
|
/// Instantiate all full RPC extensions.
|
||||||
@@ -34,18 +30,18 @@ where
|
|||||||
C: ProvideRuntimeApi<Block>,
|
C: ProvideRuntimeApi<Block>,
|
||||||
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
|
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
|
||||||
C: Send + Sync + 'static,
|
C: Send + Sync + 'static,
|
||||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
C::Api: bizinikiwi_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
C::Api: pezpallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||||
C::Api: BlockBuilder<Block>,
|
C::Api: BlockBuilder<Block>,
|
||||||
P: TransactionPool + 'static,
|
P: TransactionPool + 'static,
|
||||||
{
|
{
|
||||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
use bizinikiwi_frame_rpc_system::{System, SystemApiServer};
|
||||||
use substrate_frame_rpc_system::{System, SystemApiServer};
|
use pezpallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
||||||
|
|
||||||
let mut module = RpcModule::new(());
|
let mut module = RpcModule::new(());
|
||||||
let FullDeps { client, pool, deny_unsafe } = deps;
|
let FullDeps { client, pool } = deps;
|
||||||
|
|
||||||
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
module.merge(System::new(client.clone(), pool).into_rpc())?;
|
||||||
module.merge(TransactionPayment::new(client).into_rpc())?;
|
module.merge(TransactionPayment::new(client).into_rpc())?;
|
||||||
|
|
||||||
// Extend this RPC with a custom API by using the following syntax.
|
// Extend this RPC with a custom API by using the following syntax.
|
||||||
|
|||||||
+75
-67
@@ -1,37 +1,42 @@
|
|||||||
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
|
//! Service and ServiceFactory implementation. Specialized wrapper over bizinikiwi service.
|
||||||
|
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use sc_client_api::{Backend, BlockBackend};
|
use pez_solochain_template_runtime::{self, apis::RuntimeApi, opaque::Block};
|
||||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
use pezsc_client_api::{Backend, BlockBackend};
|
||||||
use sc_consensus_grandpa::SharedVoterState;
|
use pezsc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
|
use pezsc_consensus_grandpa::SharedVoterState;
|
||||||
use sc_telemetry::{Telemetry, TelemetryWorker};
|
use pezsc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncConfig};
|
||||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
use pezsc_telemetry::{Telemetry, TelemetryWorker};
|
||||||
use solochain_template_runtime::{self, opaque::Block, RuntimeApi};
|
use pezsc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
use pezsp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
pub(crate) type FullClient = sc_service::TFullClient<
|
pub(crate) type FullClient = pezsc_service::TFullClient<
|
||||||
Block,
|
Block,
|
||||||
RuntimeApi,
|
RuntimeApi,
|
||||||
sc_executor::WasmExecutor<sp_io::SubstrateHostFunctions>,
|
pezsc_executor::WasmExecutor<pezsp_io::BizinikiwiHostFunctions>,
|
||||||
>;
|
>;
|
||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
type FullBackend = pezsc_service::TFullBackend<Block>;
|
||||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
type FullSelectChain = pezsc_consensus::LongestChain<FullBackend, Block>;
|
||||||
|
|
||||||
/// The minimum period of blocks on which justifications will be
|
/// The minimum period of blocks on which justifications will be
|
||||||
/// imported and generated.
|
/// imported and generated.
|
||||||
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
|
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
|
||||||
|
|
||||||
pub type Service = sc_service::PartialComponents<
|
pub type Service = pezsc_service::PartialComponents<
|
||||||
FullClient,
|
FullClient,
|
||||||
FullBackend,
|
FullBackend,
|
||||||
FullSelectChain,
|
FullSelectChain,
|
||||||
sc_consensus::DefaultImportQueue<Block>,
|
pezsc_consensus::DefaultImportQueue<Block>,
|
||||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
pezsc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
|
||||||
(
|
(
|
||||||
sc_consensus_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
pezsc_consensus_grandpa::GrandpaBlockImport<
|
||||||
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
FullBackend,
|
||||||
|
Block,
|
||||||
|
FullClient,
|
||||||
|
FullSelectChain,
|
||||||
|
>,
|
||||||
|
pezsc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||||
Option<Telemetry>,
|
Option<Telemetry>,
|
||||||
),
|
),
|
||||||
>;
|
>;
|
||||||
@@ -41,16 +46,17 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
|||||||
.telemetry_endpoints
|
.telemetry_endpoints
|
||||||
.clone()
|
.clone()
|
||||||
.filter(|x| !x.is_empty())
|
.filter(|x| !x.is_empty())
|
||||||
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
|
.map(|endpoints| -> Result<_, pezsc_telemetry::Error> {
|
||||||
let worker = TelemetryWorker::new(16)?;
|
let worker = TelemetryWorker::new(16)?;
|
||||||
let telemetry = worker.handle().new_telemetry(endpoints);
|
let telemetry = worker.handle().new_telemetry(endpoints);
|
||||||
Ok((worker, telemetry))
|
Ok((worker, telemetry))
|
||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
let executor = sc_service::new_wasm_executor::<sp_io::SubstrateHostFunctions>(config);
|
let executor =
|
||||||
|
pezsc_service::new_wasm_executor::<pezsp_io::BizinikiwiHostFunctions>(&config.executor);
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager) =
|
||||||
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
pezsc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||||
config,
|
config,
|
||||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
||||||
executor,
|
executor,
|
||||||
@@ -62,17 +68,20 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
|||||||
telemetry
|
telemetry
|
||||||
});
|
});
|
||||||
|
|
||||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
let select_chain = pezsc_consensus::LongestChain::new(backend.clone());
|
||||||
|
|
||||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
let transaction_pool = Arc::from(
|
||||||
config.transaction_pool.clone(),
|
pezsc_transaction_pool::Builder::new(
|
||||||
config.role.is_authority().into(),
|
task_manager.spawn_essential_handle(),
|
||||||
config.prometheus_registry(),
|
client.clone(),
|
||||||
task_manager.spawn_essential_handle(),
|
config.role.is_authority().into(),
|
||||||
client.clone(),
|
)
|
||||||
|
.with_options(config.transaction_pool.clone())
|
||||||
|
.with_prometheus(config.prometheus_registry())
|
||||||
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
|
let (grandpa_block_import, grandpa_link) = pezsc_consensus_grandpa::block_import(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
GRANDPA_JUSTIFICATION_PERIOD,
|
GRANDPA_JUSTIFICATION_PERIOD,
|
||||||
&client,
|
&client,
|
||||||
@@ -82,21 +91,21 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
|||||||
|
|
||||||
let cidp_client = client.clone();
|
let cidp_client = client.clone();
|
||||||
let import_queue =
|
let import_queue =
|
||||||
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams {
|
pezsc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams {
|
||||||
block_import: grandpa_block_import.clone(),
|
block_import: grandpa_block_import.clone(),
|
||||||
justification_import: Some(Box::new(grandpa_block_import.clone())),
|
justification_import: Some(Box::new(grandpa_block_import.clone())),
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
create_inherent_data_providers: move |parent_hash, _| {
|
create_inherent_data_providers: move |parent_hash, _| {
|
||||||
let cidp_client = cidp_client.clone();
|
let cidp_client = cidp_client.clone();
|
||||||
async move {
|
async move {
|
||||||
let slot_duration = sc_consensus_aura::standalone::slot_duration_at(
|
let slot_duration = pezsc_consensus_aura::standalone::slot_duration_at(
|
||||||
&*cidp_client,
|
&*cidp_client,
|
||||||
parent_hash,
|
parent_hash,
|
||||||
)?;
|
)?;
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
let timestamp = pezsp_timestamp::InherentDataProvider::from_system_time();
|
||||||
|
|
||||||
let slot =
|
let slot =
|
||||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
pezsp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||||
*timestamp,
|
*timestamp,
|
||||||
slot_duration,
|
slot_duration,
|
||||||
);
|
);
|
||||||
@@ -111,7 +120,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
|||||||
compatibility_mode: Default::default(),
|
compatibility_mode: Default::default(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(sc_service::PartialComponents {
|
Ok(pezsc_service::PartialComponents {
|
||||||
client,
|
client,
|
||||||
backend,
|
backend,
|
||||||
task_manager,
|
task_manager,
|
||||||
@@ -125,11 +134,11 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
|||||||
|
|
||||||
/// Builds a new service for a full client.
|
/// Builds a new service for a full client.
|
||||||
pub fn new_full<
|
pub fn new_full<
|
||||||
N: sc_network::NetworkBackend<Block, <Block as sp_runtime::traits::Block>::Hash>,
|
N: pezsc_network::NetworkBackend<Block, <Block as pezsp_runtime::traits::Block>::Hash>,
|
||||||
>(
|
>(
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
) -> Result<TaskManager, ServiceError> {
|
) -> Result<TaskManager, ServiceError> {
|
||||||
let sc_service::PartialComponents {
|
let pezsc_service::PartialComponents {
|
||||||
client,
|
client,
|
||||||
backend,
|
backend,
|
||||||
mut task_manager,
|
mut task_manager,
|
||||||
@@ -140,34 +149,34 @@ pub fn new_full<
|
|||||||
other: (block_import, grandpa_link, mut telemetry),
|
other: (block_import, grandpa_link, mut telemetry),
|
||||||
} = new_partial(&config)?;
|
} = new_partial(&config)?;
|
||||||
|
|
||||||
let mut net_config = sc_network::config::FullNetworkConfiguration::<
|
let mut net_config = pezsc_network::config::FullNetworkConfiguration::<
|
||||||
Block,
|
Block,
|
||||||
<Block as sp_runtime::traits::Block>::Hash,
|
<Block as pezsp_runtime::traits::Block>::Hash,
|
||||||
N,
|
N,
|
||||||
>::new(&config.network);
|
>::new(&config.network, config.prometheus_registry().cloned());
|
||||||
let metrics = N::register_notification_metrics(config.prometheus_registry());
|
let metrics = N::register_notification_metrics(config.prometheus_registry());
|
||||||
|
|
||||||
let peer_store_handle = net_config.peer_store_handle();
|
let peer_store_handle = net_config.peer_store_handle();
|
||||||
let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
|
let grandpa_protocol_name = pezsc_consensus_grandpa::protocol_standard_name(
|
||||||
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||||
&config.chain_spec,
|
&config.chain_spec,
|
||||||
);
|
);
|
||||||
let (grandpa_protocol_config, grandpa_notification_service) =
|
let (grandpa_protocol_config, grandpa_notification_service) =
|
||||||
sc_consensus_grandpa::grandpa_peers_set_config::<_, N>(
|
pezsc_consensus_grandpa::grandpa_peers_set_config::<_, N>(
|
||||||
grandpa_protocol_name.clone(),
|
grandpa_protocol_name.clone(),
|
||||||
metrics.clone(),
|
metrics.clone(),
|
||||||
peer_store_handle,
|
peer_store_handle,
|
||||||
);
|
);
|
||||||
net_config.add_notification_protocol(grandpa_protocol_config);
|
net_config.add_notification_protocol(grandpa_protocol_config);
|
||||||
|
|
||||||
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
|
let warp_sync = Arc::new(pezsc_consensus_grandpa::warp_proof::NetworkProvider::new(
|
||||||
backend.clone(),
|
backend.clone(),
|
||||||
grandpa_link.shared_authority_set().clone(),
|
grandpa_link.shared_authority_set().clone(),
|
||||||
Vec::default(),
|
Vec::default(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
|
let (network, system_rpc_tx, tx_handler_controller, sync_service) =
|
||||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
pezsc_service::build_network(pezsc_service::BuildNetworkParams {
|
||||||
config: &config,
|
config: &config,
|
||||||
net_config,
|
net_config,
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
@@ -175,16 +184,14 @@ pub fn new_full<
|
|||||||
spawn_handle: task_manager.spawn_handle(),
|
spawn_handle: task_manager.spawn_handle(),
|
||||||
import_queue,
|
import_queue,
|
||||||
block_announce_validator_builder: None,
|
block_announce_validator_builder: None,
|
||||||
warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)),
|
warp_sync_config: Some(WarpSyncConfig::WithProvider(warp_sync)),
|
||||||
block_relay: None,
|
block_relay: None,
|
||||||
metrics,
|
metrics,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if config.offchain_worker.enabled {
|
if config.offchain_worker.enabled {
|
||||||
task_manager.spawn_handle().spawn(
|
let offchain_workers =
|
||||||
"offchain-workers-runner",
|
pezsc_offchain::OffchainWorkers::new(pezsc_offchain::OffchainWorkerOptions {
|
||||||
"offchain-worker",
|
|
||||||
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
|
|
||||||
runtime_api_provider: client.clone(),
|
runtime_api_provider: client.clone(),
|
||||||
is_validator: config.role.is_authority(),
|
is_validator: config.role.is_authority(),
|
||||||
keystore: Some(keystore_container.keystore()),
|
keystore: Some(keystore_container.keystore()),
|
||||||
@@ -195,13 +202,15 @@ pub fn new_full<
|
|||||||
network_provider: Arc::new(network.clone()),
|
network_provider: Arc::new(network.clone()),
|
||||||
enable_http_requests: true,
|
enable_http_requests: true,
|
||||||
custom_extensions: |_| vec![],
|
custom_extensions: |_| vec![],
|
||||||
})
|
})?;
|
||||||
.run(client.clone(), task_manager.spawn_handle())
|
task_manager.spawn_handle().spawn(
|
||||||
.boxed(),
|
"offchain-workers-runner",
|
||||||
|
"offchain-worker",
|
||||||
|
offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let role = config.role.clone();
|
let role = config.role;
|
||||||
let force_authoring = config.force_authoring;
|
let force_authoring = config.force_authoring;
|
||||||
let backoff_authoring_blocks: Option<()> = None;
|
let backoff_authoring_blocks: Option<()> = None;
|
||||||
let name = config.network.node_name.clone();
|
let name = config.network.node_name.clone();
|
||||||
@@ -212,14 +221,13 @@ pub fn new_full<
|
|||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
let pool = transaction_pool.clone();
|
let pool = transaction_pool.clone();
|
||||||
|
|
||||||
Box::new(move |deny_unsafe, _| {
|
Box::new(move |_| {
|
||||||
let deps =
|
let deps = crate::rpc::FullDeps { client: client.clone(), pool: pool.clone() };
|
||||||
crate::rpc::FullDeps { client: client.clone(), pool: pool.clone(), deny_unsafe };
|
|
||||||
crate::rpc::create_full(deps).map_err(Into::into)
|
crate::rpc::create_full(deps).map_err(Into::into)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
let _rpc_handlers = pezsc_service::spawn_tasks(pezsc_service::SpawnTasksParams {
|
||||||
network: Arc::new(network.clone()),
|
network: Arc::new(network.clone()),
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
keystore: keystore_container.keystore(),
|
keystore: keystore_container.keystore(),
|
||||||
@@ -232,10 +240,11 @@ pub fn new_full<
|
|||||||
sync_service: sync_service.clone(),
|
sync_service: sync_service.clone(),
|
||||||
config,
|
config,
|
||||||
telemetry: telemetry.as_mut(),
|
telemetry: telemetry.as_mut(),
|
||||||
|
tracing_execute_block: None,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if role.is_authority() {
|
if role.is_authority() {
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
let proposer_factory = pezsc_basic_authorship::ProposerFactory::new(
|
||||||
task_manager.spawn_handle(),
|
task_manager.spawn_handle(),
|
||||||
client.clone(),
|
client.clone(),
|
||||||
transaction_pool.clone(),
|
transaction_pool.clone(),
|
||||||
@@ -243,9 +252,9 @@ pub fn new_full<
|
|||||||
telemetry.as_ref().map(|x| x.handle()),
|
telemetry.as_ref().map(|x| x.handle()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
|
let slot_duration = pezsc_consensus_aura::slot_duration(&*client)?;
|
||||||
|
|
||||||
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _>(
|
let aura = pezsc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _>(
|
||||||
StartAuraParams {
|
StartAuraParams {
|
||||||
slot_duration,
|
slot_duration,
|
||||||
client,
|
client,
|
||||||
@@ -253,10 +262,10 @@ pub fn new_full<
|
|||||||
block_import,
|
block_import,
|
||||||
proposer_factory,
|
proposer_factory,
|
||||||
create_inherent_data_providers: move |_, ()| async move {
|
create_inherent_data_providers: move |_, ()| async move {
|
||||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
let timestamp = pezsp_timestamp::InherentDataProvider::from_system_time();
|
||||||
|
|
||||||
let slot =
|
let slot =
|
||||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
pezsp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||||
*timestamp,
|
*timestamp,
|
||||||
slot_duration,
|
slot_duration,
|
||||||
);
|
);
|
||||||
@@ -287,7 +296,7 @@ pub fn new_full<
|
|||||||
// need a keystore, regardless of which protocol we use below.
|
// need a keystore, regardless of which protocol we use below.
|
||||||
let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None };
|
let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None };
|
||||||
|
|
||||||
let grandpa_config = sc_consensus_grandpa::Config {
|
let grandpa_config = pezsc_consensus_grandpa::Config {
|
||||||
// FIXME #1578 make this available through chainspec
|
// FIXME #1578 make this available through chainspec
|
||||||
gossip_duration: Duration::from_millis(333),
|
gossip_duration: Duration::from_millis(333),
|
||||||
justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD,
|
justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD,
|
||||||
@@ -305,13 +314,13 @@ pub fn new_full<
|
|||||||
// and vote data availability than the observer. The observer has not
|
// and vote data availability than the observer. The observer has not
|
||||||
// been tested extensively yet and having most nodes in a network run it
|
// been tested extensively yet and having most nodes in a network run it
|
||||||
// could lead to finality stalls.
|
// could lead to finality stalls.
|
||||||
let grandpa_config = sc_consensus_grandpa::GrandpaParams {
|
let grandpa_config = pezsc_consensus_grandpa::GrandpaParams {
|
||||||
config: grandpa_config,
|
config: grandpa_config,
|
||||||
link: grandpa_link,
|
link: grandpa_link,
|
||||||
network,
|
network,
|
||||||
sync: Arc::new(sync_service),
|
sync: Arc::new(sync_service),
|
||||||
notification_service: grandpa_notification_service,
|
notification_service: grandpa_notification_service,
|
||||||
voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(),
|
voting_rule: pezsc_consensus_grandpa::VotingRulesBuilder::default().build(),
|
||||||
prometheus_registry,
|
prometheus_registry,
|
||||||
shared_voter_state: SharedVoterState::empty(),
|
shared_voter_state: SharedVoterState::empty(),
|
||||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||||
@@ -323,10 +332,9 @@ pub fn new_full<
|
|||||||
task_manager.spawn_essential_handle().spawn_blocking(
|
task_manager.spawn_essential_handle().spawn_blocking(
|
||||||
"grandpa-voter",
|
"grandpa-voter",
|
||||||
None,
|
None,
|
||||||
sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?,
|
pezsc_consensus_grandpa::run_grandpa_voter(grandpa_config)?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
network_starter.start_network();
|
|
||||||
Ok(task_manager)
|
Ok(task_manager)
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-23
@@ -1,50 +1,56 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pallet-template"
|
name = "pezpallet-template"
|
||||||
description = "FRAME pallet template for defining custom runtime logic. (polkadot v1.13.0)"
|
description = "Pezframe pezpallet template for defining custom runtime logic."
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
license = "Unlicense"
|
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
|
||||||
|
documentation = "https://docs.rs/pezpallet-template"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
|
codec = { features = ["derive"], workspace = true }
|
||||||
"derive",
|
scale-info = { features = ["derive"], workspace = true }
|
||||||
] }
|
|
||||||
scale-info = { version = "2.11.1", default-features = false, features = [
|
|
||||||
"derive",
|
|
||||||
] }
|
|
||||||
|
|
||||||
# frame deps
|
# frame deps
|
||||||
frame-benchmarking = { version = "35.0.0", default-features = false, optional = true }
|
pezframe-benchmarking = { optional = true, workspace = true }
|
||||||
frame-support = { version = "35.0.0", default-features = false }
|
pezframe-support = { workspace = true }
|
||||||
frame-system = { version = "35.0.0", default-features = false }
|
pezframe-system = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sp-core = { version = "34.0.0" }
|
pezsp-core = { workspace = true, default-features = true }
|
||||||
sp-io = { version = "37.0.0" }
|
pezsp-io = { workspace = true, default-features = true }
|
||||||
sp-runtime = { version = "38.0.0" }
|
pezsp-runtime = { workspace = true, default-features = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"frame-benchmarking?/std",
|
"pezframe-benchmarking?/std",
|
||||||
"frame-support/std",
|
"pezframe-support/std",
|
||||||
"frame-system/std",
|
"pezframe-system/std",
|
||||||
|
"pezsp-core/std",
|
||||||
|
"pezsp-io/std",
|
||||||
|
"pezsp-runtime/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking/runtime-benchmarks",
|
"pezframe-benchmarking/runtime-benchmarks",
|
||||||
"frame-support/runtime-benchmarks",
|
"pezframe-support/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"pezframe-system/runtime-benchmarks",
|
||||||
|
"pezsp-io/runtime-benchmarks",
|
||||||
|
"pezsp-runtime/runtime-benchmarks",
|
||||||
]
|
]
|
||||||
try-runtime = [
|
try-runtime = [
|
||||||
"frame-support/try-runtime",
|
"pezframe-support/try-runtime",
|
||||||
"frame-system/try-runtime",
|
"pezframe-system/try-runtime",
|
||||||
|
"pezsp-runtime/try-runtime",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
//! Benchmarking setup for pallet-template
|
//! Benchmarking setup for pezpallet-template
|
||||||
#![cfg(feature = "runtime-benchmarks")]
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
use crate::Pallet as Template;
|
use crate::Pezpallet as Template;
|
||||||
use frame_benchmarking::v2::*;
|
use pezframe_benchmarking::v2::*;
|
||||||
use frame_system::RawOrigin;
|
use pezframe_system::RawOrigin;
|
||||||
|
|
||||||
#[benchmarks]
|
#[benchmarks]
|
||||||
mod benchmarks {
|
mod benchmarks {
|
||||||
|
|||||||
+76
-70
@@ -1,12 +1,13 @@
|
|||||||
//! # Template Pallet
|
//! # Template Pezpallet
|
||||||
//!
|
//!
|
||||||
//! A pallet with minimal functionality to help developers understand the essential components of
|
//! A pezpallet with minimal functionality to help developers understand the essential components of
|
||||||
//! writing a FRAME pallet. It is typically used in beginner tutorials or in Substrate template
|
//! writing a PEZFRAME pezpallet. It is typically used in beginner tutorials or in Bizinikiwi template
|
||||||
//! nodes as a starting point for creating a new pallet and **not meant to be used in production**.
|
//! nodes as a starting point for creating a new pezpallet and **not meant to be used in
|
||||||
|
//! production**.
|
||||||
//!
|
//!
|
||||||
//! ## Overview
|
//! ## Overview
|
||||||
//!
|
//!
|
||||||
//! This template pallet contains basic examples of:
|
//! This template pezpallet contains basic examples of:
|
||||||
//! - declaring a storage item that stores a single `u32` value
|
//! - declaring a storage item that stores a single `u32` value
|
||||||
//! - declaring and using events
|
//! - declaring and using events
|
||||||
//! - declaring and using errors
|
//! - declaring and using errors
|
||||||
@@ -14,97 +15,102 @@
|
|||||||
//! upon success
|
//! upon success
|
||||||
//! - another dispatchable function that causes a custom error to be thrown
|
//! - another dispatchable function that causes a custom error to be thrown
|
||||||
//!
|
//!
|
||||||
//! Each pallet section is annotated with an attribute using the `#[pallet::...]` procedural macro.
|
//! Each pezpallet section is annotated with an attribute using the `#[pezpallet::...]` procedural
|
||||||
//! This macro generates the necessary code for a pallet to be aggregated into a FRAME runtime.
|
//! macro. This macro generates the necessary code for a pezpallet to be aggregated into a PEZFRAME
|
||||||
|
//! runtime.
|
||||||
//!
|
//!
|
||||||
//! Learn more about FRAME macros [here](https://docs.substrate.io/reference/frame-macros/).
|
//! Learn more about PEZFRAME macros [here](https://docs.pezkuwichain.io/reference/frame-macros/).
|
||||||
//!
|
//!
|
||||||
//! ### Pallet Sections
|
//! ### Pezpallet Sections
|
||||||
//!
|
//!
|
||||||
//! The pallet sections in this template are:
|
//! The pezpallet sections in this template are:
|
||||||
//!
|
//!
|
||||||
//! - A **configuration trait** that defines the types and parameters which the pallet depends on
|
//! - A **configuration trait** that defines the types and parameters which the pezpallet depends on
|
||||||
//! (denoted by the `#[pallet::config]` attribute). See: [`Config`].
|
//! (denoted by the `#[pezpallet::config]` attribute). See: [`Config`].
|
||||||
//! - A **means to store pallet-specific data** (denoted by the `#[pallet::storage]` attribute).
|
//! - A **means to store pezpallet-specific data** (denoted by the `#[pezpallet::storage]`
|
||||||
//! See: [`storage_types`].
|
//! attribute). See: [`storage_types`].
|
||||||
//! - A **declaration of the events** this pallet emits (denoted by the `#[pallet::event]`
|
//! - A **declaration of the events** this pezpallet emits (denoted by the `#[pezpallet::event]`
|
||||||
//! attribute). See: [`Event`].
|
//! attribute). See: [`Event`].
|
||||||
//! - A **declaration of the errors** that this pallet can throw (denoted by the `#[pallet::error]`
|
//! - A **declaration of the errors** that this pezpallet can throw (denoted by the
|
||||||
//! attribute). See: [`Error`].
|
//! `#[pezpallet::error]` attribute). See: [`Error`].
|
||||||
//! - A **set of dispatchable functions** that define the pallet's functionality (denoted by the
|
//! - A **set of dispatchable functions** that define the pezpallet's functionality (denoted by the
|
||||||
//! `#[pallet::call]` attribute). See: [`dispatchables`].
|
//! `#[pezpallet::call]` attribute). See: [`dispatchables`].
|
||||||
//!
|
//!
|
||||||
//! Run `cargo doc --package pallet-template --open` to view this pallet's documentation.
|
//! Run `cargo doc --package pezpallet-template --open` to view this pezpallet's documentation.
|
||||||
|
|
||||||
// We make sure this pallet uses `no_std` for compiling to Wasm.
|
// We make sure this pezpallet uses `no_std` for compiling to Wasm.
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
// Re-export pallet items so that they can be accessed from the crate namespace.
|
// Re-export pezpallet items so that they can be accessed from the crate namespace.
|
||||||
pub use pallet::*;
|
pub use pezpallet::*;
|
||||||
|
|
||||||
// FRAME pallets require their own "mock runtimes" to be able to run unit tests. This module
|
// PEZFRAME pallets require their own "mock runtimes" to be able to run unit tests. This module
|
||||||
// contains a mock runtime specific for testing this pallet's functionality.
|
// contains a mock runtime specific for testing this pezpallet's functionality.
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod mock;
|
mod mock;
|
||||||
|
|
||||||
// This module contains the unit tests for this pallet.
|
// This module contains the unit tests for this pezpallet.
|
||||||
// Learn about pallet unit testing here: https://docs.substrate.io/test/unit-testing/
|
// Learn about pezpallet unit testing here: https://docs.pezkuwichain.io/test/unit-testing/
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
// Every callable function or "dispatchable" a pallet exposes must have weight values that correctly
|
// Every callable function or "dispatchable" a pezpallet exposes must have weight values that
|
||||||
// estimate a dispatchable's execution time. The benchmarking module is used to calculate weights
|
// correctly estimate a dispatchable's execution time. The benchmarking module is used to calculate
|
||||||
// for each dispatchable and generates this pallet's weight.rs file. Learn more about benchmarking here: https://docs.substrate.io/test/benchmark/
|
// weights for each dispatchable and generates this pezpallet's weight.rs file. Learn more about benchmarking here: https://docs.pezkuwichain.io/test/benchmark/
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
mod benchmarking;
|
mod benchmarking;
|
||||||
pub mod weights;
|
pub mod weights;
|
||||||
pub use weights::*;
|
pub use weights::*;
|
||||||
|
|
||||||
// All pallet logic is defined in its own module and must be annotated by the `pallet` attribute.
|
// All pezpallet logic is defined in its own module and must be annotated by the `pezpallet`
|
||||||
#[frame_support::pallet]
|
// attribute.
|
||||||
pub mod pallet {
|
#[pezframe_support::pezpallet]
|
||||||
// Import various useful types required by all FRAME pallets.
|
pub mod pezpallet {
|
||||||
|
// Import various useful types required by all PEZFRAME pallets.
|
||||||
use super::*;
|
use super::*;
|
||||||
use frame_support::pallet_prelude::*;
|
use pezframe_support::pezpallet_prelude::*;
|
||||||
use frame_system::pallet_prelude::*;
|
use pezframe_system::pezpallet_prelude::*;
|
||||||
|
|
||||||
// The `Pallet` struct serves as a placeholder to implement traits, methods and dispatchables
|
// The `Pezpallet` struct serves as a placeholder to implement traits, methods and dispatchables
|
||||||
// (`Call`s) in this pallet.
|
// (`Call`s) in this pezpallet.
|
||||||
#[pallet::pallet]
|
#[pezpallet::pezpallet]
|
||||||
pub struct Pallet<T>(_);
|
pub struct Pezpallet<T>(_);
|
||||||
|
|
||||||
/// The pallet's configuration trait.
|
/// The pezpallet's configuration trait.
|
||||||
///
|
///
|
||||||
/// All our types and constants a pallet depends on must be declared here.
|
/// All our types and constants a pezpallet depends on must be declared here.
|
||||||
/// These types are defined generically and made concrete when the pallet is declared in the
|
/// These types are defined generically and made concrete when the pezpallet is declared in the
|
||||||
/// `runtime/src/lib.rs` file of your chain.
|
/// `runtime/src/lib.rs` file of your chain.
|
||||||
#[pallet::config]
|
#[pezpallet::config]
|
||||||
pub trait Config: frame_system::Config {
|
pub trait Config: pezframe_system::Config {
|
||||||
/// The overarching runtime event type.
|
/// The overarching runtime event type.
|
||||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
#[allow(deprecated)]
|
||||||
/// A type representing the weights required by the dispatchables of this pallet.
|
type RuntimeEvent: From<Event<Self>>
|
||||||
|
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||||
|
/// A type representing the weights required by the dispatchables of this pezpallet.
|
||||||
type WeightInfo: WeightInfo;
|
type WeightInfo: WeightInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A storage item for this pallet.
|
/// A storage item for this pezpallet.
|
||||||
///
|
///
|
||||||
/// In this template, we are declaring a storage item called `Something` that stores a single
|
/// In this template, we are declaring a storage item called `Something` that stores a single
|
||||||
/// `u32` value. Learn more about runtime storage here: <https://docs.substrate.io/build/runtime-storage/>
|
/// `u32` value. Learn more about runtime storage here: <https://docs.pezkuwichain.io/build/runtime-storage/>
|
||||||
#[pallet::storage]
|
#[pezpallet::storage]
|
||||||
pub type Something<T> = StorageValue<_, u32>;
|
pub type Something<T> = StorageValue<_, u32>;
|
||||||
|
|
||||||
/// Events that functions in this pallet can emit.
|
/// Events that functions in this pezpallet can emit.
|
||||||
///
|
///
|
||||||
/// Events are a simple means of indicating to the outside world (such as dApps, chain explorers
|
/// Events are a simple means of indicating to the outside world (such as dApps, chain explorers
|
||||||
/// or other users) that some notable update in the runtime has occurred. In a FRAME pallet, the
|
/// or other users) that some notable update in the runtime has occurred. In a PEZFRAME pezpallet,
|
||||||
/// documentation for each event field and its parameters is added to a node's metadata so it
|
/// the documentation for each event field and its parameters is added to a node's metadata so
|
||||||
/// can be used by external interfaces or tools.
|
/// it can be used by external interfaces or tools.
|
||||||
///
|
///
|
||||||
/// The `generate_deposit` macro generates a function on `Pallet` called `deposit_event` which
|
/// The `generate_deposit` macro generates a function on `Pezpallet` called `deposit_event`
|
||||||
/// will convert the event type of your pallet into `RuntimeEvent` (declared in the pallet's
|
/// which will convert the event type of your pezpallet into `RuntimeEvent` (declared in the
|
||||||
/// [`Config`] trait) and deposit it using [`frame_system::Pallet::deposit_event`].
|
/// pezpallet's [`Config`] trait) and deposit it using
|
||||||
#[pallet::event]
|
/// [`pezframe_system::Pezpallet::deposit_event`].
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pezpallet::event]
|
||||||
|
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
/// A user has successfully set a new value.
|
/// A user has successfully set a new value.
|
||||||
SomethingStored {
|
SomethingStored {
|
||||||
@@ -115,7 +121,7 @@ pub mod pallet {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors that can be returned by this pallet.
|
/// Errors that can be returned by this pezpallet.
|
||||||
///
|
///
|
||||||
/// Errors tell users that something went wrong so it's important that their naming is
|
/// Errors tell users that something went wrong so it's important that their naming is
|
||||||
/// informative. Similar to events, error documentation is added to a node's metadata so it's
|
/// informative. Similar to events, error documentation is added to a node's metadata so it's
|
||||||
@@ -123,7 +129,7 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// This type of runtime error can be up to 4 bytes in size should you want to return additional
|
/// This type of runtime error can be up to 4 bytes in size should you want to return additional
|
||||||
/// information.
|
/// information.
|
||||||
#[pallet::error]
|
#[pezpallet::error]
|
||||||
pub enum Error<T> {
|
pub enum Error<T> {
|
||||||
/// The value retrieved was `None` as no value was previously set.
|
/// The value retrieved was `None` as no value was previously set.
|
||||||
NoneValue,
|
NoneValue,
|
||||||
@@ -131,9 +137,9 @@ pub mod pallet {
|
|||||||
StorageOverflow,
|
StorageOverflow,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The pallet's dispatchable functions ([`Call`]s).
|
/// The pezpallet's dispatchable functions ([`Call`]s).
|
||||||
///
|
///
|
||||||
/// Dispatchable functions allows users to interact with the pallet and invoke state changes.
|
/// Dispatchable functions allows users to interact with the pezpallet and invoke state changes.
|
||||||
/// These functions materialize as "extrinsics", which are often compared to transactions.
|
/// These functions materialize as "extrinsics", which are often compared to transactions.
|
||||||
/// They must always return a `DispatchResult` and be annotated with a weight and call index.
|
/// They must always return a `DispatchResult` and be annotated with a weight and call index.
|
||||||
///
|
///
|
||||||
@@ -143,15 +149,15 @@ pub mod pallet {
|
|||||||
/// will also change which will break backwards compatibility.
|
/// will also change which will break backwards compatibility.
|
||||||
///
|
///
|
||||||
/// The [`weight`] macro is used to assign a weight to each call.
|
/// The [`weight`] macro is used to assign a weight to each call.
|
||||||
#[pallet::call]
|
#[pezpallet::call]
|
||||||
impl<T: Config> Pallet<T> {
|
impl<T: Config> Pezpallet<T> {
|
||||||
/// An example dispatchable that takes a single u32 value as a parameter, writes the value
|
/// An example dispatchable that takes a single u32 value as a parameter, writes the value
|
||||||
/// to storage and emits an event.
|
/// to storage and emits an event.
|
||||||
///
|
///
|
||||||
/// It checks that the _origin_ for this call is _Signed_ and returns a dispatch
|
/// It checks that the _origin_ for this call is _Signed_ and returns a dispatch
|
||||||
/// error if it isn't. Learn more about origins here: <https://docs.substrate.io/build/origins/>
|
/// error if it isn't. Learn more about origins here: <https://docs.pezkuwichain.io/build/origins/>
|
||||||
#[pallet::call_index(0)]
|
#[pezpallet::call_index(0)]
|
||||||
#[pallet::weight(T::WeightInfo::do_something())]
|
#[pezpallet::weight(T::WeightInfo::do_something())]
|
||||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
||||||
// Check that the extrinsic was signed and get the signer.
|
// Check that the extrinsic was signed and get the signer.
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
@@ -179,8 +185,8 @@ pub mod pallet {
|
|||||||
/// - If no value has been set ([`Error::NoneValue`])
|
/// - If no value has been set ([`Error::NoneValue`])
|
||||||
/// - If incrementing the value in storage causes an arithmetic overflow
|
/// - If incrementing the value in storage causes an arithmetic overflow
|
||||||
/// ([`Error::StorageOverflow`])
|
/// ([`Error::StorageOverflow`])
|
||||||
#[pallet::call_index(1)]
|
#[pezpallet::call_index(1)]
|
||||||
#[pallet::weight(T::WeightInfo::cause_error())]
|
#[pezpallet::weight(T::WeightInfo::cause_error())]
|
||||||
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
|
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
|
||||||
let _who = ensure_signed(origin)?;
|
let _who = ensure_signed(origin)?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +1,49 @@
|
|||||||
use crate as pallet_template;
|
use crate as pezpallet_template;
|
||||||
use frame_support::{derive_impl, traits::ConstU16};
|
use pezframe_support::derive_impl;
|
||||||
use sp_core::H256;
|
use pezsp_runtime::BuildStorage;
|
||||||
use sp_runtime::{
|
|
||||||
traits::{BlakeTwo256, IdentityLookup},
|
|
||||||
BuildStorage,
|
|
||||||
};
|
|
||||||
|
|
||||||
type Block = frame_system::mocking::MockBlock<Test>;
|
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||||
|
|
||||||
// Configure a mock runtime to test the pallet.
|
#[pezframe_support::runtime]
|
||||||
frame_support::construct_runtime!(
|
mod runtime {
|
||||||
pub enum Test
|
// The main runtime
|
||||||
{
|
#[runtime::runtime]
|
||||||
System: frame_system,
|
// Runtime Types to be generated
|
||||||
TemplateModule: pallet_template,
|
#[runtime::derive(
|
||||||
}
|
RuntimeCall,
|
||||||
);
|
RuntimeEvent,
|
||||||
|
RuntimeError,
|
||||||
|
RuntimeOrigin,
|
||||||
|
RuntimeFreezeReason,
|
||||||
|
RuntimeHoldReason,
|
||||||
|
RuntimeSlashReason,
|
||||||
|
RuntimeLockId,
|
||||||
|
RuntimeTask,
|
||||||
|
RuntimeViewFunction
|
||||||
|
)]
|
||||||
|
pub struct Test;
|
||||||
|
|
||||||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
|
#[runtime::pezpallet_index(0)]
|
||||||
impl frame_system::Config for Test {
|
pub type System = pezframe_system::Pezpallet<Test>;
|
||||||
type BaseCallFilter = frame_support::traits::Everything;
|
|
||||||
type BlockWeights = ();
|
#[runtime::pezpallet_index(1)]
|
||||||
type BlockLength = ();
|
pub type Template = pezpallet_template::Pezpallet<Test>;
|
||||||
type DbWeight = ();
|
|
||||||
type RuntimeOrigin = RuntimeOrigin;
|
|
||||||
type RuntimeCall = RuntimeCall;
|
|
||||||
type Nonce = u64;
|
|
||||||
type Hash = H256;
|
|
||||||
type Hashing = BlakeTwo256;
|
|
||||||
type AccountId = u64;
|
|
||||||
type Lookup = IdentityLookup<Self::AccountId>;
|
|
||||||
type Block = Block;
|
|
||||||
type RuntimeEvent = RuntimeEvent;
|
|
||||||
type Version = ();
|
|
||||||
type PalletInfo = PalletInfo;
|
|
||||||
type AccountData = ();
|
|
||||||
type OnNewAccount = ();
|
|
||||||
type OnKilledAccount = ();
|
|
||||||
type SystemWeightInfo = ();
|
|
||||||
type SS58Prefix = ConstU16<42>;
|
|
||||||
type OnSetCode = ();
|
|
||||||
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_template::Config for Test {
|
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||||
|
impl pezframe_system::Config for Test {
|
||||||
|
type Block = Block;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_template::Config for Test {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build genesis storage according to the mock runtime.
|
// Build genesis storage according to the mock runtime.
|
||||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||||
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
|
pezframe_system::GenesisConfig::<Test>::default()
|
||||||
|
.build_storage()
|
||||||
|
.unwrap()
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{mock::*, Error, Event, Something};
|
use crate::{mock::*, Error, Event, Something};
|
||||||
use frame_support::{assert_noop, assert_ok};
|
use pezframe_support::{assert_noop, assert_ok};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works_for_default_value() {
|
fn it_works_for_default_value() {
|
||||||
@@ -7,8 +7,8 @@ fn it_works_for_default_value() {
|
|||||||
// Go past genesis block so events get deposited
|
// Go past genesis block so events get deposited
|
||||||
System::set_block_number(1);
|
System::set_block_number(1);
|
||||||
// Dispatch a signed extrinsic.
|
// Dispatch a signed extrinsic.
|
||||||
assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42));
|
assert_ok!(Template::do_something(RuntimeOrigin::signed(1), 42));
|
||||||
// Read pallet storage and assert an expected result.
|
// Read pezpallet storage and assert an expected result.
|
||||||
assert_eq!(Something::<Test>::get(), Some(42));
|
assert_eq!(Something::<Test>::get(), Some(42));
|
||||||
// Assert that the correct event was deposited
|
// Assert that the correct event was deposited
|
||||||
System::assert_last_event(Event::SomethingStored { something: 42, who: 1 }.into());
|
System::assert_last_event(Event::SomethingStored { something: 42, who: 1 }.into());
|
||||||
@@ -19,9 +19,6 @@ fn it_works_for_default_value() {
|
|||||||
fn correct_error_for_none_value() {
|
fn correct_error_for_none_value() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
// Ensure the expected error is thrown when no value is present.
|
// Ensure the expected error is thrown when no value is present.
|
||||||
assert_noop!(
|
assert_noop!(Template::cause_error(RuntimeOrigin::signed(1)), Error::<Test>::NoneValue);
|
||||||
TemplateModule::cause_error(RuntimeOrigin::signed(1)),
|
|
||||||
Error::<Test>::NoneValue
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
//! Autogenerated weights for pallet_template
|
//! Autogenerated weights for pezpallet_template
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
//! WORST CASE MAP SIZE: `1000000`
|
//! WORST CASE MAP SIZE: `1000000`
|
||||||
//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `<UNKNOWN>`
|
//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `<UNKNOWN>`
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
// Executed Command:
|
// Executed Command:
|
||||||
// ../../target/release/node-template
|
// ../../target/release/node-template
|
||||||
// benchmark
|
// benchmark
|
||||||
// pallet
|
// pezpallet
|
||||||
// --chain
|
// --chain
|
||||||
// dev
|
// dev
|
||||||
// --pallet
|
// --pezpallet
|
||||||
// pallet_template
|
// pezpallet_template
|
||||||
// --extrinsic
|
// --extrinsic
|
||||||
// *
|
// *
|
||||||
// --steps=50
|
// --steps=50
|
||||||
@@ -29,20 +29,20 @@
|
|||||||
#![allow(unused_parens)]
|
#![allow(unused_parens)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
/// Weight functions needed for pallet_template.
|
/// Weight functions needed for pezpallet_template.
|
||||||
pub trait WeightInfo {
|
pub trait WeightInfo {
|
||||||
fn do_something() -> Weight;
|
fn do_something() -> Weight;
|
||||||
fn cause_error() -> Weight;
|
fn cause_error() -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Weights for pallet_template using the Substrate node and recommended hardware.
|
/// Weights for pezpallet_template using the Bizinikiwi node and recommended hardware.
|
||||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||||
/// Storage: TemplateModule Something (r:0 w:1)
|
/// Storage: Template Something (r:0 w:1)
|
||||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
/// Proof: Template Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||||
fn do_something() -> Weight {
|
fn do_something() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
@@ -51,8 +51,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
|||||||
Weight::from_parts(9_000_000, 0)
|
Weight::from_parts(9_000_000, 0)
|
||||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||||
}
|
}
|
||||||
/// Storage: TemplateModule Something (r:1 w:1)
|
/// Storage: Template Something (r:1 w:1)
|
||||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
/// Proof: Template Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||||
fn cause_error() -> Weight {
|
fn cause_error() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `32`
|
// Measured: `32`
|
||||||
@@ -66,8 +66,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
|||||||
|
|
||||||
// For backwards compatibility and tests
|
// For backwards compatibility and tests
|
||||||
impl WeightInfo for () {
|
impl WeightInfo for () {
|
||||||
/// Storage: TemplateModule Something (r:0 w:1)
|
/// Storage: Template Something (r:0 w:1)
|
||||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
/// Proof: Template Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||||
fn do_something() -> Weight {
|
fn do_something() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `0`
|
// Measured: `0`
|
||||||
@@ -76,8 +76,8 @@ impl WeightInfo for () {
|
|||||||
Weight::from_parts(9_000_000, 0)
|
Weight::from_parts(9_000_000, 0)
|
||||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||||
}
|
}
|
||||||
/// Storage: TemplateModule Something (r:1 w:1)
|
/// Storage: Template Something (r:1 w:1)
|
||||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
/// Proof: Template Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||||
fn cause_error() -> Weight {
|
fn cause_error() -> Weight {
|
||||||
// Proof Size summary in bytes:
|
// Proof Size summary in bytes:
|
||||||
// Measured: `32`
|
// Measured: `32`
|
||||||
|
|||||||
+132
-102
@@ -1,136 +1,166 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "solochain-template-runtime"
|
name = "pez-solochain-template-runtime"
|
||||||
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk. (polkadot v1.13.0)"
|
description = "A solochain runtime template built with Bizinikiwi, part of Pezkuwi Sdk."
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
license = "Unlicense"
|
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
|
||||||
|
documentation = "https://docs.rs/pez-solochain-template-runtime"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
|
codec = { features = ["derive"], workspace = true }
|
||||||
"derive",
|
scale-info = { features = ["derive", "serde"], workspace = true }
|
||||||
] }
|
serde_json = { workspace = true, default-features = false, features = [
|
||||||
scale-info = { version = "2.11.1", default-features = false, features = [
|
"alloc",
|
||||||
"derive",
|
|
||||||
"serde",
|
|
||||||
] }
|
] }
|
||||||
|
|
||||||
# frame
|
# pezframe
|
||||||
frame-support = { version = "35.0.0", default-features = false, features = ["experimental"] }
|
pezframe-executive = { workspace = true }
|
||||||
frame-system = { version = "35.0.0", default-features = false }
|
pezframe-metadata-hash-extension = { workspace = true }
|
||||||
frame-try-runtime = { version = "0.41.0", default-features = false, optional = true }
|
pezframe-support = { features = ["experimental"], workspace = true }
|
||||||
frame-executive = { version = "35.0.0", default-features = false }
|
pezframe-system = { workspace = true }
|
||||||
|
pezframe-try-runtime = { optional = true, workspace = true }
|
||||||
|
|
||||||
# frame pallets
|
# pezframe pallets
|
||||||
pallet-aura = { version = "34.0.0", default-features = false }
|
pezpallet-aura = { workspace = true }
|
||||||
pallet-balances = { version = "36.0.0", default-features = false }
|
pezpallet-balances = { workspace = true }
|
||||||
pallet-grandpa = { version = "35.0.0", default-features = false }
|
pezpallet-grandpa = { workspace = true }
|
||||||
pallet-sudo = { version = "35.0.0", default-features = false }
|
pezpallet-sudo = { workspace = true }
|
||||||
pallet-timestamp = { version = "34.0.0", default-features = false }
|
pezpallet-timestamp = { workspace = true }
|
||||||
pallet-transaction-payment = { version = "35.0.0", default-features = false }
|
pezpallet-transaction-payment = { workspace = true }
|
||||||
|
|
||||||
# primitives
|
# primitives
|
||||||
sp-api = { version = "33.0.0", default-features = false }
|
pezsp-api = { workspace = true }
|
||||||
sp-block-builder = { version = "33.0.0", default-features = false }
|
pezsp-block-builder = { workspace = true }
|
||||||
sp-consensus-aura = { version = "0.39.0", default-features = false, features = ["serde"] }
|
pezsp-consensus-aura = { features = ["serde"], workspace = true }
|
||||||
sp-consensus-grandpa = { version = "20.0.0", default-features = false, features = ["serde"] }
|
pezsp-consensus-grandpa = { features = ["serde"], workspace = true }
|
||||||
sp-core = { version = "34.0.0", default-features = false, features = ["serde"] }
|
pezsp-core = { features = ["serde"], workspace = true }
|
||||||
sp-inherents = { version = "33.0.0", default-features = false }
|
pezsp-genesis-builder = { workspace = true }
|
||||||
sp-offchain = { version = "33.0.0", default-features = false }
|
pezsp-inherents = { workspace = true }
|
||||||
sp-runtime = { version = "38.0.0", default-features = false, features = ["serde"] }
|
pezsp-keyring = { workspace = true }
|
||||||
sp-session = { version = "34.0.0", default-features = false }
|
pezsp-offchain = { workspace = true }
|
||||||
sp-std = { version = "14.0.0", default-features = false }
|
pezsp-runtime = { features = ["serde"], workspace = true }
|
||||||
sp-storage = { version = "21.0.0", default-features = false }
|
pezsp-session = { workspace = true }
|
||||||
sp-transaction-pool = { version = "33.0.0", default-features = false }
|
pezsp-storage = { workspace = true }
|
||||||
sp-version = { version = "36.0.0", default-features = false, features = ["serde"] }
|
pezsp-transaction-pool = { workspace = true }
|
||||||
sp-genesis-builder = { version = "0.14.0", default-features = false }
|
pezsp-version = { features = ["serde"], workspace = true }
|
||||||
|
|
||||||
# RPC related
|
# RPC related
|
||||||
frame-system-rpc-runtime-api = { version = "33.0.0", default-features = false }
|
pezframe-system-rpc-runtime-api = { workspace = true }
|
||||||
pallet-transaction-payment-rpc-runtime-api = { version = "35.0.0", default-features = false }
|
pezpallet-transaction-payment-rpc-runtime-api = { workspace = true }
|
||||||
|
|
||||||
# Used for runtime benchmarking
|
# Used for runtime benchmarking
|
||||||
frame-benchmarking = { version = "35.0.0", default-features = false, optional = true }
|
pezframe-benchmarking = { optional = true, workspace = true }
|
||||||
frame-system-benchmarking = { version = "35.0.0", default-features = false, optional = true }
|
pezframe-system-benchmarking = { optional = true, workspace = true }
|
||||||
|
|
||||||
# The pallet in this template.
|
# The pezpallet in this template.
|
||||||
pallet-template = { path = "../pallets/template", default-features = false, version = "0.1.0" }
|
pezpallet-template = { workspace = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "23.0.0", optional = true }
|
bizinikiwi-wasm-builder = { optional = true, workspace = true, default-features = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
"bizinikiwi-wasm-builder",
|
||||||
"codec/std",
|
"codec/std",
|
||||||
|
"pezframe-benchmarking?/std",
|
||||||
|
"pezframe-executive/std",
|
||||||
|
"pezframe-metadata-hash-extension/std",
|
||||||
|
"pezframe-support/std",
|
||||||
|
"pezframe-system-benchmarking?/std",
|
||||||
|
"pezframe-system-rpc-runtime-api/std",
|
||||||
|
"pezframe-system/std",
|
||||||
|
"pezframe-try-runtime?/std",
|
||||||
|
"pezpallet-aura/std",
|
||||||
|
"pezpallet-balances/std",
|
||||||
|
"pezpallet-grandpa/std",
|
||||||
|
"pezpallet-sudo/std",
|
||||||
|
"pezpallet-template/std",
|
||||||
|
"pezpallet-timestamp/std",
|
||||||
|
"pezpallet-transaction-payment-rpc-runtime-api/std",
|
||||||
|
"pezpallet-transaction-payment/std",
|
||||||
|
"pezsp-api/std",
|
||||||
|
"pezsp-block-builder/std",
|
||||||
|
"pezsp-consensus-aura/std",
|
||||||
|
"pezsp-consensus-grandpa/std",
|
||||||
|
"pezsp-core/std",
|
||||||
|
"pezsp-genesis-builder/std",
|
||||||
|
"pezsp-inherents/std",
|
||||||
|
"pezsp-keyring/std",
|
||||||
|
"pezsp-offchain/std",
|
||||||
|
"pezsp-runtime/std",
|
||||||
|
"pezsp-session/std",
|
||||||
|
"pezsp-storage/std",
|
||||||
|
"pezsp-transaction-pool/std",
|
||||||
|
"pezsp-version/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
|
"serde_json/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 = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking/runtime-benchmarks",
|
"bizinikiwi-wasm-builder?/runtime-benchmarks",
|
||||||
"frame-support/runtime-benchmarks",
|
"pezframe-benchmarking/runtime-benchmarks",
|
||||||
"frame-system-benchmarking/runtime-benchmarks",
|
"pezframe-executive/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"pezframe-metadata-hash-extension/runtime-benchmarks",
|
||||||
"pallet-balances/runtime-benchmarks",
|
"pezframe-support/runtime-benchmarks",
|
||||||
"pallet-grandpa/runtime-benchmarks",
|
"pezframe-system-benchmarking/runtime-benchmarks",
|
||||||
"pallet-sudo/runtime-benchmarks",
|
"pezframe-system-rpc-runtime-api/runtime-benchmarks",
|
||||||
"pallet-template/runtime-benchmarks",
|
"pezframe-system/runtime-benchmarks",
|
||||||
"pallet-timestamp/runtime-benchmarks",
|
"pezframe-try-runtime?/runtime-benchmarks",
|
||||||
"sp-runtime/runtime-benchmarks",
|
"pezpallet-aura/runtime-benchmarks",
|
||||||
|
"pezpallet-balances/runtime-benchmarks",
|
||||||
|
"pezpallet-grandpa/runtime-benchmarks",
|
||||||
|
"pezpallet-sudo/runtime-benchmarks",
|
||||||
|
"pezpallet-template/runtime-benchmarks",
|
||||||
|
"pezpallet-timestamp/runtime-benchmarks",
|
||||||
|
"pezpallet-transaction-payment-rpc-runtime-api/runtime-benchmarks",
|
||||||
|
"pezpallet-transaction-payment/runtime-benchmarks",
|
||||||
|
"pezsp-api/runtime-benchmarks",
|
||||||
|
"pezsp-block-builder/runtime-benchmarks",
|
||||||
|
"pezsp-consensus-aura/runtime-benchmarks",
|
||||||
|
"pezsp-consensus-grandpa/runtime-benchmarks",
|
||||||
|
"pezsp-genesis-builder/runtime-benchmarks",
|
||||||
|
"pezsp-inherents/runtime-benchmarks",
|
||||||
|
"pezsp-keyring/runtime-benchmarks",
|
||||||
|
"pezsp-offchain/runtime-benchmarks",
|
||||||
|
"pezsp-runtime/runtime-benchmarks",
|
||||||
|
"pezsp-session/runtime-benchmarks",
|
||||||
|
"pezsp-transaction-pool/runtime-benchmarks",
|
||||||
|
"pezsp-version/runtime-benchmarks",
|
||||||
|
]
|
||||||
|
try-runtime = [
|
||||||
|
"pezframe-executive/try-runtime",
|
||||||
|
"pezframe-support/try-runtime",
|
||||||
|
"pezframe-system/try-runtime",
|
||||||
|
"pezframe-try-runtime/try-runtime",
|
||||||
|
"pezpallet-aura/try-runtime",
|
||||||
|
"pezpallet-balances/try-runtime",
|
||||||
|
"pezpallet-grandpa/try-runtime",
|
||||||
|
"pezpallet-sudo/try-runtime",
|
||||||
|
"pezpallet-template/try-runtime",
|
||||||
|
"pezpallet-timestamp/try-runtime",
|
||||||
|
"pezpallet-transaction-payment/try-runtime",
|
||||||
|
"pezsp-runtime/try-runtime",
|
||||||
]
|
]
|
||||||
|
|
||||||
try-runtime = [
|
# Enable the metadata hash generation.
|
||||||
"frame-executive/try-runtime",
|
#
|
||||||
"frame-support/try-runtime",
|
# This is hidden behind a feature because it increases the compile time.
|
||||||
"frame-system/try-runtime",
|
# The wasm binary needs to be compiled twice, once to fetch the metadata,
|
||||||
"frame-try-runtime/try-runtime",
|
# generate the metadata hash and then a second time with the
|
||||||
"pallet-aura/try-runtime",
|
# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash`
|
||||||
"pallet-balances/try-runtime",
|
# extension.
|
||||||
"pallet-grandpa/try-runtime",
|
metadata-hash = ["bizinikiwi-wasm-builder/metadata-hash"]
|
||||||
"pallet-sudo/try-runtime",
|
|
||||||
"pallet-template/try-runtime",
|
# A convenience feature for enabling things when doing a build
|
||||||
"pallet-timestamp/try-runtime",
|
# for an on-chain release.
|
||||||
"pallet-transaction-payment/try-runtime",
|
on-chain-release-build = ["metadata-hash", "pezsp-api/disable-logging"]
|
||||||
"sp-runtime/try-runtime",
|
|
||||||
]
|
|
||||||
|
|||||||
+14
-4
@@ -1,6 +1,16 @@
|
|||||||
|
#[cfg(all(feature = "std", feature = "metadata-hash"))]
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(feature = "std")]
|
bizinikiwi_wasm_builder::WasmBuilder::init_with_defaults()
|
||||||
{
|
.enable_metadata_hash("UNIT", 12)
|
||||||
substrate_wasm_builder::WasmBuilder::build_using_defaults();
|
.build();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
|
||||||
|
fn main() {
|
||||||
|
bizinikiwi_wasm_builder::WasmBuilder::build_using_defaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The wasm builder is deactivated when compiling
|
||||||
|
/// this crate for wasm to speed up the compilation.
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
fn main() {}
|
||||||
|
|||||||
@@ -0,0 +1,304 @@
|
|||||||
|
// 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>
|
||||||
|
|
||||||
|
// External crates imports
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
use pezframe_support::{
|
||||||
|
genesis_builder_helper::{build_state, get_preset},
|
||||||
|
weights::Weight,
|
||||||
|
};
|
||||||
|
use pezpallet_grandpa::AuthorityId as GrandpaId;
|
||||||
|
use pezsp_api::impl_runtime_apis;
|
||||||
|
use pezsp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
|
use pezsp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||||
|
use pezsp_runtime::{
|
||||||
|
traits::{Block as BlockT, NumberFor},
|
||||||
|
transaction_validity::{TransactionSource, TransactionValidity},
|
||||||
|
ApplyExtrinsicResult,
|
||||||
|
};
|
||||||
|
use pezsp_version::RuntimeVersion;
|
||||||
|
|
||||||
|
// Local module imports
|
||||||
|
use super::{
|
||||||
|
AccountId, Aura, Balance, Block, Executive, Grandpa, InherentDataExt, Nonce, Runtime,
|
||||||
|
RuntimeCall, RuntimeGenesisConfig, SessionKeys, System, TransactionPayment, VERSION,
|
||||||
|
};
|
||||||
|
|
||||||
|
impl_runtime_apis! {
|
||||||
|
impl pezsp_api::Core<Block> for Runtime {
|
||||||
|
fn version() -> RuntimeVersion {
|
||||||
|
VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute_block(block: <Block as BlockT>::LazyBlock) {
|
||||||
|
Executive::execute_block(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn initialize_block(header: &<Block as BlockT>::Header) -> pezsp_runtime::ExtrinsicInclusionMode {
|
||||||
|
Executive::initialize_block(header)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_api::Metadata<Block> for Runtime {
|
||||||
|
fn metadata() -> OpaqueMetadata {
|
||||||
|
OpaqueMetadata::new(Runtime::metadata().into())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
|
||||||
|
Runtime::metadata_at_version(version)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn metadata_versions() -> Vec<u32> {
|
||||||
|
Runtime::metadata_versions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezframe_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
|
||||||
|
fn execute_view_function(id: pezframe_support::view_functions::ViewFunctionId, input: Vec<u8>) -> Result<Vec<u8>, pezframe_support::view_functions::ViewFunctionDispatchError> {
|
||||||
|
Runtime::execute_view_function(id, input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_block_builder::BlockBuilder<Block> for Runtime {
|
||||||
|
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||||
|
Executive::apply_extrinsic(extrinsic)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn finalize_block() -> <Block as BlockT>::Header {
|
||||||
|
Executive::finalize_block()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inherent_extrinsics(data: pezsp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||||
|
data.create_extrinsics()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_inherents(
|
||||||
|
block: <Block as BlockT>::LazyBlock,
|
||||||
|
data: pezsp_inherents::InherentData,
|
||||||
|
) -> pezsp_inherents::CheckInherentsResult {
|
||||||
|
data.check_extrinsics(&block)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||||
|
fn validate_transaction(
|
||||||
|
source: TransactionSource,
|
||||||
|
tx: <Block as BlockT>::Extrinsic,
|
||||||
|
block_hash: <Block as BlockT>::Hash,
|
||||||
|
) -> TransactionValidity {
|
||||||
|
Executive::validate_transaction(source, tx, block_hash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||||
|
fn offchain_worker(header: &<Block as BlockT>::Header) {
|
||||||
|
Executive::offchain_worker(header)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||||
|
fn slot_duration() -> pezsp_consensus_aura::SlotDuration {
|
||||||
|
pezsp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn authorities() -> Vec<AuraId> {
|
||||||
|
pezpallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_session::SessionKeys<Block> for Runtime {
|
||||||
|
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||||
|
SessionKeys::generate(seed)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_session_keys(
|
||||||
|
encoded: Vec<u8>,
|
||||||
|
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
||||||
|
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_consensus_grandpa::GrandpaApi<Block> for Runtime {
|
||||||
|
fn grandpa_authorities() -> pezsp_consensus_grandpa::AuthorityList {
|
||||||
|
Grandpa::grandpa_authorities()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_set_id() -> pezsp_consensus_grandpa::SetId {
|
||||||
|
Grandpa::current_set_id()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn submit_report_equivocation_unsigned_extrinsic(
|
||||||
|
_equivocation_proof: pezsp_consensus_grandpa::EquivocationProof<
|
||||||
|
<Block as BlockT>::Hash,
|
||||||
|
NumberFor<Block>,
|
||||||
|
>,
|
||||||
|
_key_owner_proof: pezsp_consensus_grandpa::OpaqueKeyOwnershipProof,
|
||||||
|
) -> Option<()> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generate_key_ownership_proof(
|
||||||
|
_set_id: pezsp_consensus_grandpa::SetId,
|
||||||
|
_authority_id: GrandpaId,
|
||||||
|
) -> Option<pezsp_consensus_grandpa::OpaqueKeyOwnershipProof> {
|
||||||
|
// NOTE: this is the only implementation possible since we've
|
||||||
|
// defined our key owner proof type as a bottom type (i.e. a type
|
||||||
|
// with no values).
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezframe_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
|
||||||
|
fn account_nonce(account: AccountId) -> Nonce {
|
||||||
|
System::account_nonce(account)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
|
||||||
|
fn query_info(
|
||||||
|
uxt: <Block as BlockT>::Extrinsic,
|
||||||
|
len: u32,
|
||||||
|
) -> pezpallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
|
||||||
|
TransactionPayment::query_info(uxt, len)
|
||||||
|
}
|
||||||
|
fn query_fee_details(
|
||||||
|
uxt: <Block as BlockT>::Extrinsic,
|
||||||
|
len: u32,
|
||||||
|
) -> pezpallet_transaction_payment::FeeDetails<Balance> {
|
||||||
|
TransactionPayment::query_fee_details(uxt, len)
|
||||||
|
}
|
||||||
|
fn query_weight_to_fee(weight: Weight) -> Balance {
|
||||||
|
TransactionPayment::weight_to_fee(weight)
|
||||||
|
}
|
||||||
|
fn query_length_to_fee(length: u32) -> Balance {
|
||||||
|
TransactionPayment::length_to_fee(length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
|
||||||
|
for Runtime
|
||||||
|
{
|
||||||
|
fn query_call_info(
|
||||||
|
call: RuntimeCall,
|
||||||
|
len: u32,
|
||||||
|
) -> pezpallet_transaction_payment::RuntimeDispatchInfo<Balance> {
|
||||||
|
TransactionPayment::query_call_info(call, len)
|
||||||
|
}
|
||||||
|
fn query_call_fee_details(
|
||||||
|
call: RuntimeCall,
|
||||||
|
len: u32,
|
||||||
|
) -> pezpallet_transaction_payment::FeeDetails<Balance> {
|
||||||
|
TransactionPayment::query_call_fee_details(call, len)
|
||||||
|
}
|
||||||
|
fn query_weight_to_fee(weight: Weight) -> Balance {
|
||||||
|
TransactionPayment::weight_to_fee(weight)
|
||||||
|
}
|
||||||
|
fn query_length_to_fee(length: u32) -> Balance {
|
||||||
|
TransactionPayment::length_to_fee(length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
impl pezframe_benchmarking::Benchmark<Block> for Runtime {
|
||||||
|
fn benchmark_metadata(extra: bool) -> (
|
||||||
|
Vec<pezframe_benchmarking::BenchmarkList>,
|
||||||
|
Vec<pezframe_support::traits::StorageInfo>,
|
||||||
|
) {
|
||||||
|
use pezframe_benchmarking::{baseline, BenchmarkList};
|
||||||
|
use pezframe_support::traits::StorageInfoTrait;
|
||||||
|
use pezframe_system_benchmarking::Pezpallet as SystemBench;
|
||||||
|
use pezframe_system_benchmarking::extensions::Pezpallet as SystemExtensionsBench;
|
||||||
|
use baseline::Pezpallet as BaselineBench;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
let mut list = Vec::<BenchmarkList>::new();
|
||||||
|
list_benchmarks!(list, extra);
|
||||||
|
|
||||||
|
let storage_info = AllPalletsWithSystem::storage_info();
|
||||||
|
|
||||||
|
(list, storage_info)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_local_definitions)]
|
||||||
|
fn dispatch_benchmark(
|
||||||
|
config: pezframe_benchmarking::BenchmarkConfig
|
||||||
|
) -> Result<Vec<pezframe_benchmarking::BenchmarkBatch>, alloc::string::String> {
|
||||||
|
use pezframe_benchmarking::{baseline, BenchmarkBatch};
|
||||||
|
use pezsp_storage::TrackedStorageKey;
|
||||||
|
use pezframe_system_benchmarking::Pezpallet as SystemBench;
|
||||||
|
use pezframe_system_benchmarking::extensions::Pezpallet as SystemExtensionsBench;
|
||||||
|
use baseline::Pezpallet as BaselineBench;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
impl pezframe_system_benchmarking::Config for Runtime {}
|
||||||
|
impl baseline::Config for Runtime {}
|
||||||
|
|
||||||
|
use pezframe_support::traits::WhitelistedStorageKeys;
|
||||||
|
let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
|
||||||
|
|
||||||
|
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||||
|
let params = (&config, &whitelist);
|
||||||
|
add_benchmarks!(params, batches);
|
||||||
|
|
||||||
|
Ok(batches)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "try-runtime")]
|
||||||
|
impl pezframe_try_runtime::TryRuntime<Block> for Runtime {
|
||||||
|
fn on_runtime_upgrade(checks: pezframe_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
|
||||||
|
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||||
|
// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
|
||||||
|
// right here and right now.
|
||||||
|
let weight = Executive::try_runtime_upgrade(checks).unwrap();
|
||||||
|
(weight, super::configs::RuntimeBlockWeights::get().max_block)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute_block(
|
||||||
|
block: <Block as BlockT>::LazyBlock,
|
||||||
|
state_root_check: bool,
|
||||||
|
signature_check: bool,
|
||||||
|
select: pezframe_try_runtime::TryStateSelect
|
||||||
|
) -> Weight {
|
||||||
|
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||||
|
// have a backtrace here.
|
||||||
|
Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezsp_genesis_builder::GenesisBuilder<Block> for Runtime {
|
||||||
|
fn build_state(config: Vec<u8>) -> pezsp_genesis_builder::Result {
|
||||||
|
build_state::<RuntimeGenesisConfig>(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_preset(id: &Option<pezsp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
|
||||||
|
get_preset::<RuntimeGenesisConfig>(id, crate::genesis_config_presets::get_preset)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn preset_names() -> Vec<pezsp_genesis_builder::PresetId> {
|
||||||
|
crate::genesis_config_presets::preset_names()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// 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>
|
||||||
|
|
||||||
|
pezframe_benchmarking::define_benchmarks!(
|
||||||
|
[pezframe_benchmarking, BaselineBench::<Runtime>]
|
||||||
|
[pezframe_system, SystemBench::<Runtime>]
|
||||||
|
[pezframe_system_extensions, SystemExtensionsBench::<Runtime>]
|
||||||
|
[pezpallet_balances, Balances]
|
||||||
|
[pezpallet_timestamp, Timestamp]
|
||||||
|
[pezpallet_sudo, Sudo]
|
||||||
|
[pezpallet_template, Template]
|
||||||
|
);
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
// 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>
|
||||||
|
|
||||||
|
// Bizinikiwi and Pezkuwi dependencies
|
||||||
|
use pezframe_support::{
|
||||||
|
derive_impl, parameter_types,
|
||||||
|
traits::{ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, VariantCountOf},
|
||||||
|
weights::{
|
||||||
|
constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND},
|
||||||
|
IdentityFee, Weight,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use pezframe_system::limits::{BlockLength, BlockWeights};
|
||||||
|
use pezpallet_transaction_payment::{ConstFeeMultiplier, FungibleAdapter, Multiplier};
|
||||||
|
use pezsp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
|
use pezsp_runtime::{traits::One, Perbill};
|
||||||
|
use pezsp_version::RuntimeVersion;
|
||||||
|
|
||||||
|
// Local module imports
|
||||||
|
use super::{
|
||||||
|
AccountId, Aura, Balance, Balances, Block, BlockNumber, Hash, Nonce, PalletInfo, Runtime,
|
||||||
|
RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask,
|
||||||
|
System, EXISTENTIAL_DEPOSIT, SLOT_DURATION, VERSION,
|
||||||
|
};
|
||||||
|
|
||||||
|
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const BlockHashCount: BlockNumber = 2400;
|
||||||
|
pub const Version: RuntimeVersion = VERSION;
|
||||||
|
|
||||||
|
/// We allow for 2 seconds of compute with a 6 second average block time.
|
||||||
|
pub RuntimeBlockWeights: BlockWeights = BlockWeights::with_sensible_defaults(
|
||||||
|
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||||
|
NORMAL_DISPATCH_RATIO,
|
||||||
|
);
|
||||||
|
pub RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
||||||
|
pub const SS58Prefix: u8 = 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All migrations of the runtime, aside from the ones declared in the pallets.
|
||||||
|
///
|
||||||
|
/// This can be a tuple of types, each implementing `OnRuntimeUpgrade`.
|
||||||
|
#[allow(unused_parens)]
|
||||||
|
type SingleBlockMigrations = ();
|
||||||
|
|
||||||
|
/// The default types are being injected by [`derive_impl`](`pezframe_support::derive_impl`) from
|
||||||
|
/// [`SoloChainDefaultConfig`](`struct@pezframe_system::config_preludes::SolochainDefaultConfig`),
|
||||||
|
/// but overridden as needed.
|
||||||
|
#[derive_impl(pezframe_system::config_preludes::SolochainDefaultConfig)]
|
||||||
|
impl pezframe_system::Config for Runtime {
|
||||||
|
/// The block type for the runtime.
|
||||||
|
type Block = Block;
|
||||||
|
/// Block & extrinsics weights: base values and limits.
|
||||||
|
type BlockWeights = RuntimeBlockWeights;
|
||||||
|
/// The maximum length of a block (in bytes).
|
||||||
|
type BlockLength = RuntimeBlockLength;
|
||||||
|
/// The identifier used to distinguish between accounts.
|
||||||
|
type AccountId = AccountId;
|
||||||
|
/// The type for storing how many extrinsics an account has signed.
|
||||||
|
type Nonce = Nonce;
|
||||||
|
/// The type for hashing blocks and tries.
|
||||||
|
type Hash = Hash;
|
||||||
|
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||||
|
type BlockHashCount = BlockHashCount;
|
||||||
|
/// The weight of database operations that the runtime can invoke.
|
||||||
|
type DbWeight = RocksDbWeight;
|
||||||
|
/// Version of the runtime.
|
||||||
|
type Version = Version;
|
||||||
|
/// The data to be stored in an account.
|
||||||
|
type AccountData = pezpallet_balances::AccountData<Balance>;
|
||||||
|
/// This is used as an identifier of the chain. 42 is the generic bizinikiwi prefix.
|
||||||
|
type SS58Prefix = SS58Prefix;
|
||||||
|
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
|
||||||
|
type SingleBlockMigrations = SingleBlockMigrations;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_aura::Config for Runtime {
|
||||||
|
type AuthorityId = AuraId;
|
||||||
|
type DisabledValidators = ();
|
||||||
|
type MaxAuthorities = ConstU32<32>;
|
||||||
|
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||||
|
type SlotDuration = pezpallet_aura::MinimumPeriodTimesTwo<Runtime>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_grandpa::Config for Runtime {
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
|
||||||
|
type WeightInfo = ();
|
||||||
|
type MaxAuthorities = ConstU32<32>;
|
||||||
|
type MaxNominators = ConstU32<0>;
|
||||||
|
type MaxSetIdSessionEntries = ConstU64<0>;
|
||||||
|
|
||||||
|
type KeyOwnerProof = pezsp_core::Void;
|
||||||
|
type EquivocationReportSystem = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_timestamp::Config for Runtime {
|
||||||
|
/// A timestamp: milliseconds since the unix epoch.
|
||||||
|
type Moment = u64;
|
||||||
|
type OnTimestampSet = Aura;
|
||||||
|
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
||||||
|
type WeightInfo = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_balances::Config for Runtime {
|
||||||
|
type MaxLocks = ConstU32<50>;
|
||||||
|
type MaxReserves = ();
|
||||||
|
type ReserveIdentifier = [u8; 8];
|
||||||
|
/// The type for recording an account's balance.
|
||||||
|
type Balance = Balance;
|
||||||
|
/// The ubiquitous event type.
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type DustRemoval = ();
|
||||||
|
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
|
||||||
|
type AccountStore = System;
|
||||||
|
type WeightInfo = pezpallet_balances::weights::BizinikiwiWeight<Runtime>;
|
||||||
|
type FreezeIdentifier = RuntimeFreezeReason;
|
||||||
|
type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
|
||||||
|
type RuntimeHoldReason = RuntimeHoldReason;
|
||||||
|
type RuntimeFreezeReason = RuntimeFreezeReason;
|
||||||
|
type DoneSlashHandler = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub FeeMultiplier: Multiplier = Multiplier::one();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_transaction_payment::Config for Runtime {
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type OnChargeTransaction = FungibleAdapter<Balances, ()>;
|
||||||
|
type OperationalFeeMultiplier = ConstU8<5>;
|
||||||
|
type WeightToFee = IdentityFee<Balance>;
|
||||||
|
type LengthToFee = IdentityFee<Balance>;
|
||||||
|
type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;
|
||||||
|
type WeightInfo = pezpallet_transaction_payment::weights::BizinikiwiWeight<Runtime>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pezpallet_sudo::Config for Runtime {
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type RuntimeCall = RuntimeCall;
|
||||||
|
type WeightInfo = pezpallet_sudo::weights::BizinikiwiWeight<Runtime>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configure the pezpallet-template in pallets/template.
|
||||||
|
impl pezpallet_template::Config for Runtime {
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type WeightInfo = pezpallet_template::weights::BizinikiwiWeight<Runtime>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
// This file is part of Bizinikiwi.
|
||||||
|
|
||||||
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
use crate::{AccountId, BalancesConfig, RuntimeGenesisConfig, SudoConfig};
|
||||||
|
use alloc::{vec, vec::Vec};
|
||||||
|
use pezframe_support::build_struct_json_patch;
|
||||||
|
use pezsp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
|
use pezsp_consensus_grandpa::AuthorityId as GrandpaId;
|
||||||
|
use pezsp_genesis_builder::{self, PresetId};
|
||||||
|
use pezsp_keyring::Sr25519Keyring;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
// Returns the genesis config presets populated with given parameters.
|
||||||
|
fn testnet_genesis(
|
||||||
|
initial_authorities: Vec<(AuraId, GrandpaId)>,
|
||||||
|
endowed_accounts: Vec<AccountId>,
|
||||||
|
root: AccountId,
|
||||||
|
) -> Value {
|
||||||
|
build_struct_json_patch!(RuntimeGenesisConfig {
|
||||||
|
balances: BalancesConfig {
|
||||||
|
balances: endowed_accounts
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(|k| (k, 1u128 << 60))
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
},
|
||||||
|
aura: pezpallet_aura::GenesisConfig {
|
||||||
|
authorities: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
|
||||||
|
},
|
||||||
|
grandpa: pezpallet_grandpa::GenesisConfig {
|
||||||
|
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect::<Vec<_>>(),
|
||||||
|
},
|
||||||
|
sudo: SudoConfig { key: Some(root) },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the development genesis config.
|
||||||
|
pub fn development_config_genesis() -> Value {
|
||||||
|
testnet_genesis(
|
||||||
|
vec![(
|
||||||
|
pezsp_keyring::Sr25519Keyring::Alice.public().into(),
|
||||||
|
pezsp_keyring::Ed25519Keyring::Alice.public().into(),
|
||||||
|
)],
|
||||||
|
vec![
|
||||||
|
Sr25519Keyring::Alice.to_account_id(),
|
||||||
|
Sr25519Keyring::Bob.to_account_id(),
|
||||||
|
Sr25519Keyring::AliceStash.to_account_id(),
|
||||||
|
Sr25519Keyring::BobStash.to_account_id(),
|
||||||
|
],
|
||||||
|
pezsp_keyring::Sr25519Keyring::Alice.to_account_id(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the local genesis config preset.
|
||||||
|
pub fn local_config_genesis() -> Value {
|
||||||
|
testnet_genesis(
|
||||||
|
vec![
|
||||||
|
(
|
||||||
|
pezsp_keyring::Sr25519Keyring::Alice.public().into(),
|
||||||
|
pezsp_keyring::Ed25519Keyring::Alice.public().into(),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
pezsp_keyring::Sr25519Keyring::Bob.public().into(),
|
||||||
|
pezsp_keyring::Ed25519Keyring::Bob.public().into(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
Sr25519Keyring::iter()
|
||||||
|
.filter(|v| v != &Sr25519Keyring::One && v != &Sr25519Keyring::Two)
|
||||||
|
.map(|v| v.to_account_id())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
Sr25519Keyring::Alice.to_account_id(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides the JSON representation of predefined genesis config for given `id`.
|
||||||
|
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
|
||||||
|
let patch = match id.as_ref() {
|
||||||
|
pezsp_genesis_builder::DEV_RUNTIME_PRESET => development_config_genesis(),
|
||||||
|
pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => local_config_genesis(),
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
Some(
|
||||||
|
serde_json::to_string(&patch)
|
||||||
|
.expect("serialization to json is expected to work. qed.")
|
||||||
|
.into_bytes(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List of supported presets.
|
||||||
|
pub fn preset_names() -> Vec<PresetId> {
|
||||||
|
vec![
|
||||||
|
PresetId::from(pezsp_genesis_builder::DEV_RUNTIME_PRESET),
|
||||||
|
PresetId::from(pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET),
|
||||||
|
]
|
||||||
|
}
|
||||||
+162
-530
@@ -3,49 +3,114 @@
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||||
|
|
||||||
use pallet_grandpa::AuthorityId as GrandpaId;
|
pub mod apis;
|
||||||
use sp_api::impl_runtime_apis;
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
mod benchmarks;
|
||||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
pub mod configs;
|
||||||
use sp_runtime::{
|
|
||||||
create_runtime_str, generic, impl_opaque_keys,
|
extern crate alloc;
|
||||||
traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, One, Verify},
|
use alloc::vec::Vec;
|
||||||
transaction_validity::{TransactionSource, TransactionValidity},
|
use pezsp_runtime::{
|
||||||
ApplyExtrinsicResult, MultiSignature,
|
generic, impl_opaque_keys,
|
||||||
|
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
||||||
|
MultiAddress, MultiSignature,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use sp_version::NativeVersion;
|
use pezsp_version::NativeVersion;
|
||||||
use sp_version::RuntimeVersion;
|
use pezsp_version::RuntimeVersion;
|
||||||
|
|
||||||
use frame_support::genesis_builder_helper::{build_state, get_preset};
|
pub use pezframe_system::Call as SystemCall;
|
||||||
pub use frame_support::{
|
pub use pezpallet_balances::Call as BalancesCall;
|
||||||
construct_runtime, derive_impl, parameter_types,
|
pub use pezpallet_timestamp::Call as TimestampCall;
|
||||||
traits::{
|
|
||||||
ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness,
|
|
||||||
StorageInfo,
|
|
||||||
},
|
|
||||||
weights::{
|
|
||||||
constants::{
|
|
||||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND,
|
|
||||||
},
|
|
||||||
IdentityFee, Weight,
|
|
||||||
},
|
|
||||||
StorageValue,
|
|
||||||
};
|
|
||||||
pub use frame_system::Call as SystemCall;
|
|
||||||
pub use pallet_balances::Call as BalancesCall;
|
|
||||||
pub use pallet_timestamp::Call as TimestampCall;
|
|
||||||
use pallet_transaction_payment::{ConstFeeMultiplier, FungibleAdapter, Multiplier};
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use pezsp_runtime::BuildStorage;
|
||||||
pub use sp_runtime::{Perbill, Permill};
|
|
||||||
|
|
||||||
/// Import the template pallet.
|
pub mod genesis_config_presets;
|
||||||
pub use pallet_template;
|
|
||||||
|
|
||||||
/// An index to a block.
|
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
||||||
pub type BlockNumber = u32;
|
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
|
||||||
|
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
|
||||||
|
/// to even the core data structures.
|
||||||
|
pub mod opaque {
|
||||||
|
use super::*;
|
||||||
|
use pezsp_runtime::{
|
||||||
|
generic,
|
||||||
|
traits::{BlakeTwo256, Hash as HashT},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub use pezsp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
|
||||||
|
|
||||||
|
/// Opaque block header type.
|
||||||
|
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||||
|
/// Opaque block type.
|
||||||
|
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||||
|
/// Opaque block identifier type.
|
||||||
|
pub type BlockId = generic::BlockId<Block>;
|
||||||
|
/// Opaque block hash type.
|
||||||
|
pub type Hash = <BlakeTwo256 as HashT>::Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_opaque_keys! {
|
||||||
|
pub struct SessionKeys {
|
||||||
|
pub aura: Aura,
|
||||||
|
pub grandpa: Grandpa,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// To learn more about runtime versioning, see:
|
||||||
|
// https://docs.pezkuwichain.io/main-docs/build/upgrade#runtime-versioning
|
||||||
|
#[pezsp_version::runtime_version]
|
||||||
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
|
spec_name: alloc::borrow::Cow::Borrowed("pez-solochain-template-runtime"),
|
||||||
|
impl_name: alloc::borrow::Cow::Borrowed("pez-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`,
|
||||||
|
// `spec_version`, and `authoring_version` are the same between Wasm and native.
|
||||||
|
// This value is set to 100 to notify Pezkuwi-JS App (https://pezkuwichain.io) to use
|
||||||
|
// the compatible custom types.
|
||||||
|
spec_version: 100,
|
||||||
|
impl_version: 1,
|
||||||
|
apis: apis::RUNTIME_API_VERSIONS,
|
||||||
|
transaction_version: 1,
|
||||||
|
system_version: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
mod block_times {
|
||||||
|
/// This determines the average expected block time that we are targeting. Blocks will be
|
||||||
|
/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by
|
||||||
|
/// `pezpallet_timestamp` which is in turn picked up by `pezpallet_aura` to implement `fn
|
||||||
|
/// slot_duration()`.
|
||||||
|
///
|
||||||
|
/// Change this to adjust the block time.
|
||||||
|
pub const MILLI_SECS_PER_BLOCK: u64 = 6000;
|
||||||
|
|
||||||
|
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
|
||||||
|
// Attempting to do so will brick block production.
|
||||||
|
pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK;
|
||||||
|
}
|
||||||
|
pub use block_times::*;
|
||||||
|
|
||||||
|
// Time is measured by number of blocks.
|
||||||
|
pub const MINUTES: BlockNumber = 60_000 / (MILLI_SECS_PER_BLOCK as BlockNumber);
|
||||||
|
pub const HOURS: BlockNumber = MINUTES * 60;
|
||||||
|
pub const DAYS: BlockNumber = HOURS * 24;
|
||||||
|
|
||||||
|
pub const BLOCK_HASH_COUNT: BlockNumber = 2400;
|
||||||
|
|
||||||
|
// Unit = the base number of indivisible units for balances
|
||||||
|
pub const UNIT: Balance = 1_000_000_000_000;
|
||||||
|
pub const MILLI_UNIT: Balance = 1_000_000_000;
|
||||||
|
pub const MICRO_UNIT: Balance = 1_000_000;
|
||||||
|
|
||||||
|
/// Existential deposit.
|
||||||
|
pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_UNIT;
|
||||||
|
|
||||||
|
/// The version information used to identify this runtime when compiled natively.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub fn native_version() -> NativeVersion {
|
||||||
|
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||||
|
}
|
||||||
|
|
||||||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
|
||||||
pub type Signature = MultiSignature;
|
pub type Signature = MultiSignature;
|
||||||
@@ -61,196 +126,59 @@ pub type Balance = u128;
|
|||||||
pub type Nonce = u32;
|
pub type Nonce = u32;
|
||||||
|
|
||||||
/// A hash of some data used by the chain.
|
/// A hash of some data used by the chain.
|
||||||
pub type Hash = sp_core::H256;
|
pub type Hash = pezsp_core::H256;
|
||||||
|
|
||||||
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
|
/// An index to a block.
|
||||||
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
|
pub type BlockNumber = u32;
|
||||||
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
|
|
||||||
/// to even the core data structures.
|
|
||||||
pub mod opaque {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
|
/// The address format for describing accounts.
|
||||||
|
pub type Address = MultiAddress<AccountId, ()>;
|
||||||
|
|
||||||
/// Opaque block header type.
|
/// Block header type as expected by this runtime.
|
||||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||||
/// Opaque block type.
|
|
||||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
|
||||||
/// Opaque block identifier type.
|
|
||||||
pub type BlockId = generic::BlockId<Block>;
|
|
||||||
|
|
||||||
impl_opaque_keys! {
|
/// Block type as expected by this runtime.
|
||||||
pub struct SessionKeys {
|
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||||
pub aura: Aura,
|
|
||||||
pub grandpa: Grandpa,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// To learn more about runtime versioning, see:
|
/// A Block signed with a Justification
|
||||||
// https://docs.substrate.io/main-docs/build/upgrade#runtime-versioning
|
pub type SignedBlock = generic::SignedBlock<Block>;
|
||||||
#[sp_version::runtime_version]
|
|
||||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|
||||||
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`,
|
|
||||||
// `spec_version`, and `authoring_version` are the same between Wasm and native.
|
|
||||||
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
|
|
||||||
// the compatible custom types.
|
|
||||||
spec_version: 100,
|
|
||||||
impl_version: 1,
|
|
||||||
apis: RUNTIME_API_VERSIONS,
|
|
||||||
transaction_version: 1,
|
|
||||||
state_version: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// This determines the average expected block time that we are targeting.
|
/// BlockId type as expected by this runtime.
|
||||||
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
|
pub type BlockId = generic::BlockId<Block>;
|
||||||
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
|
|
||||||
/// up by `pallet_aura` to implement `fn slot_duration()`.
|
|
||||||
///
|
|
||||||
/// Change this to adjust the block time.
|
|
||||||
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
|
||||||
|
|
||||||
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
|
/// The `TransactionExtension` to the basic transaction logic.
|
||||||
// Attempting to do so will brick block production.
|
pub type TxExtension = (
|
||||||
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
pezframe_system::AuthorizeCall<Runtime>,
|
||||||
|
pezframe_system::CheckNonZeroSender<Runtime>,
|
||||||
|
pezframe_system::CheckSpecVersion<Runtime>,
|
||||||
|
pezframe_system::CheckTxVersion<Runtime>,
|
||||||
|
pezframe_system::CheckGenesis<Runtime>,
|
||||||
|
pezframe_system::CheckEra<Runtime>,
|
||||||
|
pezframe_system::CheckNonce<Runtime>,
|
||||||
|
pezframe_system::CheckWeight<Runtime>,
|
||||||
|
pezpallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||||
|
pezframe_metadata_hash_extension::CheckMetadataHash<Runtime>,
|
||||||
|
pezframe_system::WeightReclaim<Runtime>,
|
||||||
|
);
|
||||||
|
|
||||||
// Time is measured by number of blocks.
|
/// Unchecked extrinsic type as expected by this runtime.
|
||||||
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
|
pub type UncheckedExtrinsic =
|
||||||
pub const HOURS: BlockNumber = MINUTES * 60;
|
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
|
||||||
pub const DAYS: BlockNumber = HOURS * 24;
|
|
||||||
|
|
||||||
/// The version information used to identify this runtime when compiled natively.
|
/// The payload being signed in transactions.
|
||||||
#[cfg(feature = "std")]
|
pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
|
||||||
pub fn native_version() -> NativeVersion {
|
|
||||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
|
||||||
}
|
|
||||||
|
|
||||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
/// Executive: handles dispatch to the various modules.
|
||||||
|
pub type Executive = pezframe_executive::Executive<
|
||||||
parameter_types! {
|
Runtime,
|
||||||
pub const BlockHashCount: BlockNumber = 2400;
|
Block,
|
||||||
pub const Version: RuntimeVersion = VERSION;
|
pezframe_system::ChainContext<Runtime>,
|
||||||
/// We allow for 2 seconds of compute with a 6 second average block time.
|
Runtime,
|
||||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
AllPalletsWithSystem,
|
||||||
frame_system::limits::BlockWeights::with_sensible_defaults(
|
>;
|
||||||
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
|
||||||
NORMAL_DISPATCH_RATIO,
|
|
||||||
);
|
|
||||||
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
|
|
||||||
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
|
||||||
pub const SS58Prefix: u8 = 42;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from
|
|
||||||
/// [`SoloChainDefaultConfig`](`struct@frame_system::config_preludes::SolochainDefaultConfig`),
|
|
||||||
/// but overridden as needed.
|
|
||||||
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
|
|
||||||
impl frame_system::Config for Runtime {
|
|
||||||
/// The block type for the runtime.
|
|
||||||
type Block = Block;
|
|
||||||
/// Block & extrinsics weights: base values and limits.
|
|
||||||
type BlockWeights = BlockWeights;
|
|
||||||
/// The maximum length of a block (in bytes).
|
|
||||||
type BlockLength = BlockLength;
|
|
||||||
/// The identifier used to distinguish between accounts.
|
|
||||||
type AccountId = AccountId;
|
|
||||||
/// The type for storing how many extrinsics an account has signed.
|
|
||||||
type Nonce = Nonce;
|
|
||||||
/// The type for hashing blocks and tries.
|
|
||||||
type Hash = Hash;
|
|
||||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
|
||||||
type BlockHashCount = BlockHashCount;
|
|
||||||
/// The weight of database operations that the runtime can invoke.
|
|
||||||
type DbWeight = RocksDbWeight;
|
|
||||||
/// Version of the runtime.
|
|
||||||
type Version = Version;
|
|
||||||
/// The data to be stored in an account.
|
|
||||||
type AccountData = pallet_balances::AccountData<Balance>;
|
|
||||||
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
|
|
||||||
type SS58Prefix = SS58Prefix;
|
|
||||||
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_aura::Config for Runtime {
|
|
||||||
type AuthorityId = AuraId;
|
|
||||||
type DisabledValidators = ();
|
|
||||||
type MaxAuthorities = ConstU32<32>;
|
|
||||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
|
||||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_grandpa::Config for Runtime {
|
|
||||||
type RuntimeEvent = RuntimeEvent;
|
|
||||||
|
|
||||||
type WeightInfo = ();
|
|
||||||
type MaxAuthorities = ConstU32<32>;
|
|
||||||
type MaxNominators = ConstU32<0>;
|
|
||||||
type MaxSetIdSessionEntries = ConstU64<0>;
|
|
||||||
|
|
||||||
type KeyOwnerProof = sp_core::Void;
|
|
||||||
type EquivocationReportSystem = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_timestamp::Config for Runtime {
|
|
||||||
/// A timestamp: milliseconds since the unix epoch.
|
|
||||||
type Moment = u64;
|
|
||||||
type OnTimestampSet = Aura;
|
|
||||||
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
|
||||||
type WeightInfo = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Existential deposit.
|
|
||||||
pub const EXISTENTIAL_DEPOSIT: u128 = 500;
|
|
||||||
|
|
||||||
impl pallet_balances::Config for Runtime {
|
|
||||||
type MaxLocks = ConstU32<50>;
|
|
||||||
type MaxReserves = ();
|
|
||||||
type ReserveIdentifier = [u8; 8];
|
|
||||||
/// The type for recording an account's balance.
|
|
||||||
type Balance = Balance;
|
|
||||||
/// The ubiquitous event type.
|
|
||||||
type RuntimeEvent = RuntimeEvent;
|
|
||||||
type DustRemoval = ();
|
|
||||||
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
|
|
||||||
type AccountStore = System;
|
|
||||||
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
|
|
||||||
type FreezeIdentifier = ();
|
|
||||||
type MaxFreezes = ();
|
|
||||||
type RuntimeHoldReason = ();
|
|
||||||
type RuntimeFreezeReason = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
parameter_types! {
|
|
||||||
pub FeeMultiplier: Multiplier = Multiplier::one();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_transaction_payment::Config for Runtime {
|
|
||||||
type RuntimeEvent = RuntimeEvent;
|
|
||||||
type OnChargeTransaction = FungibleAdapter<Balances, ()>;
|
|
||||||
type OperationalFeeMultiplier = ConstU8<5>;
|
|
||||||
type WeightToFee = IdentityFee<Balance>;
|
|
||||||
type LengthToFee = IdentityFee<Balance>;
|
|
||||||
type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_sudo::Config for Runtime {
|
|
||||||
type RuntimeEvent = RuntimeEvent;
|
|
||||||
type RuntimeCall = RuntimeCall;
|
|
||||||
type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Configure the pallet-template in pallets/template.
|
|
||||||
impl pallet_template::Config for Runtime {
|
|
||||||
type RuntimeEvent = RuntimeEvent;
|
|
||||||
type WeightInfo = pallet_template::weights::SubstrateWeight<Runtime>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the runtime by composing the FRAME pallets that were previously configured.
|
// Create the runtime by composing the FRAME pallets that were previously configured.
|
||||||
#[frame_support::runtime]
|
#[pezframe_support::runtime]
|
||||||
mod runtime {
|
mod runtime {
|
||||||
#[runtime::runtime]
|
#[runtime::runtime]
|
||||||
#[runtime::derive(
|
#[runtime::derive(
|
||||||
@@ -262,329 +190,33 @@ mod runtime {
|
|||||||
RuntimeHoldReason,
|
RuntimeHoldReason,
|
||||||
RuntimeSlashReason,
|
RuntimeSlashReason,
|
||||||
RuntimeLockId,
|
RuntimeLockId,
|
||||||
RuntimeTask
|
RuntimeTask,
|
||||||
|
RuntimeViewFunction
|
||||||
)]
|
)]
|
||||||
pub struct Runtime;
|
pub struct Runtime;
|
||||||
|
|
||||||
#[runtime::pallet_index(0)]
|
#[runtime::pezpallet_index(0)]
|
||||||
pub type System = frame_system;
|
pub type System = pezframe_system;
|
||||||
|
|
||||||
#[runtime::pallet_index(1)]
|
#[runtime::pezpallet_index(1)]
|
||||||
pub type Timestamp = pallet_timestamp;
|
pub type Timestamp = pezpallet_timestamp;
|
||||||
|
|
||||||
#[runtime::pallet_index(2)]
|
#[runtime::pezpallet_index(2)]
|
||||||
pub type Aura = pallet_aura;
|
pub type Aura = pezpallet_aura;
|
||||||
|
|
||||||
#[runtime::pallet_index(3)]
|
#[runtime::pezpallet_index(3)]
|
||||||
pub type Grandpa = pallet_grandpa;
|
pub type Grandpa = pezpallet_grandpa;
|
||||||
|
|
||||||
#[runtime::pallet_index(4)]
|
#[runtime::pezpallet_index(4)]
|
||||||
pub type Balances = pallet_balances;
|
pub type Balances = pezpallet_balances;
|
||||||
|
|
||||||
#[runtime::pallet_index(5)]
|
#[runtime::pezpallet_index(5)]
|
||||||
pub type TransactionPayment = pallet_transaction_payment;
|
pub type TransactionPayment = pezpallet_transaction_payment;
|
||||||
|
|
||||||
#[runtime::pallet_index(6)]
|
#[runtime::pezpallet_index(6)]
|
||||||
pub type Sudo = pallet_sudo;
|
pub type Sudo = pezpallet_sudo;
|
||||||
|
|
||||||
// Include the custom logic from the pallet-template in the runtime.
|
// Include the custom logic from the pezpallet-template in the runtime.
|
||||||
#[runtime::pallet_index(7)]
|
#[runtime::pezpallet_index(7)]
|
||||||
pub type TemplateModule = pallet_template;
|
pub type Template = pezpallet_template;
|
||||||
}
|
|
||||||
|
|
||||||
/// The address format for describing accounts.
|
|
||||||
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
|
|
||||||
/// Block header type as expected by this runtime.
|
|
||||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
|
||||||
/// Block type as expected by this runtime.
|
|
||||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
|
||||||
/// The SignedExtension to the basic transaction logic.
|
|
||||||
pub type SignedExtra = (
|
|
||||||
frame_system::CheckNonZeroSender<Runtime>,
|
|
||||||
frame_system::CheckSpecVersion<Runtime>,
|
|
||||||
frame_system::CheckTxVersion<Runtime>,
|
|
||||||
frame_system::CheckGenesis<Runtime>,
|
|
||||||
frame_system::CheckEra<Runtime>,
|
|
||||||
frame_system::CheckNonce<Runtime>,
|
|
||||||
frame_system::CheckWeight<Runtime>,
|
|
||||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// All migrations of the runtime, aside from the ones declared in the pallets.
|
|
||||||
///
|
|
||||||
/// This can be a tuple of types, each implementing `OnRuntimeUpgrade`.
|
|
||||||
#[allow(unused_parens)]
|
|
||||||
type Migrations = ();
|
|
||||||
|
|
||||||
/// Unchecked extrinsic type as expected by this runtime.
|
|
||||||
pub type UncheckedExtrinsic =
|
|
||||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
|
||||||
/// The payload being signed in transactions.
|
|
||||||
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
|
|
||||||
/// Executive: handles dispatch to the various modules.
|
|
||||||
pub type Executive = frame_executive::Executive<
|
|
||||||
Runtime,
|
|
||||||
Block,
|
|
||||||
frame_system::ChainContext<Runtime>,
|
|
||||||
Runtime,
|
|
||||||
AllPalletsWithSystem,
|
|
||||||
Migrations,
|
|
||||||
>;
|
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
|
||||||
mod benches {
|
|
||||||
frame_benchmarking::define_benchmarks!(
|
|
||||||
[frame_benchmarking, BaselineBench::<Runtime>]
|
|
||||||
[frame_system, SystemBench::<Runtime>]
|
|
||||||
[pallet_balances, Balances]
|
|
||||||
[pallet_timestamp, Timestamp]
|
|
||||||
[pallet_sudo, Sudo]
|
|
||||||
[pallet_template, TemplateModule]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_runtime_apis! {
|
|
||||||
impl sp_api::Core<Block> for Runtime {
|
|
||||||
fn version() -> RuntimeVersion {
|
|
||||||
VERSION
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute_block(block: Block) {
|
|
||||||
Executive::execute_block(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn initialize_block(header: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
|
|
||||||
Executive::initialize_block(header)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_api::Metadata<Block> for Runtime {
|
|
||||||
fn metadata() -> OpaqueMetadata {
|
|
||||||
OpaqueMetadata::new(Runtime::metadata().into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
|
|
||||||
Runtime::metadata_at_version(version)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn metadata_versions() -> sp_std::vec::Vec<u32> {
|
|
||||||
Runtime::metadata_versions()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
|
||||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
|
||||||
Executive::apply_extrinsic(extrinsic)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn finalize_block() -> <Block as BlockT>::Header {
|
|
||||||
Executive::finalize_block()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
|
||||||
data.create_extrinsics()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_inherents(
|
|
||||||
block: Block,
|
|
||||||
data: sp_inherents::InherentData,
|
|
||||||
) -> sp_inherents::CheckInherentsResult {
|
|
||||||
data.check_extrinsics(&block)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
|
||||||
fn validate_transaction(
|
|
||||||
source: TransactionSource,
|
|
||||||
tx: <Block as BlockT>::Extrinsic,
|
|
||||||
block_hash: <Block as BlockT>::Hash,
|
|
||||||
) -> TransactionValidity {
|
|
||||||
Executive::validate_transaction(source, tx, block_hash)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
|
|
||||||
fn offchain_worker(header: &<Block as BlockT>::Header) {
|
|
||||||
Executive::offchain_worker(header)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
|
||||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
|
||||||
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
|
||||||
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_session::SessionKeys<Block> for Runtime {
|
|
||||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
|
||||||
opaque::SessionKeys::generate(seed)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decode_session_keys(
|
|
||||||
encoded: Vec<u8>,
|
|
||||||
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
|
|
||||||
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_consensus_grandpa::GrandpaApi<Block> for Runtime {
|
|
||||||
fn grandpa_authorities() -> sp_consensus_grandpa::AuthorityList {
|
|
||||||
Grandpa::grandpa_authorities()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn current_set_id() -> sp_consensus_grandpa::SetId {
|
|
||||||
Grandpa::current_set_id()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn submit_report_equivocation_unsigned_extrinsic(
|
|
||||||
_equivocation_proof: sp_consensus_grandpa::EquivocationProof<
|
|
||||||
<Block as BlockT>::Hash,
|
|
||||||
NumberFor<Block>,
|
|
||||||
>,
|
|
||||||
_key_owner_proof: sp_consensus_grandpa::OpaqueKeyOwnershipProof,
|
|
||||||
) -> Option<()> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_key_ownership_proof(
|
|
||||||
_set_id: sp_consensus_grandpa::SetId,
|
|
||||||
_authority_id: GrandpaId,
|
|
||||||
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
|
|
||||||
// NOTE: this is the only implementation possible since we've
|
|
||||||
// defined our key owner proof type as a bottom type (i.e. a type
|
|
||||||
// with no values).
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
|
|
||||||
fn account_nonce(account: AccountId) -> Nonce {
|
|
||||||
System::account_nonce(account)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
|
|
||||||
fn query_info(
|
|
||||||
uxt: <Block as BlockT>::Extrinsic,
|
|
||||||
len: u32,
|
|
||||||
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
|
|
||||||
TransactionPayment::query_info(uxt, len)
|
|
||||||
}
|
|
||||||
fn query_fee_details(
|
|
||||||
uxt: <Block as BlockT>::Extrinsic,
|
|
||||||
len: u32,
|
|
||||||
) -> pallet_transaction_payment::FeeDetails<Balance> {
|
|
||||||
TransactionPayment::query_fee_details(uxt, len)
|
|
||||||
}
|
|
||||||
fn query_weight_to_fee(weight: Weight) -> Balance {
|
|
||||||
TransactionPayment::weight_to_fee(weight)
|
|
||||||
}
|
|
||||||
fn query_length_to_fee(length: u32) -> Balance {
|
|
||||||
TransactionPayment::length_to_fee(length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
|
|
||||||
for Runtime
|
|
||||||
{
|
|
||||||
fn query_call_info(
|
|
||||||
call: RuntimeCall,
|
|
||||||
len: u32,
|
|
||||||
) -> pallet_transaction_payment::RuntimeDispatchInfo<Balance> {
|
|
||||||
TransactionPayment::query_call_info(call, len)
|
|
||||||
}
|
|
||||||
fn query_call_fee_details(
|
|
||||||
call: RuntimeCall,
|
|
||||||
len: u32,
|
|
||||||
) -> pallet_transaction_payment::FeeDetails<Balance> {
|
|
||||||
TransactionPayment::query_call_fee_details(call, len)
|
|
||||||
}
|
|
||||||
fn query_weight_to_fee(weight: Weight) -> Balance {
|
|
||||||
TransactionPayment::weight_to_fee(weight)
|
|
||||||
}
|
|
||||||
fn query_length_to_fee(length: u32) -> Balance {
|
|
||||||
TransactionPayment::length_to_fee(length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
|
||||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
|
||||||
fn benchmark_metadata(extra: bool) -> (
|
|
||||||
Vec<frame_benchmarking::BenchmarkList>,
|
|
||||||
Vec<frame_support::traits::StorageInfo>,
|
|
||||||
) {
|
|
||||||
use frame_benchmarking::{baseline, Benchmarking, BenchmarkList};
|
|
||||||
use frame_support::traits::StorageInfoTrait;
|
|
||||||
use frame_system_benchmarking::Pallet as SystemBench;
|
|
||||||
use baseline::Pallet as BaselineBench;
|
|
||||||
|
|
||||||
let mut list = Vec::<BenchmarkList>::new();
|
|
||||||
list_benchmarks!(list, extra);
|
|
||||||
|
|
||||||
let storage_info = AllPalletsWithSystem::storage_info();
|
|
||||||
|
|
||||||
(list, storage_info)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dispatch_benchmark(
|
|
||||||
config: frame_benchmarking::BenchmarkConfig
|
|
||||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
|
||||||
use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch};
|
|
||||||
use sp_storage::TrackedStorageKey;
|
|
||||||
use frame_system_benchmarking::Pallet as SystemBench;
|
|
||||||
use baseline::Pallet as BaselineBench;
|
|
||||||
|
|
||||||
impl frame_system_benchmarking::Config for Runtime {}
|
|
||||||
impl baseline::Config for Runtime {}
|
|
||||||
|
|
||||||
use frame_support::traits::WhitelistedStorageKeys;
|
|
||||||
let whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
|
|
||||||
|
|
||||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
|
||||||
let params = (&config, &whitelist);
|
|
||||||
add_benchmarks!(params, batches);
|
|
||||||
|
|
||||||
Ok(batches)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "try-runtime")]
|
|
||||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
|
||||||
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
|
|
||||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
|
||||||
// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
|
|
||||||
// right here and right now.
|
|
||||||
let weight = Executive::try_runtime_upgrade(checks).unwrap();
|
|
||||||
(weight, BlockWeights::get().max_block)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn execute_block(
|
|
||||||
block: Block,
|
|
||||||
state_root_check: bool,
|
|
||||||
signature_check: bool,
|
|
||||||
select: frame_try_runtime::TryStateSelect
|
|
||||||
) -> Weight {
|
|
||||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
|
||||||
// have a backtrace here.
|
|
||||||
Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
|
|
||||||
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
|
|
||||||
build_state::<RuntimeGenesisConfig>(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
|
|
||||||
get_preset::<RuntimeGenesisConfig>(id, |_| None)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user