Compare commits
10 Commits
7c8393328e
...
d8312e32f8
Author | SHA1 | Date |
---|---|---|
Bazsalanszky | d8312e32f8 | |
dependabot[bot] | 41ad4a6c9d | |
dependabot[bot] | f3083ac2c1 | |
dependabot[bot] | f621c2a4c6 | |
Paritytech CI | e6bf90cfbf | |
Denis Pisarev | 87b1b4728e | |
Denis Pisarev | 0dc8ee3ebf | |
Denis Pisarev | 74561a411d | |
Paritytech CI | e0c480c0f3 | |
dependabot[bot] | a0efe869fe |
|
@ -0,0 +1,11 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "cargo"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
|
@ -1,53 +0,0 @@
|
|||
# This is an example GitHub action that will build and publish a Docker image to DockerHub
|
||||
# You need to add the following secrets to your GitHub Repository or Organization to make this work
|
||||
# - DOCKER_USERNAME: The username of the DockerHub account. E.g. parity
|
||||
# - DOCKER_TOKEN: Access token for DockerHub, see https://docs.docker.com/docker-hub/access-tokens/. E.g. VVVVVVVV-WWWW-XXXXXX-YYYY-ZZZZZZZZZ
|
||||
# The following are setup as an environment variable below
|
||||
# - DOCKER_REPO: The unique name of the DockerHub repository. E.g. parity/polkadot
|
||||
|
||||
name: Build & Publish Docker Image
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
# Triggers the workflow on push events but only for the main branch
|
||||
# push:
|
||||
# branches: [ main ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Set an environment variable (that can be overriden) for the Docker Repo
|
||||
env:
|
||||
DOCKER_REPO: parity/polkadot
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v2.5.0
|
||||
|
||||
# Login to Docker hub using the credentials stored in the repository secrets
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
|
||||
# Get the commit short hash, to use as the rev
|
||||
- name: Calculate rev hash
|
||||
id: rev
|
||||
run: echo "value=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
# Build and push 2 images, One with the version tag and the other with latest tag
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v3.2.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ env.DOCKER_REPO }}:v${{ steps.rev.outputs.value }}, ${{ env.DOCKER_REPO }}:latest
|
|
@ -20,19 +20,18 @@ jobs:
|
|||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set-Up
|
||||
run: sudo apt install -y git clang curl libssl-dev llvm libudev-dev protobuf-compiler
|
||||
- name: Install linux dependencies
|
||||
run: sudo apt-get install -y clang libssl-dev llvm libudev-dev protobuf-compiler
|
||||
|
||||
- name: Install Rustup
|
||||
- name: Install Rust
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
source ~/.cargo/env
|
||||
rustup default stable
|
||||
rustup update nightly
|
||||
rustup update stable
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
rustup update stable --no-self-update
|
||||
rustup target add wasm32-unknown-unknown
|
||||
|
||||
# Rust cache
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Check Build
|
||||
run: |
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
# This is an example GitHub action that will build and publish the binaries and a Docker image
|
||||
# You need to add the following secrets to your GitHub Repository or Organization to make this work
|
||||
# - DOCKERHUB_USERNAME: The username of the DockerHub account. E.g. parity
|
||||
# - DOCKERHUB_TOKEN: Access token for DockerHub, see https://docs.docker.com/docker-hub/access-tokens/.
|
||||
# The following is set up as an environment variable below
|
||||
# - DOCKER_REPO: The unique name of the DockerHub repository. E.g. parity/polkadot
|
||||
|
||||
name: Release
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
push:
|
||||
# Triggers the workflow on tag push events
|
||||
tags:
|
||||
- v[0-9]+.*
|
||||
|
||||
env:
|
||||
RUST_BACKTRACE: 1
|
||||
CARGO_INCREMENTAL: 0
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
||||
CARGO_NET_RETRY: 10
|
||||
RUSTFLAGS: -D warnings
|
||||
RUSTUP_MAX_RETRIES: 10
|
||||
CARGO_TERM_COLOR: always
|
||||
# Set an environment variable (that can be overriden) for the Docker Repo
|
||||
DOCKER_REPO: tripleight/node-template
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 60
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: taiki-e/create-gh-release-action@v1
|
||||
with:
|
||||
title: $version
|
||||
branch: main
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
upload-assets:
|
||||
name: ${{ matrix.target }}
|
||||
needs:
|
||||
- create-release
|
||||
strategy:
|
||||
matrix:
|
||||
# The list of architechture and OS to build for
|
||||
# You can add or remove targets here if you want
|
||||
#
|
||||
# When updating this list, remember to update the target list in tests too
|
||||
include:
|
||||
# - target: aarch64-unknown-linux-gnu
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
- target: aarch64-apple-darwin
|
||||
os: macos-11
|
||||
- target: x86_64-apple-darwin
|
||||
os: macos-11
|
||||
# - target: universal-apple-darwin
|
||||
# os: macos-11
|
||||
|
||||
# The type of runner that the job will run on
|
||||
# Runs on Ubuntu if other os is not specified above
|
||||
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
|
||||
timeout-minutes: 90
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Rust
|
||||
run: |
|
||||
rustup update stable --no-self-update
|
||||
rustup target add wasm32-unknown-unknown
|
||||
|
||||
- name: Install linux dependencies
|
||||
if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu'))
|
||||
run: |
|
||||
sudo apt-get -qq update
|
||||
sudo apt-get install -y protobuf-compiler
|
||||
|
||||
- name: Install mac dependencies
|
||||
if: startsWith(matrix.os, 'macos')
|
||||
run: brew install protobuf
|
||||
- uses: taiki-e/setup-cross-toolchain-action@v1
|
||||
if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu'))
|
||||
with:
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
# Build and upload the binary to the new release
|
||||
- uses: taiki-e/upload-rust-binary-action@v1
|
||||
with:
|
||||
bin: node-template
|
||||
target: ${{ matrix.target }}
|
||||
tar: all
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload x86_64 linux binary to workflow
|
||||
if: (matrix.target == 'x86_64-unknown-linux-gnu')
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: node-template
|
||||
path: ${{ github.workspace }}/target/x86_64-unknown-linux-gnu/release/node-template
|
||||
|
||||
build-image:
|
||||
# The type of runner that the job will run on
|
||||
needs:
|
||||
- upload-assets
|
||||
runs-on: ubuntu-22.04
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Login to Docker hub using the credentials stored in the repository secrets
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Download the binary from the previous job
|
||||
- name: Download x86_64 linux binary
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: node-template
|
||||
path: ${{ github.workspace }}
|
||||
|
||||
# Build and push 2 images, One with the version tag and the other with latest tag
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Containerfile
|
||||
push: true
|
||||
build-args: |
|
||||
DOCKER_REPO=${{ env.DOCKER_REPO }}
|
||||
tags: |
|
||||
${{ env.DOCKER_REPO }}:${{ github.ref_name }}
|
||||
${{ env.DOCKER_REPO }}:latest
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,8 @@
|
|||
[workspace]
|
||||
members = [
|
||||
members = [
|
||||
"node",
|
||||
"pallets/template",
|
||||
"pallets/zkp_verify",
|
||||
"runtime",
|
||||
]
|
||||
[profile.release]
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
FROM docker.io/library/ubuntu:22.04
|
||||
|
||||
# show backtraces
|
||||
ENV RUST_BACKTRACE 1
|
||||
|
||||
# install tools and dependencies
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
ca-certificates && \
|
||||
# apt cleanup
|
||||
apt-get autoremove -y && \
|
||||
apt-get clean && \
|
||||
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
|
||||
# add user and link ~/.local/share/polkadot to /data
|
||||
useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \
|
||||
mkdir -p /data /polkadot/.local/share && \
|
||||
chown -R polkadot:polkadot /data && \
|
||||
ln -s /data /polkadot/.local/share/node-template
|
||||
|
||||
USER polkadot
|
||||
|
||||
# copy the compiled binary to the container
|
||||
COPY --chown=polkadot:polkadot --chmod=774 node-template /usr/bin/node-template
|
||||
|
||||
# check if executable works in this container
|
||||
RUN /usr/bin/node-template --version
|
||||
|
||||
# ws_port
|
||||
EXPOSE 9930 9333 9944 30333 30334
|
||||
|
||||
CMD ["/usr/bin/node-template"]
|
|
@ -1,24 +1,16 @@
|
|||
This is free and unencumbered software released into the public domain.
|
||||
MIT No Attribution
|
||||
|
||||
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.
|
||||
Copyright Parity Technologies (UK) Ltd.
|
||||
|
||||
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.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so.
|
||||
|
||||
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>
|
||||
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 OR COPYRIGHT
|
||||
HOLDERS 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.
|
|
@ -125,7 +125,7 @@ Take special note of the following:
|
|||
|
||||
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/fundamentals/runtime-development/#frame) to construct a blockchain runtime.
|
||||
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/).
|
||||
|
||||
|
@ -133,19 +133,20 @@ Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this
|
|||
|
||||
- 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://crates.parity.io/frame_support/macro.construct_runtime.html) macro, which is part of the core FRAME Support [system](https://docs.substrate.io/reference/frame-pallets/#system-pallets) library.
|
||||
- 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 [core Substrate repository](https://github.com/paritytech/substrate/tree/master/frame) and a template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs) directory.
|
||||
The runtime in this project is constructed using many FRAME pallets that ship with [the Substrate repository](https://github.com/paritytech/substrate/tree/master/frame) and a template pallet that is [defined in the `pallets`](./pallets/template/src/lib.rs) directory.
|
||||
|
||||
A FRAME pallet is compromised of a number of blockchain primitives:
|
||||
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 and errors](https://docs.substrate.io/build/events-and-errors/) to notify users of important changes in the runtime.
|
||||
- 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.
|
||||
- Config: The `Config` configuration interface is used to define the types and parameters upon which a FRAME pallet depends.
|
||||
|
||||
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
|
||||
|
||||
|
@ -153,8 +154,10 @@ Instead of installing dependencies and building this source directly, consider t
|
|||
|
||||
### Nix
|
||||
|
||||
Install [nix](https://nixos.org/), and optionally [direnv](https://github.com/direnv/direnv) and [lorri](https://github.com/nix-community/lorri) for a fully plug-and-play experience for setting up the development environment.
|
||||
To get all the correct dependencies, activate direnv `direnv allow` and lorri `lorri shell`.
|
||||
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
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1678901627,
|
||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1679262748,
|
||||
"narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustup
|
||||
clang
|
||||
protobuf
|
||||
];
|
||||
|
||||
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
|
||||
};
|
||||
});
|
||||
}
|
|
@ -5,7 +5,7 @@ description = "A fresh FRAME-based Substrate node, ready for hacking."
|
|||
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
|
||||
homepage = "https://substrate.io/"
|
||||
edition = "2021"
|
||||
license = "Unlicense"
|
||||
license = "MIT-0"
|
||||
publish = false
|
||||
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
|
||||
build = "build.rs"
|
||||
|
@ -17,55 +17,55 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||
name = "node-template"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.9", features = ["derive"] }
|
||||
clap = { version = "4.4.2", features = ["derive"] }
|
||||
futures = { version = "0.3.21", features = ["thread-pool"]}
|
||||
|
||||
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-keystore = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-consensus-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-consensus-grandpa = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-inherents = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-keyring = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-network = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-statement-store = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-consensus-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-consensus-grandpa = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-inherents = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-keyring = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
# These dependencies are used for the node template's RPCs
|
||||
jsonrpsee = { version = "0.16.2", features = ["server"] }
|
||||
sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
# These dependencies are used for runtime benchmarking
|
||||
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
# Local Dependencies
|
||||
node-template-runtime = { version = "4.0.0-dev", path = "../runtime" }
|
||||
|
||||
# CLI-specific dependencies
|
||||
try-runtime-cli = { version = "0.10.0-dev", optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
try-runtime-cli = { version = "0.10.0-dev", optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -82,11 +82,8 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
|||
let extrinsic: OpaqueExtrinsic = create_benchmark_extrinsic(
|
||||
self.client.as_ref(),
|
||||
acc,
|
||||
BalancesCall::transfer_keep_alive {
|
||||
dest: self.dest.clone().into(),
|
||||
value: self.value.into(),
|
||||
}
|
||||
.into(),
|
||||
BalancesCall::transfer_keep_alive { dest: self.dest.clone().into(), value: self.value }
|
||||
.into(),
|
||||
nonce,
|
||||
)
|
||||
.into();
|
||||
|
@ -143,10 +140,10 @@ pub fn create_benchmark_extrinsic(
|
|||
let signature = raw_payload.using_encoded(|e| sender.sign(e));
|
||||
|
||||
runtime::UncheckedExtrinsic::new_signed(
|
||||
call.clone(),
|
||||
call,
|
||||
sp_runtime::AccountId32::from(sender.public()).into(),
|
||||
runtime::Signature::Sr25519(signature.clone()),
|
||||
extra.clone(),
|
||||
runtime::Signature::Sr25519(signature),
|
||||
extra,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use node_template_runtime::{
|
||||
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,
|
||||
SystemConfig, WASM_BINARY,
|
||||
AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig, Signature,
|
||||
SudoConfig, SystemConfig, WASM_BINARY,
|
||||
};
|
||||
use sc_service::ChainType;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
|
@ -12,7 +12,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
|
|||
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
|
||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;
|
||||
|
||||
/// Generate a crypto pair from seed.
|
||||
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
|
||||
|
@ -131,11 +131,12 @@ fn testnet_genesis(
|
|||
root_key: AccountId,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
_enable_println: bool,
|
||||
) -> GenesisConfig {
|
||||
GenesisConfig {
|
||||
) -> RuntimeGenesisConfig {
|
||||
RuntimeGenesisConfig {
|
||||
system: SystemConfig {
|
||||
// Add Wasm runtime to storage.
|
||||
code: wasm_binary.to_vec(),
|
||||
..Default::default()
|
||||
},
|
||||
balances: BalancesConfig {
|
||||
// Configure endowed accounts with initial balance of 1 << 60.
|
||||
|
@ -146,6 +147,7 @@ fn testnet_genesis(
|
|||
},
|
||||
grandpa: GrandpaConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
|
||||
..Default::default()
|
||||
},
|
||||
sudo: SudoConfig {
|
||||
// Assign network admin rights.
|
||||
|
|
|
@ -10,6 +10,7 @@ pub struct Cli {
|
|||
}
|
||||
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Subcommand {
|
||||
/// Key management cli utilities
|
||||
#[command(subcommand)]
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
};
|
||||
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
|
||||
use node_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
|
||||
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
|
||||
use sc_cli::SubstrateCli;
|
||||
use sc_service::PartialComponents;
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
|
||||
|
@ -46,10 +46,6 @@ impl SubstrateCli for Cli {
|
|||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
||||
})
|
||||
}
|
||||
|
||||
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
&node_template_runtime::VERSION
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse and run command line arguments
|
||||
|
@ -124,7 +120,7 @@ pub fn run() -> sc_cli::Result<()> {
|
|||
)
|
||||
}
|
||||
|
||||
cmd.run::<Block, service::ExecutorDispatch>(config)
|
||||
cmd.run::<Block, ()>(config)
|
||||
},
|
||||
BenchmarkCmd::Block(cmd) => {
|
||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use jsonrpsee::RpcModule;
|
||||
use node_template_runtime::{opaque::Block, AccountId, Balance, Index};
|
||||
use node_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_block_builder::BlockBuilder;
|
||||
|
@ -34,7 +34,7 @@ where
|
|||
C: ProvideRuntimeApi<Block>,
|
||||
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
|
||||
C: Send + Sync + 'static,
|
||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
|
||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||
C::Api: BlockBuilder<Block>,
|
||||
P: TransactionPool + 'static,
|
||||
|
@ -45,7 +45,7 @@ where
|
|||
let mut module = RpcModule::new(());
|
||||
let FullDeps { client, pool, deny_unsafe } = deps;
|
||||
|
||||
module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
|
||||
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
||||
module.merge(TransactionPayment::new(client).into_rpc())?;
|
||||
|
||||
// Extend this RPC with a custom API by using the following syntax.
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
|
||||
|
||||
use futures::FutureExt;
|
||||
use node_template_runtime::{self, opaque::Block, RuntimeApi};
|
||||
use sc_client_api::BlockBackend;
|
||||
use sc_client_api::{Backend, BlockBackend};
|
||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||
use sc_consensus_grandpa::SharedVoterState;
|
||||
pub use sc_executor::NativeElseWasmExecutor;
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
|
||||
use sc_telemetry::{Telemetry, TelemetryWorker};
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
|
@ -36,6 +37,7 @@ pub(crate) type FullClient =
|
|||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn new_partial(
|
||||
config: &Configuration,
|
||||
) -> Result<
|
||||
|
@ -58,10 +60,6 @@ pub fn new_partial(
|
|||
>,
|
||||
ServiceError,
|
||||
> {
|
||||
if config.keystore_remote.is_some() {
|
||||
return Err(ServiceError::Other("Remote Keystores are not supported.".into()))
|
||||
}
|
||||
|
||||
let telemetry = config
|
||||
.telemetry_endpoints
|
||||
.clone()
|
||||
|
@ -73,13 +71,7 @@ pub fn new_partial(
|
|||
})
|
||||
.transpose()?;
|
||||
|
||||
let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(
|
||||
config.wasm_method,
|
||||
config.default_heap_pages,
|
||||
config.max_runtime_instances,
|
||||
config.runtime_cache_size,
|
||||
);
|
||||
|
||||
let executor = sc_service::new_native_or_wasm_executor(config);
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||
config,
|
||||
|
@ -105,7 +97,7 @@ pub fn new_partial(
|
|||
|
||||
let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
|
||||
client.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
&client,
|
||||
select_chain.clone(),
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
)?;
|
||||
|
@ -147,45 +139,29 @@ pub fn new_partial(
|
|||
})
|
||||
}
|
||||
|
||||
fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
|
||||
// FIXME: here would the concrete keystore be built,
|
||||
// must return a concrete type (NOT `LocalKeystore`) that
|
||||
// implements `CryptoStore` and `SyncCryptoStore`
|
||||
Err("Remote Keystore not supported.")
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
mut task_manager,
|
||||
import_queue,
|
||||
mut keystore_container,
|
||||
keystore_container,
|
||||
select_chain,
|
||||
transaction_pool,
|
||||
other: (block_import, grandpa_link, mut telemetry),
|
||||
} = new_partial(&config)?;
|
||||
|
||||
if let Some(url) = &config.keystore_remote {
|
||||
match remote_keystore(url) {
|
||||
Ok(k) => keystore_container.set_remote_keystore(k),
|
||||
Err(e) =>
|
||||
return Err(ServiceError::Other(format!(
|
||||
"Error hooking up remote keystore for {}: {}",
|
||||
url, e
|
||||
))),
|
||||
};
|
||||
}
|
||||
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
|
||||
|
||||
let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
|
||||
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||
&config.chain_spec,
|
||||
);
|
||||
net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config(
|
||||
grandpa_protocol_name.clone(),
|
||||
));
|
||||
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_consensus_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
|
||||
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
|
||||
backend.clone(),
|
||||
grandpa_link.shared_authority_set().clone(),
|
||||
|
@ -195,6 +171,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
net_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
|
@ -204,11 +181,23 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
sc_service::build_offchain_workers(
|
||||
&config,
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
task_manager.spawn_handle().spawn(
|
||||
"offchain-workers-runner",
|
||||
"offchain-worker",
|
||||
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
|
||||
runtime_api_provider: client.clone(),
|
||||
is_validator: config.role.is_authority(),
|
||||
keystore: Some(keystore_container.keystore()),
|
||||
offchain_db: backend.offchain_storage(),
|
||||
transaction_pool: Some(OffchainTransactionPoolFactory::new(
|
||||
transaction_pool.clone(),
|
||||
)),
|
||||
network_provider: network.clone(),
|
||||
enable_http_requests: true,
|
||||
custom_extensions: |_| vec![],
|
||||
})
|
||||
.run(client.clone(), task_manager.spawn_handle())
|
||||
.boxed(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -233,7 +222,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
network: network.clone(),
|
||||
client: client.clone(),
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
keystore: keystore_container.keystore(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_builder: rpc_extensions_builder,
|
||||
|
@ -249,7 +238,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
transaction_pool.clone(),
|
||||
prometheus_registry.as_ref(),
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
);
|
||||
|
@ -276,7 +265,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
},
|
||||
force_authoring,
|
||||
backoff_authoring_blocks,
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
keystore: keystore_container.keystore(),
|
||||
sync_oracle: sync_service.clone(),
|
||||
justification_sync_link: sync_service.clone(),
|
||||
block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32),
|
||||
|
@ -296,8 +285,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
if enable_grandpa {
|
||||
// if the node isn't actively participating in consensus then it doesn't
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore =
|
||||
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
|
||||
let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None };
|
||||
|
||||
let grandpa_config = sc_consensus_grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
|
@ -326,6 +314,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
|||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool),
|
||||
};
|
||||
|
||||
// the GRANDPA voter task is considered infallible, i.e.
|
||||
|
|
|
@ -5,7 +5,7 @@ description = "FRAME pallet template for defining custom runtime logic."
|
|||
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
|
||||
homepage = "https://substrate.io"
|
||||
edition = "2021"
|
||||
license = "Unlicense"
|
||||
license = "MIT-0"
|
||||
publish = false
|
||||
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
|
||||
|
||||
|
@ -13,18 +13,18 @@ repository = "https://github.com/substrate-developer-hub/substrate-node-template
|
|||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
|
||||
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
|
||||
"derive",
|
||||
] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
|
||||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
|
|
@ -1 +1 @@
|
|||
License: Unlicense
|
||||
License: MIT-0
|
|
@ -1,19 +1,34 @@
|
|||
//! Benchmarking setup for pallet-template
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
use super::*;
|
||||
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as Template;
|
||||
use frame_benchmarking::v1::{benchmarks, whitelisted_caller};
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_system::RawOrigin;
|
||||
|
||||
benchmarks! {
|
||||
do_something {
|
||||
let s in 0 .. 100;
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn do_something() {
|
||||
let value = 100u32.into();
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller), s)
|
||||
verify {
|
||||
assert_eq!(Something::<T>::get(), Some(s));
|
||||
#[extrinsic_call]
|
||||
do_something(RawOrigin::Signed(caller), value);
|
||||
|
||||
assert_eq!(Something::<T>::get(), Some(value));
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn cause_error() {
|
||||
Something::<T>::put(100u32);
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
#[extrinsic_call]
|
||||
cause_error(RawOrigin::Signed(caller));
|
||||
|
||||
assert_eq!(Something::<T>::get(), Some(101u32));
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
|
|
|
@ -13,9 +13,12 @@ mod tests;
|
|||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
pub mod weights;
|
||||
pub use weights::*;
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
|
@ -27,6 +30,8 @@ pub mod pallet {
|
|||
pub trait Config: frame_system::Config {
|
||||
/// Because this pallet emits events, it depends on the runtime's definition of an event.
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
/// Type representing the weight of this pallet
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
// The pallet's runtime storage items.
|
||||
|
@ -64,7 +69,7 @@ pub mod pallet {
|
|||
/// An example dispatchable that takes a singles value as a parameter, writes the value to
|
||||
/// storage and emits an event. This function must be dispatched by a signed extrinsic.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(10_000 + T::DbWeight::get().writes(1).ref_time())]
|
||||
#[pallet::weight(T::WeightInfo::do_something())]
|
||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
||||
// Check that the extrinsic was signed and get the signer.
|
||||
// This function will return an error if the extrinsic is not signed.
|
||||
|
@ -82,7 +87,7 @@ pub mod pallet {
|
|||
|
||||
/// An example dispatchable that may throw a custom error.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1).ref_time())]
|
||||
#[pallet::weight(T::WeightInfo::cause_error())]
|
||||
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
|
||||
let _who = ensure_signed(origin)?;
|
||||
|
||||
|
|
|
@ -2,19 +2,15 @@ use crate as pallet_template;
|
|||
use frame_support::traits::{ConstU16, ConstU64};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system,
|
||||
TemplateModule: pallet_template,
|
||||
|
@ -28,13 +24,12 @@ impl frame_system::Config for Test {
|
|||
type DbWeight = ();
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Nonce = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
|
@ -50,9 +45,10 @@ impl frame_system::Config for Test {
|
|||
|
||||
impl pallet_template::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
// Build genesis storage according to the mock runtime.
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
||||
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
//! Autogenerated weights for pallet_template
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `<UNKNOWN>`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ../../target/release/node-template
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain
|
||||
// dev
|
||||
// --pallet
|
||||
// pallet_template
|
||||
// --extrinsic
|
||||
// *
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --wasm-execution=compiled
|
||||
// --output
|
||||
// pallets/template/src/weights.rs
|
||||
// --template
|
||||
// ../../.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for pallet_template.
|
||||
pub trait WeightInfo {
|
||||
fn do_something() -> Weight;
|
||||
fn cause_error() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for pallet_template using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: TemplateModule Something (r:0 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn do_something() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 8_000_000 picoseconds.
|
||||
Weight::from_parts(9_000_000, 0)
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: TemplateModule Something (r:1 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn cause_error() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `32`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 6_000_000 picoseconds.
|
||||
Weight::from_parts(6_000_000, 1489)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
/// Storage: TemplateModule Something (r:0 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn do_something() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 8_000_000 picoseconds.
|
||||
Weight::from_parts(9_000_000, 0)
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: TemplateModule Something (r:1 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn cause_error() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `32`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 6_000_000 picoseconds.
|
||||
Weight::from_parts(6_000_000, 1489)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
[package]
|
||||
name = "pallet_zkp_verify"
|
||||
version = "4.0.0-dev"
|
||||
description = "FRAME pallet template for defining custom runtime logic."
|
||||
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
|
||||
homepage = "https://substrate.io"
|
||||
edition = "2021"
|
||||
license = "MIT-0"
|
||||
publish = false
|
||||
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
|
||||
"derive",
|
||||
] }
|
||||
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
|
||||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
ark-ec = { version = "^0.4.0", default-features = false }
|
||||
ark-ff = { version = "^0.4.0", default-features = false }
|
||||
ark-groth16 = { version = "^0.4.0", default-features = false }
|
||||
ark-gm17 = { version = "^0.3.0", default-features = false }
|
||||
ark-bn254 = { version = "^0.4.0", features = ["curve"], default-features = false }
|
||||
ark-snark = { version = "0.4.0", default-features = false }
|
||||
ark-bls12-381 = { version = "0.4.0", features = ["curve"], default-features = false }
|
||||
ark-std = { version = "0.4.0", default-features = false }
|
||||
ark-serialize = { version = "0.4.0", features = [ "derive" ], default-features = false }
|
||||
|
||||
dusk-jubjub = { version ="0.13.1", default-features = false}
|
||||
dusk-plonk = {version = "0.17.0", features = ["rkyv-impl","alloc"], default-features = false }
|
||||
dusk-bls12_381 = {version = "0.12.3", features = ["rkyv-impl","pairings","alloc"], default-features = false}
|
||||
rkyv = { version = "0.7.42", features = ["validation","size_32"], default-features = false }
|
||||
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"frame-benchmarking?/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"scale-info/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
|
||||
try-runtime = ["frame-support/try-runtime"]
|
|
@ -0,0 +1 @@
|
|||
License: MIT-0
|
|
@ -0,0 +1,35 @@
|
|||
//! Benchmarking setup for pallet-zkp_verify
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
use super::*;
|
||||
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as ZKPVerify;
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_system::RawOrigin;
|
||||
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn do_something() {
|
||||
let value = 100u32.into();
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
#[extrinsic_call]
|
||||
do_something(RawOrigin::Signed(caller), value);
|
||||
|
||||
assert_eq!(Something::<T>::get(), Some(value));
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn cause_error() {
|
||||
Something::<T>::put(100u32);
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
#[extrinsic_call]
|
||||
cause_error(RawOrigin::Signed(caller));
|
||||
|
||||
assert_eq!(Something::<T>::get(), Some(101u32));
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(ZKPVerify, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
/// Edit this file to define custom logic or remove it if it is not needed.
|
||||
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
|
||||
/// <https://docs.substrate.io/reference/frame-pallets/>
|
||||
pub use pallet::*;
|
||||
use dusk_plonk::prelude::{Proof, Verifier, BlsScalar};
|
||||
use rkyv::Deserialize;
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
pub mod weights;
|
||||
pub use weights::*;
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
use ark_bn254::{Bn254, Fq, Fq2, Fr, G1Affine, G2Affine, Config as Bn254Config};
|
||||
use ark_ec::bn::Bn;
|
||||
use ark_gm17::{prepare_verifying_key as gm17_prepare_verification_key, Proof as gm17_proof, VerifyingKey as gm17_verification_key, verify_proof as gm17_verify_proof, GM17};
|
||||
use ark_groth16::{prepare_verifying_key as g16_prepare_verification_key, Proof as g16_proof, VerifyingKey as g16_verification_key, Groth16};
|
||||
use ark_ff::{Field, Zero, vec,Fp};
|
||||
use ark_snark::SNARK;
|
||||
use ark_bls12_381::{Bls12_381, Fr as BlsFr};
|
||||
use ark_serialize::{CanonicalDeserialize, Compress, Validate};
|
||||
use ark_std::{
|
||||
io::{Cursor},
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config {
|
||||
/// Because this pallet emits events, it depends on the runtime's definition of an event.
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
/// Type representing the weight of this pallet
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
// The pallet's runtime storage items.
|
||||
// https://docs.substrate.io/main-docs/build/runtime-storage/
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn something)]
|
||||
// Learn more about declaring storage items:
|
||||
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
|
||||
pub type Something<T> = StorageValue<_, u32>;
|
||||
|
||||
// Pallets use events to inform users when important changes are made.
|
||||
// https://docs.substrate.io/main-docs/build/events-errors/
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// Event documentation should end with an array that provides descriptive names for event
|
||||
/// parameters. [something, who]
|
||||
ValidationSuccess { who: T::AccountId },
|
||||
}
|
||||
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
ValidationFailed,
|
||||
}
|
||||
|
||||
// Dispatchable functions allows users to interact with the pallet and invoke state changes.
|
||||
// These functions materialize as "extrinsics", which are often compared to transactions.
|
||||
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::cause_error())]
|
||||
pub fn verify_proof(origin: OriginFor<T>, vk: Vec<u8>,inputs: Vec<u8>,proof: Vec<u8>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
let cursor = Cursor::new(&vk);
|
||||
let vk = <Groth16<Bls12_381> as SNARK<BlsFr>>::VerifyingKey::deserialize_with_mode(
|
||||
cursor,
|
||||
Compress::No,
|
||||
Validate::No,
|
||||
).unwrap();
|
||||
|
||||
let cursor = Cursor::new(&inputs);
|
||||
let inputs: ark_ff::Fp<ark_ff::MontBackend<ark_bls12_381::FrConfig, 4>, 4> =
|
||||
Fp::deserialize_with_mode(cursor, Compress::No, Validate::No).unwrap();
|
||||
|
||||
|
||||
let cursor = Cursor::new(&proof);
|
||||
let proof =
|
||||
<Groth16<Bls12_381> as SNARK<BlsFr>>::Proof::deserialize_with_mode(
|
||||
cursor,
|
||||
Compress::No,
|
||||
Validate::No,
|
||||
).unwrap();
|
||||
|
||||
|
||||
let result = Groth16::<Bls12_381>::verify(&vk, &[inputs], &proof).unwrap();
|
||||
if(result){
|
||||
Self::deposit_event(Event::ValidationSuccess { who });
|
||||
Ok(())
|
||||
}else{
|
||||
Err(Error::<T>::ValidationFailed.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::cause_error())]
|
||||
pub fn verify_proof_plonk(origin: OriginFor<T>, vk: Vec<u8>, inputs: Vec<u8>,proof: Vec<u8>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
let verifier: Verifier = Verifier::try_from_bytes(&vk[..]).expect("Failed to load verifier");
|
||||
|
||||
|
||||
let archived = rkyv::check_archived_root::<Proof>(&proof[..]).unwrap();
|
||||
|
||||
let proof: Proof = archived.deserialize(&mut rkyv::Infallible).unwrap();
|
||||
let archived = rkyv::check_archived_root::<Vec<BlsScalar>>(&inputs[..]).unwrap();
|
||||
let inputs: Vec<BlsScalar> = archived.deserialize(&mut rkyv::Infallible).unwrap();
|
||||
|
||||
|
||||
let verification =verifier.verify(&proof, &inputs);
|
||||
|
||||
|
||||
let result = verification.is_ok();
|
||||
if(result){
|
||||
Self::deposit_event(Event::ValidationSuccess { who });
|
||||
Ok(())
|
||||
}else{
|
||||
Err(Error::<T>::ValidationFailed.into())
|
||||
}
|
||||
}
|
||||
|
||||
/*#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::cause_error())]
|
||||
pub fn verify_proof_gm17(origin: OriginFor<T>, vk: Vec<u8>, inputs: Vec<u8>,proof: Vec<u8>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
let cursor = Cursor::new(&vk);
|
||||
let pvk = <GM17<Bls12_381> as SNARK<BlsFr>>::VerifyingKey::deserialize_with_mode(
|
||||
cursor,
|
||||
Compress::No,
|
||||
Validate::No,
|
||||
).unwrap();
|
||||
|
||||
let cursor = Cursor::new(&inputs);
|
||||
let inputs: ark_ff::Fp<ark_ff::MontBackend<ark_bls12_381::FrConfig, 4>, 4> =
|
||||
Fp::deserialize_with_mode(cursor, Compress::No, Validate::No).unwrap();
|
||||
|
||||
let cursor = Cursor::new(&proof);
|
||||
let proof =
|
||||
<GM17<Bls12_381> as SNARK<BlsFr>>::Proof::deserialize_with_mode(
|
||||
cursor,
|
||||
Compress::No,
|
||||
Validate::No,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
let result = gm17_verify_proof(&vk, &proof, &[inputs]).unwrap();
|
||||
if(result){
|
||||
Ok(())
|
||||
}else{
|
||||
Err(Error::<T>::NoneValue.into())
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
use crate as pallet_zkp_verify;
|
||||
use frame_support::traits::{ConstU16, ConstU64};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system,
|
||||
TemplateModule: pallet_template,
|
||||
}
|
||||
);
|
||||
|
||||
impl frame_system::Config for Test {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
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 BlockHashCount = ConstU64<250>;
|
||||
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 {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
// Build genesis storage according to the mock runtime.
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
use crate::{mock::*, Error, Event};
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
|
||||
#[test]
|
||||
fn it_works_for_default_value() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Go past genesis block so events get deposited
|
||||
System::set_block_number(1);
|
||||
// Dispatch a signed extrinsic.
|
||||
assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42));
|
||||
// Read pallet storage and assert an expected result.
|
||||
assert_eq!(TemplateModule::something(), Some(42));
|
||||
// Assert that the correct event was deposited
|
||||
System::assert_last_event(Event::SomethingStored { something: 42, who: 1 }.into());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correct_error_for_none_value() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Ensure the expected error is thrown when no value is present.
|
||||
assert_noop!(
|
||||
TemplateModule::cause_error(RuntimeOrigin::signed(1)),
|
||||
Error::<Test>::NoneValue
|
||||
);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
//! Autogenerated weights for pallet_template
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-04-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `Alexs-MacBook-Pro-2.local`, CPU: `<UNKNOWN>`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ../../target/release/node-template
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain
|
||||
// dev
|
||||
// --pallet
|
||||
// pallet_template
|
||||
// --extrinsic
|
||||
// *
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --wasm-execution=compiled
|
||||
// --output
|
||||
// pallets/template/src/weights.rs
|
||||
// --template
|
||||
// ../../.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for pallet_template.
|
||||
pub trait WeightInfo {
|
||||
fn do_something() -> Weight;
|
||||
fn cause_error() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for pallet_template using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: TemplateModule Something (r:0 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn do_something() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 8_000_000 picoseconds.
|
||||
Weight::from_parts(9_000_000, 0)
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: TemplateModule Something (r:1 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn cause_error() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `32`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 6_000_000 picoseconds.
|
||||
Weight::from_parts(6_000_000, 1489)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
/// Storage: TemplateModule Something (r:0 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn do_something() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `0`
|
||||
// Minimum execution time: 8_000_000 picoseconds.
|
||||
Weight::from_parts(9_000_000, 0)
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
/// Storage: TemplateModule Something (r:1 w:1)
|
||||
/// Proof: TemplateModule Something (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
|
||||
fn cause_error() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `32`
|
||||
// Estimated: `1489`
|
||||
// Minimum execution time: 6_000_000 picoseconds.
|
||||
Weight::from_parts(6_000_000, 1489)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ description = "A fresh FRAME-based Substrate node, ready for hacking."
|
|||
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
|
||||
homepage = "https://substrate.io/"
|
||||
edition = "2021"
|
||||
license = "Unlicense"
|
||||
license = "MIT-0"
|
||||
publish = false
|
||||
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
|
||||
|
||||
|
@ -13,45 +13,46 @@ repository = "https://github.com/substrate-developer-hub/substrate-node-template
|
|||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
|
||||
|
||||
pallet-aura = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-try-runtime = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v0.9.40" }
|
||||
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-consensus-aura = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
sp-version = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-aura = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-try-runtime = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" }
|
||||
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
frame-executive = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-consensus-aura = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-inherents = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-offchain = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-session = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
# Used for the node template's RPCs
|
||||
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" }
|
||||
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" }
|
||||
|
||||
# Used for runtime benchmarking
|
||||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v0.9.40" }
|
||||
frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v0.9.40" }
|
||||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" }
|
||||
frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" }
|
||||
|
||||
# Local Dependencies
|
||||
pallet-template = { version = "4.0.0-dev", default-features = false, path = "../pallets/template" }
|
||||
pallet_zkp_verify = { version = "4.0.0-dev", default-features = false, path = "../pallets/zkp_verify" }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v0.9.40" }
|
||||
substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true , branch = "polkadot-v1.0.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
@ -95,6 +96,7 @@ runtime-benchmarks = [
|
|||
"frame-system/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"pallet-grandpa/runtime-benchmarks",
|
||||
"pallet-sudo/runtime-benchmarks",
|
||||
"pallet-template/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
|
|
|
@ -27,7 +27,8 @@ use sp_version::RuntimeVersion;
|
|||
pub use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo,
|
||||
ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness,
|
||||
StorageInfo,
|
||||
},
|
||||
weights::{
|
||||
constants::{
|
||||
|
@ -48,6 +49,9 @@ pub use sp_runtime::{Perbill, Permill};
|
|||
/// Import the template pallet.
|
||||
pub use pallet_template;
|
||||
|
||||
/// Import the ZKP verifier pallet.
|
||||
pub use pallet_zkp_verify;
|
||||
|
||||
/// An index to a block.
|
||||
pub type BlockNumber = u32;
|
||||
|
||||
|
@ -62,7 +66,7 @@ pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::Account
|
|||
pub type Balance = u128;
|
||||
|
||||
/// Index of a transaction in the chain.
|
||||
pub type Index = u32;
|
||||
pub type Nonce = u32;
|
||||
|
||||
/// A hash of some data used by the chain.
|
||||
pub type Hash = sp_core::H256;
|
||||
|
@ -154,6 +158,8 @@ parameter_types! {
|
|||
impl frame_system::Config for Runtime {
|
||||
/// The basic call filter to use in dispatchable.
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
/// 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).
|
||||
|
@ -164,16 +170,12 @@ impl frame_system::Config for Runtime {
|
|||
type RuntimeCall = RuntimeCall;
|
||||
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
|
||||
type Lookup = AccountIdLookup<AccountId, ()>;
|
||||
/// The index type for storing how many extrinsics an account has signed.
|
||||
type Index = Index;
|
||||
/// The index type for blocks.
|
||||
type BlockNumber = BlockNumber;
|
||||
/// The type for storing how many extrinsics an account has signed.
|
||||
type Nonce = Nonce;
|
||||
/// The type for hashing blocks and tries.
|
||||
type Hash = Hash;
|
||||
/// The hashing algorithm used.
|
||||
type Hashing = BlakeTwo256;
|
||||
/// The header type.
|
||||
type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// The ubiquitous event type.
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
/// The ubiquitous origin type.
|
||||
|
@ -207,6 +209,7 @@ impl pallet_aura::Config for Runtime {
|
|||
type AuthorityId = AuraId;
|
||||
type DisabledValidators = ();
|
||||
type MaxAuthorities = ConstU32<32>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
|
@ -243,6 +246,10 @@ impl pallet_balances::Config for Runtime {
|
|||
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
|
||||
type AccountStore = System;
|
||||
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
|
||||
type FreezeIdentifier = ();
|
||||
type MaxFreezes = ();
|
||||
type RuntimeHoldReason = ();
|
||||
type MaxHolds = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
@ -261,21 +268,24 @@ impl pallet_transaction_payment::Config for Runtime {
|
|||
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>;
|
||||
}
|
||||
|
||||
/// Configure the pallet-zkp_verify in pallets/zkp_verify.
|
||||
impl pallet_zkp_verify::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = pallet_zkp_verify::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
// Create the runtime by composing the FRAME pallets that were previously configured.
|
||||
construct_runtime!(
|
||||
pub struct Runtime
|
||||
where
|
||||
Block = Block,
|
||||
NodeBlock = opaque::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
{
|
||||
pub struct Runtime {
|
||||
System: frame_system,
|
||||
Timestamp: pallet_timestamp,
|
||||
Aura: pallet_aura,
|
||||
|
@ -285,6 +295,7 @@ construct_runtime!(
|
|||
Sudo: pallet_sudo,
|
||||
// Include the custom logic from the pallet-template in the runtime.
|
||||
TemplateModule: pallet_template,
|
||||
ZKPVerifyModule: pallet_zkp_verify,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -331,7 +342,9 @@ mod benches {
|
|||
[frame_system, SystemBench::<Runtime>]
|
||||
[pallet_balances, Balances]
|
||||
[pallet_timestamp, Timestamp]
|
||||
[pallet_sudo, Sudo]
|
||||
[pallet_template, TemplateModule]
|
||||
[pallet_zkp_verify, ZKPVerifyModule]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -354,6 +367,14 @@ impl_runtime_apis! {
|
|||
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 {
|
||||
|
@ -445,8 +466,8 @@ impl_runtime_apis! {
|
|||
}
|
||||
}
|
||||
|
||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Index {
|
||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Nonce {
|
||||
System::account_nonce(account)
|
||||
}
|
||||
}
|
||||
|
@ -558,40 +579,3 @@ impl_runtime_apis! {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use frame_support::traits::WhitelistedStorageKeys;
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
fn check_whitelist() {
|
||||
let whitelist: HashSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
|
||||
.iter()
|
||||
.map(|e| HexDisplay::from(&e.key).to_string())
|
||||
.collect();
|
||||
|
||||
// Block Number
|
||||
assert!(
|
||||
whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
|
||||
);
|
||||
// Total Issuance
|
||||
assert!(
|
||||
whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
|
||||
);
|
||||
// Execution Phase
|
||||
assert!(
|
||||
whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
|
||||
);
|
||||
// Event Count
|
||||
assert!(
|
||||
whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
|
||||
);
|
||||
// System Events
|
||||
assert!(
|
||||
whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
[toolchain]
|
||||
channel = "nightly"
|
||||
components = [
|
||||
"cargo",
|
||||
"clippy",
|
||||
"rust-analyzer",
|
||||
"rust-src",
|
||||
"rust-std",
|
||||
"rustc-dev",
|
||||
"rustc",
|
||||
"rustfmt",
|
||||
]
|
||||
targets = [ "wasm32-unknown-unknown" ]
|
||||
profile = "minimal"
|
Loading…
Reference in New Issue