feat: Rebrand Polkadot/Substrate references to PezkuwiChain

This commit systematically rebrands various references from Parity Technologies'
Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk.

Key changes include:
- Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks.
- Modified internal documentation and code comments to reflect PezkuwiChain naming and structure.
- Replaced direct references to  with  or specific paths within the  for XCM, Pezkuwi, and other modules.
- Cleaned up deprecated  issue and PR references in various  and  files, particularly in  and  modules.
- Adjusted image and logo URLs in documentation to point to PezkuwiChain assets.
- Removed or rephrased comments related to external Polkadot/Substrate PRs and issues.

This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
2025-12-14 00:04:10 +03:00
parent e4778b4576
commit 379cb741ed
9082 changed files with 997824 additions and 997542 deletions
@@ -0,0 +1,60 @@
[package]
name = "pezpallet-example-basic"
version = "27.0.0"
authors.workspace = true
edition.workspace = true
license = "MIT-0"
homepage.workspace = true
repository.workspace = true
description = "FRAME example pallet"
readme = "README.md"
publish = false
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { workspace = true }
pezframe-benchmarking = { optional = true, workspace = true }
pezframe-support = { workspace = true }
pezframe-system = { workspace = true }
log = { workspace = true }
pezpallet-balances = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
pezsp-io = { workspace = true }
pezsp-runtime = { workspace = true }
[dev-dependencies]
pezsp-core = { workspace = true }
[features]
default = ["std"]
std = [
"codec/std",
"pezframe-benchmarking?/std",
"pezframe-support/std",
"pezframe-system/std",
"log/std",
"pezpallet-balances/std",
"scale-info/std",
"pezsp-core/std",
"pezsp-io/std",
"pezsp-runtime/std",
]
runtime-benchmarks = [
"pezframe-benchmarking/runtime-benchmarks",
"pezframe-support/runtime-benchmarks",
"pezframe-system/runtime-benchmarks",
"pezpallet-balances/runtime-benchmarks",
"pezsp-io/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
]
try-runtime = [
"pezframe-support/try-runtime",
"pezframe-system/try-runtime",
"pezpallet-balances/try-runtime",
"pezsp-runtime/try-runtime",
]
@@ -0,0 +1,240 @@
<!-- markdown-link-check-disable -->
# Basic Example Pallet
<!-- Original author of paragraph: @gavofyork -->
The Example: A simple example of a FRAME pallet demonstrating
concepts, APIs and structures common to most FRAME runtimes.
Run `cargo doc --package pezpallet-example-basic --open` to view this pallet's documentation.
**This pallet serves as an example and is not meant to be used in production.**
## Documentation Guidelines
<!-- Original author of paragraph: Various. Based on collation of review comments to PRs addressing issues with -->
<!-- label 'S3-FRAME' in https://github.com/paritytech/bizinikiwi-developer-hub/issues -->
<ul>
<li>Documentation comments (i.e. <code>/// comment</code>) - should
accompany pallet functions and be restricted to the pallet interface,
not the internals of the pallet implementation. Only state inputs,
outputs, and a brief description that mentions whether calling it
requires root, but without repeating the source code details.
Capitalize the first word of each documentation comment and end it with
a full stop. See
<a href="https://github.com/paritytech/bizinikiwi#72-contributing-to-documentation-for-bizinikiwi-packages"
target="_blank"> Generic example of annotating source code with documentation comments</a></li>
<li>Self-documenting code - Try to refactor code to be self-documenting.</li>
<li>Code comments - Supplement complex code with a brief explanation, not every line of code.</li>
<li>Identifiers - surround by backticks (i.e. <code>INHERENT_IDENTIFIER</code>, <code>InherentType</code>,
<code>u64</code>)</li>
<li>Usage scenarios - should be simple doctests. The compiler should ensure they stay valid.</li>
<li>Extended tutorials - should be moved to external files and refer to.</li>
<!-- Original author of paragraph: @AmarRSingh -->
<li>Mandatory - include all of the sections/subsections where <b>MUST</b> is specified.</li>
<li>Optional - optionally include sections/subsections where <b>CAN</b> is specified.</li>
</ul>
### Documentation Template:<br>
Copy and paste this template from frame/examples/basic/src/lib.rs into file
`frame/<INSERT_CUSTOM_PALLET_NAME>/src/lib.rs` of your own custom pallet and complete it.
<details><p><pre>
// Add heading with custom pallet name
\# <INSERT_CUSTOM_PALLET_NAME> Pallet
// Add simple description
// Include the following links that shows what trait needs to be implemented to use the pallet
// and the supported dispatchables that are documented in the Call enum.
- \[`<INSERT_CUSTOM_PALLET_NAME>::Config`](https://docs.rs/pezpallet-example-basic/latest/pallet_example_basic/trait.Config.html)
- \[`Call`](https://docs.rs/pezpallet-example-basic/latest/pallet_example_basic/enum.Call.html)
- \[`Module`](https://docs.rs/pezpallet-example-basic/latest/pallet_example_basic/struct.Module.html)
\## Overview
<!-- Original author of paragraph: Various. See https://github.com/pezkuwichain/kurdistan-sdk/issues/1 -->
// Short description of pallet's purpose.
// Links to Traits that should be implemented.
// What this pallet is for.
// What functionality the pallet provides.
// When to use the pallet (use case examples).
// How it is used.
// Inputs it uses and the source of each input.
// Outputs it produces.
<!-- Original author of paragraph: @Kianenigma in PR https://github.com/pezkuwichain/kurdistan-sdk/issues/52 -->
<!-- and comment https://github.com/pezkuwichain/kurdistan-sdk/issues/1#issuecomment-471982710 -->
\## Terminology
// Add terminology used in the custom pallet. Include concepts, storage items, or actions that you think
// deserve to be noted to give context to the rest of the documentation or pallet usage. The author needs to
// use some judgment about what is included. We don't want a list of every storage item nor types - the user
// can go to the code for that. For example, "transfer fee" is obvious and should not be included, but
// "free balance" and "reserved balance" should be noted to give context to the pallet.
// Please do not link to outside resources. The reference docs should be the ultimate source of truth.
<!-- Original author of heading: @Kianenigma in PR https://github.com/pezkuwichain/kurdistan-sdk/issues/52 -->
\## Goals
// Add goals that the custom pallet is designed to achieve.
<!-- Original author of heading: @Kianenigma in PR https://github.com/pezkuwichain/kurdistan-sdk/issues/52 -->
\### Scenarios
<!-- Original author of paragraph: @Kianenigma. Based on PR https://github.com/pezkuwichain/kurdistan-sdk/issues/52 -->
\#### <INSERT_SCENARIO_NAME>
// Describe requirements prior to interacting with the custom pallet.
// Describe the process of interacting with the custom pallet for this scenario and public API functions used.
\## Interface
\### Supported Origins
// What origins are used and supported in this pallet (root, signed, none)
// i.e. root when <code>\`ensure_root\`</code> used
// i.e. none when <code>\`ensure_none\`</code> used
// i.e. signed when <code>\`ensure_signed\`</code> used
<code>\`inherent\`</code> <INSERT_DESCRIPTION>
<!-- Original author of paragraph: @Kianenigma in comment -->
<!-- https://github.com/pezkuwichain/kurdistan-sdk/issues/1#issuecomment-471982710 -->
\### Types
// Type aliases. Include any associated types and where the user would typically define them.
<code>\`ExampleType\`</code> <INSERT_DESCRIPTION>
<!-- Original author of paragraph: ??? -->
// Reference documentation of aspects such as `storageItems` and `dispatchable` functions should only be
// included in the https://docs.rs Rustdocs for Bizinikiwi and not repeated in the README file.
\### Dispatchable Functions
<!-- Original author of paragraph: @AmarRSingh & @joepetrowski -->
// A brief description of dispatchable functions and a link to the rustdoc with their actual documentation.
// <b>MUST</b> have link to Call enum
// <b>MUST</b> have origin information included in function doc
// <b>CAN</b> have more info up to the user
\### Public Functions
<!-- Original author of paragraph: @joepetrowski -->
// A link to the rustdoc and any notes about usage in the pallet, not for specific functions.
// For example, in the Balances Pallet: "Note that when using the publicly exposed functions,
// you (the runtime developer) are responsible for implementing any necessary checks
// (e.g. that the sender is the signer) before calling a function that will affect storage."
<!-- Original author of paragraph: @AmarRSingh -->
// It is up to the writer of the respective pallet (with respect to how much information to provide).
\#### Public Inspection functions - Immutable (getters)
// Insert a subheading for each getter function signature
\##### <code>\`example_getter_name()\`</code>
// What it returns
// Why, when, and how often to call it
// When it could panic or error
// When safety issues to consider
\#### Public Mutable functions (changing state)
// Insert a subheading for each setter function signature
\##### <code>\`example_setter_name(origin, parameter_name: T::ExampleType)\`</code>
// What state it changes
// Why, when, and how often to call it
// When it could panic or error
// When safety issues to consider
// What parameter values are valid and why
\### Storage Items
// Explain any storage items included in this pallet
\### Digest Items
// Explain any digest items included in this pallet
\### Inherent Data
// Explain what inherent data (if any) is defined in the pallet and any other related types
\### Events:
// Insert events for this pallet if any
\### Errors:
// Explain what generates errors
\## Usage
// Insert 2-3 examples of usage and code snippets that show how to
// use <INSERT_CUSTOM_PALLET_NAME> Pallet in a custom pallet.
\### Prerequisites
// Show how to include necessary imports for <INSERT_CUSTOM_PALLET_NAME> and derive
// your pallet configuration trait with the `INSERT_CUSTOM_PALLET_NAME` trait.
\```rust
use <INSERT_CUSTOM_PALLET_NAME>;
pub trait Config: <INSERT_CUSTOM_PALLET_NAME>::Config { }
\```
\### Simple Code Snippet
// Show a simple example (e.g. how to query a public getter function of <INSERT_CUSTOM_PALLET_NAME>)
\### Example from FRAME
// Show a usage example in an actual runtime
// See:
// - Bizinikiwi TCR https://github.com/parity-samples/bizinikiwi-tcr
// - Bizinikiwi Kitties https://shawntabrizi.github.io/bizinikiwi-collectables-workshop/#/
\## Genesis Config
<!-- Original author of paragraph: @joepetrowski -->
\## Dependencies
// Dependencies on other FRAME pallets and the genesis config should be mentioned,
// but not the Rust Standard Library.
// Genesis configuration modifications that may be made to incorporate this pallet
// Interaction with other pallets
<!-- Original author of heading: @AmarRSingh -->
\## Related Pallets
// Interaction with other pallets in the form of a bullet point list
\## References
<!-- Original author of paragraph: @joepetrowski -->
// Links to reference material, if applicable. For example, Phragmen, W3F research, etc.
// that the implementation is based on.
</pre></p></details>
License: MIT-0
@@ -0,0 +1,124 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: MIT-0
// 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, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 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.
//! Benchmarking for `pezpallet-example-basic`.
// Only enable this module for benchmarking.
#![cfg(feature = "runtime-benchmarks")]
use crate::*;
use pezframe_benchmarking::v2::*;
use pezframe_system::RawOrigin;
// To actually run this benchmark on pezpallet-example-basic, we need to put this pallet into the
// runtime and compile it with `runtime-benchmarks` feature. The detail procedures are
// documented at:
// https://docs.pezkuwichain.io/reference/how-to-guides/weights/add-benchmarks/
//
// The auto-generated weight estimate of this pallet is copied over to the `weights.rs` file.
// The exact command of how the estimate generated is printed at the top of the file.
// Details on using the benchmarks macro can be seen at:
// https://docs.pezkuwichain.io/bizinikiwi/master/pezframe_benchmarking/trait.Benchmarking.html#tymethod.benchmarks
#[benchmarks]
mod benchmarks {
use super::*;
// This will measure the execution time of `set_dummy`.
#[benchmark]
fn set_dummy_benchmark() {
// This is the benchmark setup phase.
// `set_dummy` is a constant time function, hence we hard-code some random value here.
let value = 1000u32.into();
#[extrinsic_call]
set_dummy(RawOrigin::Root, value); // The execution phase is just running `set_dummy` extrinsic call
// This is the optional benchmark verification phase, asserting certain states.
assert_eq!(Dummy::<T>::get(), Some(value))
}
// An example method that returns a Result that can be called within a benchmark
fn example_result_method() -> Result<(), BenchmarkError> {
Ok(())
}
// This will measure the execution time of `accumulate_dummy`.
// The benchmark execution phase is shorthanded. When the name of the benchmark case is the same
// as the extrinsic call. `_(...)` is used to represent the extrinsic name.
// The benchmark verification phase is omitted.
#[benchmark]
fn accumulate_dummy() -> Result<(), BenchmarkError> {
let value = 1000u32.into();
// The caller account is whitelisted for DB reads/write by the benchmarking macro.
let caller: T::AccountId = whitelisted_caller();
// an example of calling something result-based within a benchmark using the ? operator
// this necessitates specifying the `Result<(), BenchmarkError>` return type
example_result_method()?;
// You can use `_` if the name of the Call matches the benchmark name.
#[extrinsic_call]
_(RawOrigin::Signed(caller), value);
// need this to be compatible with the return type
Ok(())
}
/// You can write helper functions in here since its a normal Rust module.
fn setup_vector(len: u32) -> Vec<u32> {
let mut vector = Vec::<u32>::new();
for i in (0..len).rev() {
vector.push(i);
}
vector
}
// This will measure the execution time of sorting a vector.
//
// Define `x` as a linear component with range `[0, =10_000]`. This means that the benchmarking
// will assume that the weight grows at a linear rate depending on `x`.
#[benchmark]
fn sort_vector(x: Linear<0, 10_000>) {
let mut vector = setup_vector(x);
// The benchmark execution phase could also be a closure with custom code:
#[block]
{
vector.sort();
}
// Check that it was sorted correctly. This will not be benchmarked and is just for
// verification.
vector.windows(2).for_each(|w| assert!(w[0] <= w[1]));
}
// This line generates test cases for benchmarking, and could be run by:
// `cargo test -p pezpallet-example-basic --all-features`, you will see one line per case:
// `test benchmarking::bench_sort_vector ... ok`
// `test benchmarking::bench_accumulate_dummy ... ok`
// `test benchmarking::bench_set_dummy_benchmark ... ok` in the result.
//
// The line generates three steps per benchmark, with repeat=1 and the three steps are
// [low, mid, high] of the range.
impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test);
}
@@ -0,0 +1,536 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: MIT-0
// 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, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 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.
//! # Basic Example Pallet
//!
//! A pallet demonstrating concepts, APIs and structures common to most FRAME runtimes.
//!
//! **This pallet serves as an example and is not meant to be used in production.**
//!
//! > Made with *Bizinikiwi*, for *Pezkuwi*.
//!
//! [![github]](https://github.com/pezkuwichain/pezkuwi-sdk/tree/master/bizinikiwi/pezframe/examples/basic)
//! [![pezkuwi]](https://pezkuwichain.io)
//!
//! [pezkuwi]: https://img.shields.io/badge/polkadot-E6007A?style=for-the-badge&logo=polkadot&logoColor=white
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
//!
//! ## Pallet API
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes,
//! including its configuration trait, dispatchables, storage items, events and errors.
//!
//! ## Overview
//!
//! This pallet provides basic examples of using:
//!
//! - A custom weight calculator able to classify a call's dispatch class (see:
//! [`pezframe_support::dispatch::DispatchClass`])
//! - Pallet hooks to implement some custom logic that's executed before and after a block is
//! imported (see: [`pezframe_support::traits::Hooks`])
//! - Inherited weight annotation for pallet calls, used to create less repetition for calls that
//! use the [`Config::WeightInfo`] trait to calculate call weights. This can also be overridden,
//! as demonstrated by [`Call::set_dummy`].
//! - A private function that performs a storage update.
//! - A simple transaction extension implementation (see:
//! [`pezsp_runtime::traits::TransactionExtension`]) which increases the priority of the
//! [`Call::set_dummy`] if it's present and drops any transaction with an encoded length higher
//! than 200 bytes.
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::vec::Vec;
use codec::{Decode, DecodeWithMemTracking, Encode};
use core::marker::PhantomData;
use pezframe_support::{
dispatch::{ClassifyDispatch, DispatchClass, DispatchResult, Pays, PaysFee, WeighData},
pezpallet_prelude::TransactionSource,
traits::IsSubType,
weights::Weight,
};
use pezframe_system::ensure_signed;
use log::info;
use scale_info::TypeInfo;
use pezsp_runtime::{
impl_tx_ext_default,
traits::{
Bounded, DispatchInfoOf, DispatchOriginOf, SaturatedConversion, Saturating,
TransactionExtension, ValidateResult,
},
transaction_validity::{InvalidTransaction, ValidTransaction},
};
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
#[cfg(test)]
mod tests;
mod benchmarking;
pub mod weights;
pub use weights::*;
/// A type alias for the balance type from this pallet's point of view.
type BalanceOf<T> = <T as pezpallet_balances::Config>::Balance;
const MILLICENTS: u32 = 1_000_000_000;
// A custom weight calculator tailored for the dispatch call `set_dummy()`. This actually examines
// the arguments and makes a decision based upon them.
//
// The `WeightData<T>` trait has access to the arguments of the dispatch that it wants to assign a
// weight to. Nonetheless, the trait itself cannot make any assumptions about what the generic type
// of the arguments (`T`) is. Based on our needs, we could replace `T` with a more concrete type
// while implementing the trait. The `pallet::weight` expects whatever implements `WeighData<T>` to
// replace `T` with a tuple of the dispatch arguments. This is exactly how we will craft the
// implementation below.
//
// The rules of `WeightForSetDummy` are as follows:
// - The final weight of each dispatch is calculated as the argument of the call multiplied by the
// parameter given to the `WeightForSetDummy`'s constructor.
// - assigns a dispatch class `operational` if the argument of the call is more than 1000.
//
// More information can be read at:
// - https://docs.pezkuwichain.io/main-docs/build/tx-weights-fees/
//
// Manually configuring weight is an advanced operation and what you really need may well be
// fulfilled by running the benchmarking toolchain. Refer to `benchmarking.rs` file.
struct WeightForSetDummy<T: pezpallet_balances::Config>(BalanceOf<T>);
impl<T: pezpallet_balances::Config> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
fn weigh_data(&self, target: (&BalanceOf<T>,)) -> Weight {
let multiplier = self.0;
// *target.0 is the amount passed into the extrinsic
let cents = *target.0 / <BalanceOf<T>>::from(MILLICENTS);
Weight::from_parts((cents * multiplier).saturated_into::<u64>(), 0)
}
}
impl<T: pezpallet_balances::Config> ClassifyDispatch<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
fn classify_dispatch(&self, target: (&BalanceOf<T>,)) -> DispatchClass {
if *target.0 > <BalanceOf<T>>::from(1000u32) {
DispatchClass::Operational
} else {
DispatchClass::Normal
}
}
}
impl<T: pezpallet_balances::Config> PaysFee<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
fn pays_fee(&self, _target: (&BalanceOf<T>,)) -> Pays {
Pays::Yes
}
}
// Definition of the pallet logic, to be aggregated at runtime definition through
// `construct_runtime`.
#[pezframe_support::pallet]
pub mod pallet {
// Import various types used to declare pallet in scope.
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// Our pallet's configuration trait. All our types and constants go in here. If the
/// pallet is dependent on specific other pallets, then their configuration traits
/// should be added to our implied traits list.
///
/// `pezframe_system::Config` should always be included.
#[pallet::config]
pub trait Config: pezpallet_balances::Config + pezframe_system::Config {
// Setting a constant config parameter from the runtime
#[pallet::constant]
type MagicNumber: Get<Self::Balance>;
/// Type representing the weight of this pallet
type WeightInfo: WeightInfo;
}
// Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and
// method.
#[pallet::pallet]
pub struct Pallet<T>(_);
// This pallet implements the [`pezframe_support::traits::Hooks`] trait to define some logic to
// execute in some context.
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
// `on_initialize` is executed at the beginning of the block before any extrinsic are
// dispatched.
//
// This function must return the weight consumed by `on_initialize` and `on_finalize`.
fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
// Anything that needs to be done at the start of the block.
// We don't do anything here.
Weight::zero()
}
// `on_finalize` is executed at the end of block after all extrinsic are dispatched.
fn on_finalize(_n: BlockNumberFor<T>) {
// Perform necessary data/state clean up here.
}
// A runtime code run after every block and have access to extended set of APIs.
//
// For instance you can generate extrinsics for the upcoming produced block.
fn offchain_worker(_n: BlockNumberFor<T>) {
// We don't do anything here.
// but we could dispatch extrinsic (transaction/unsigned/inherent) using
// pezsp_io::submit_extrinsic.
// To see example on offchain worker, please refer to example-offchain-worker pallet
// accompanied in this repository.
}
}
// The call declaration. This states the entry points that we handle. The
// macro takes care of the marshalling of arguments and dispatch.
//
// Anyone can have these functions execute by signing and submitting
// an extrinsic. Ensure that calls into each of these execute in a time, memory and
// using storage space proportional to any costs paid for by the caller or otherwise the
// difficulty of forcing the call to happen.
//
// Generally you'll want to split these into three groups:
// - Public calls that are signed by an external account.
// - Root calls that are allowed to be made only by the governance system.
// - Unsigned calls that can be of two kinds:
// * "Inherent extrinsics" that are opinions generally held by the block authors that build
// child blocks.
// * Unsigned Transactions that are of intrinsic recognizable utility to the network, and are
// validated by the runtime.
//
// Information about where this dispatch initiated from is provided as the first argument
// "origin". As such functions must always look like:
//
// `fn foo(origin: OriginFor<T>, bar: Bar, baz: Baz) -> DispatchResultWithPostInfo { ... }`
//
// The `DispatchResultWithPostInfo` is required as part of the syntax (and can be found at
// `pezpallet_prelude::DispatchResultWithPostInfo`).
//
// There are three entries in the `pezframe_system::Origin` enum that correspond
// to the above bullets: `::Signed(AccountId)`, `::Root` and `::None`. You should always match
// against them as the first thing you do in your function. There are three convenience calls
// in system that do the matching for you and return a convenient result: `ensure_signed`,
// `ensure_root` and `ensure_none`.
#[pallet::call(weight(<T as Config>::WeightInfo))]
impl<T: Config> Pallet<T> {
/// This is your public interface. Be extremely careful.
/// This is just a simple example of how to interact with the pallet from the external
/// world.
// This just increases the value of `Dummy` by `increase_by`.
//
// Since this is a dispatched function there are two extremely important things to
// remember:
//
// - MUST NOT PANIC: Under no circumstances (save, perhaps, storage getting into an
// irreparably damaged state) must this function panic.
// - NO SIDE-EFFECTS ON ERROR: This function must either complete totally (and return
// `Ok(())` or it must have no side-effects on storage and return `Err('Some reason')`.
//
// The first is relatively easy to audit for - just ensure all panickers are removed from
// logic that executes in production (which you do anyway, right?!). To ensure the second
// is followed, you should do all tests for validity at the top of your function. This
// is stuff like checking the sender (`origin`) or that state is such that the operation
// makes sense.
//
// Once you've determined that it's all good, then enact the operation and change storage.
// If you can't be certain that the operation will succeed without substantial computation
// then you have a classic blockchain attack scenario. The normal way of managing this is
// to attach a bond to the operation. As the first major alteration of storage, reserve
// some value from the sender's account (`Balances` Pallet has a `reserve` function for
// exactly this scenario). This amount should be enough to cover any costs of the
// substantial execution in case it turns out that you can't proceed with the operation.
//
// If it eventually transpires that the operation is fine and, therefore, that the
// expense of the checks should be borne by the network, then you can refund the reserved
// deposit. If, however, the operation turns out to be invalid and the computation is
// wasted, then you can burn it or repatriate elsewhere.
//
// Security bonds ensure that attackers can't game it by ensuring that anyone interacting
// with the system either progresses it or pays for the trouble of faffing around with
// no progress.
//
// If you don't respect these rules, it is likely that your chain will be attackable.
//
// Each transaction must define a `#[pallet::weight(..)]` attribute to convey a set of
// static information about its dispatch. FRAME System and FRAME Executive pallet then use
// this information to properly execute the transaction, whilst keeping the total load of
// the chain in a moderate rate.
//
// The parenthesized value of the `#[pallet::weight(..)]` attribute can be any type that
// implements a set of traits, namely [`WeighData`], [`ClassifyDispatch`], and
// [`PaysFee`]. The first conveys the weight (a numeric representation of pure
// execution time and difficulty) of the transaction and the second demonstrates the
// [`DispatchClass`] of the call, the third gives whereas extrinsic must pay fees or not.
// A higher weight means a larger transaction (less of which can be placed in a single
// block).
//
// The weight for this extrinsic we rely on the auto-generated `WeightInfo` from the
// benchmark toolchain.
#[pallet::call_index(0)]
pub fn accumulate_dummy(origin: OriginFor<T>, increase_by: T::Balance) -> DispatchResult {
// This is a public call, so we ensure that the origin is some signed account.
let _sender = ensure_signed(origin)?;
// Read the value of dummy from storage.
// let dummy = Dummy::<T>::get();
// Calculate the new value.
// let new_dummy = dummy.map_or(increase_by, |dummy| dummy + increase_by);
// Put the new value into storage.
// <Dummy<T>>::put(new_dummy);
// Will also work with a reference:
// <Dummy<T>>::put(&new_dummy);
// Here's the new one of read and then modify the value.
<Dummy<T>>::mutate(|dummy| {
// Using `saturating_add` instead of a regular `+` to avoid overflowing
let new_dummy = dummy.map_or(increase_by, |d| d.saturating_add(increase_by));
*dummy = Some(new_dummy);
});
// Let's deposit an event to let the outside world know this happened.
Self::deposit_event(Event::AccumulateDummy { balance: increase_by });
// All good, no refund.
Ok(())
}
/// A privileged call; in this case it resets our dummy value to something new.
// Implementation of a privileged call. The `origin` parameter is ROOT because
// it's not (directly) from an extrinsic, but rather the system as a whole has decided
// to execute it. Different runtimes have different reasons for allow privileged
// calls to be executed - we don't need to care why. Because it's privileged, we can
// assume it's a one-off operation and substantial processing/storage/memory can be used
// without worrying about gameability or attack scenarios.
//
// The weight for this extrinsic we use our own weight object `WeightForSetDummy` to
// determine its weight
#[pallet::call_index(1)]
#[pallet::weight(WeightForSetDummy::<T>(<BalanceOf<T>>::from(100u32)))]
pub fn set_dummy(
origin: OriginFor<T>,
#[pallet::compact] new_value: T::Balance,
) -> DispatchResult {
ensure_root(origin)?;
// Print out log or debug message in the console via log::{error, warn, info, debug,
// trace}, accepting format strings similar to `println!`.
// https://docs.pezkuwichain.io/bizinikiwi/master/pezsp_io/logging/fn.log.html
// https://docs.pezkuwichain.io/bizinikiwi/master/pezframe_support/constant.LOG_TARGET.html
info!("New value is now: {:?}", new_value);
// Put the new value into storage.
<Dummy<T>>::put(new_value);
Self::deposit_event(Event::SetDummy { balance: new_value });
// All good, no refund.
Ok(())
}
}
/// Events are a simple means of reporting specific conditions and
/// circumstances that have happened that users, Dapps and/or chain explorers would find
/// interesting and otherwise difficult to detect.
#[pallet::event]
/// This attribute generate the function `deposit_event` to deposit one of this pallet event,
/// it is optional, it is also possible to provide a custom implementation.
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
// Just a normal `enum`, here's a dummy event to ensure it compiles.
/// Dummy event, just here so there's a generic type that's used.
AccumulateDummy {
balance: BalanceOf<T>,
},
SetDummy {
balance: BalanceOf<T>,
},
SetBar {
account: T::AccountId,
balance: BalanceOf<T>,
},
}
// pallet::storage attributes allow for type-safe usage of the Bizinikiwi storage database,
// so you can keep things around between blocks.
//
// Any storage must be one of `StorageValue`, `StorageMap` or `StorageDoubleMap`.
// The first generic holds the prefix to use and is generated by the macro.
// The query kind is either `OptionQuery` (the default) or `ValueQuery`.
// - for `type Foo<T> = StorageValue<_, u32, OptionQuery>`:
// - `Foo::put(1); Foo::get()` returns `Some(1)`;
// - `Foo::kill(); Foo::get()` returns `None`.
// - for `type Foo<T> = StorageValue<_, u32, ValueQuery>`:
// - `Foo::put(1); Foo::get()` returns `1`;
// - `Foo::kill(); Foo::get()` returns `0` (u32::default()).
#[pallet::storage]
pub(super) type Dummy<T: Config> = StorageValue<_, T::Balance>;
// A map that has enumerable entries.
#[pallet::storage]
pub(super) type Bar<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance>;
// this one uses the query kind: `ValueQuery`, we'll demonstrate the usage of 'mutate' API.
#[pallet::storage]
pub(super) type Foo<T: Config> = StorageValue<_, T::Balance, ValueQuery>;
#[pallet::storage]
pub type CountedMap<T> = CountedStorageMap<_, Blake2_128Concat, u8, u16>;
// The genesis config type.
#[pallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub dummy: T::Balance,
pub bar: Vec<(T::AccountId, T::Balance)>,
pub foo: T::Balance,
}
// The build of genesis for the pallet.
#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
<Dummy<T>>::put(&self.dummy);
for (a, b) in &self.bar {
<Bar<T>>::insert(a, b);
}
<Foo<T>>::put(&self.foo);
}
}
}
// The main implementation block for the pallet. Functions here fall into three broad
// categories:
// - Public interface. These are functions that are `pub` and generally fall into inspector
// functions that do not write to storage and operation functions that do.
// - Private functions. These are your usual private utilities unavailable to other pallets.
impl<T: Config> Pallet<T> {
// Add public immutables and private mutables.
#[allow(dead_code)]
fn accumulate_foo(origin: T::RuntimeOrigin, increase_by: T::Balance) -> DispatchResult {
let _sender = ensure_signed(origin)?;
let prev = Foo::<T>::get();
// Because Foo has 'default', the type of 'foo' in closure is the raw type instead of an
// Option<> type.
let result = Foo::<T>::mutate(|foo| {
*foo = foo.saturating_add(increase_by);
*foo
});
assert!(prev + increase_by == result);
Ok(())
}
}
// Similar to other FRAME pallets, your pallet can also define a transaction extension and perform
// some checks and [pre/post]processing [before/after] the transaction. A transaction extension can
// be any decodable type that implements `TransactionExtension`. See the trait definition for the
// full list of bounds. As a convention, you can follow this approach to create an extension for
// your pallet:
// - If the extension does not carry any data, then use a tuple struct with just a `marker`
// (needed for the compiler to accept `T: Config`) will suffice.
// - Otherwise, create a tuple struct which contains the external data. Of course, for the entire
// struct to be decodable, each individual item also needs to be decodable.
//
// Note that a transaction extension can also indicate that a particular data must be present in the
// _signing payload_ of a transaction by providing an implementation for the `implicit` method. This
// example will not cover this type of extension. See `CheckSpecVersion` in [FRAME
// System](https://github.com/pezkuwichain/pezkuwi-sdk/tree/master/bizinikiwi/pezframe/system#signed-extensions)
// for an example.
//
// Using the extension, you can add some hooks to the life cycle of each transaction. Note that by
// default, an extension is applied to all `Call` functions (i.e. all transactions). the `Call` enum
// variant is given to each function of `TransactionExtension`. Hence, you can filter based on
// pallet or a particular call if needed.
//
// Some extra information, such as encoded length, some static dispatch info like weight and the
// sender of the transaction (if signed) are also provided.
//
// The full list of hooks that can be added to a transaction extension can be found in the
// `TransactionExtension` trait definition.
//
// The transaction extensions are aggregated in the runtime file of a bizinikiwi chain. All
// extensions should be aggregated in a tuple and passed to the `CheckedExtrinsic` and
// `UncheckedExtrinsic` types defined in the runtime. Lookup `pub type TxExtension = (...)` in
// `node/runtime` and `node-template` for an example of this.
/// A simple transaction extension that checks for the `set_dummy` call. In that case, it increases
/// the priority and prints some log.
///
/// Additionally, it drops any transaction with an encoded length higher than 200 bytes. No
/// particular reason why, just to demonstrate the power of transaction extensions.
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, Eq, PartialEq, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct WatchDummy<T: Config + Send + Sync>(PhantomData<T>);
impl<T: Config + Send + Sync> core::fmt::Debug for WatchDummy<T> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "WatchDummy")
}
}
impl<T: Config + Send + Sync> TransactionExtension<<T as pezframe_system::Config>::RuntimeCall>
for WatchDummy<T>
where
<T as pezframe_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
const IDENTIFIER: &'static str = "WatchDummy";
type Implicit = ();
type Pre = ();
type Val = ();
fn validate(
&self,
origin: DispatchOriginOf<<T as pezframe_system::Config>::RuntimeCall>,
call: &<T as pezframe_system::Config>::RuntimeCall,
_info: &DispatchInfoOf<<T as pezframe_system::Config>::RuntimeCall>,
len: usize,
_self_implicit: Self::Implicit,
_inherited_implication: &impl Encode,
_source: TransactionSource,
) -> ValidateResult<Self::Val, <T as pezframe_system::Config>::RuntimeCall> {
// if the transaction is too big, just drop it.
if len > 200 {
return Err(InvalidTransaction::ExhaustsResources.into());
}
// check for `set_dummy`
let validity = match call.is_sub_type() {
Some(Call::set_dummy { .. }) => {
pezsp_runtime::print("set_dummy was received.");
let valid_tx =
ValidTransaction { priority: Bounded::max_value(), ..Default::default() };
valid_tx
},
_ => Default::default(),
};
Ok((validity, (), origin))
}
impl_tx_ext_default!(<T as pezframe_system::Config>::RuntimeCall; weight prepare);
}
@@ -0,0 +1,195 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: MIT-0
// 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, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 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.
//! Tests for pezpallet-example-basic.
use crate::*;
use pezframe_support::{
assert_ok, derive_impl,
dispatch::{DispatchInfo, GetDispatchInfo},
traits::{ConstU64, OnInitialize},
};
use pezsp_core::H256;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use pezsp_runtime::{
traits::{BlakeTwo256, DispatchTransaction, IdentityLookup},
transaction_validity::TransactionSource::External,
BuildStorage,
};
// Reexport crate as its pallet name for construct_runtime.
use crate as pezpallet_example_basic;
type Block = pezframe_system::mocking::MockBlock<Test>;
// For testing the pallet, we construct a mock runtime.
pezframe_support::construct_runtime!(
pub enum Test
{
System: pezframe_system,
Balances: pezpallet_balances,
Example: pezpallet_example_basic,
}
);
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
impl Config for Test {
type MagicNumber = ConstU64<1_000_000_000>;
type WeightInfo = ();
}
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let t = RuntimeGenesisConfig {
// We use default for brevity, but you can configure as desired if needed.
system: Default::default(),
balances: Default::default(),
example: pezpallet_example_basic::GenesisConfig {
dummy: 42,
// we configure the map with (key, value) pairs.
bar: alloc::vec![(1, 2), (2, 3)],
foo: 24,
},
}
.build_storage()
.unwrap();
t.into()
}
#[test]
fn it_works_for_optional_value() {
new_test_ext().execute_with(|| {
// Check that GenesisBuilder works properly.
let val1 = 42;
let val2 = 27;
assert_eq!(Dummy::<Test>::get(), Some(val1));
// Check that accumulate works when we have Some value in Dummy already.
assert_ok!(Example::accumulate_dummy(RuntimeOrigin::signed(1), val2));
assert_eq!(Dummy::<Test>::get(), Some(val1 + val2));
// Check that accumulate works when we Dummy has None in it.
<Example as OnInitialize<u64>>::on_initialize(2);
assert_ok!(Example::accumulate_dummy(RuntimeOrigin::signed(1), val1));
assert_eq!(Dummy::<Test>::get(), Some(val1 + val2 + val1));
});
}
#[test]
fn it_works_for_default_value() {
new_test_ext().execute_with(|| {
assert_eq!(Foo::<Test>::get(), 24);
assert_ok!(Example::accumulate_foo(RuntimeOrigin::signed(1), 1));
assert_eq!(Foo::<Test>::get(), 25);
});
}
#[test]
fn set_dummy_works() {
new_test_ext().execute_with(|| {
let test_val = 133;
assert_ok!(Example::set_dummy(RuntimeOrigin::root(), test_val.into()));
assert_eq!(Dummy::<Test>::get(), Some(test_val));
});
}
#[test]
fn signed_ext_watch_dummy_works() {
new_test_ext().execute_with(|| {
let call = pezpallet_example_basic::Call::set_dummy { new_value: 10 }.into();
let info = DispatchInfo::default();
assert_eq!(
WatchDummy::<Test>(PhantomData)
.validate_only(Some(1).into(), &call, &info, 150, External, 0)
.unwrap()
.0
.priority,
u64::MAX,
);
assert_eq!(
WatchDummy::<Test>(PhantomData)
.validate_only(Some(1).into(), &call, &info, 250, External, 0)
.unwrap_err(),
InvalidTransaction::ExhaustsResources.into(),
);
})
}
#[test]
fn counted_map_works() {
new_test_ext().execute_with(|| {
assert_eq!(CountedMap::<Test>::count(), 0);
CountedMap::<Test>::insert(3, 3);
assert_eq!(CountedMap::<Test>::count(), 1);
})
}
#[test]
fn weights_work() {
// must have a defined weight.
let default_call = pezpallet_example_basic::Call::<Test>::accumulate_dummy { increase_by: 10 };
let info1 = default_call.get_dispatch_info();
// aka. `let info = <Call<Test> as GetDispatchInfo>::get_dispatch_info(&default_call);`
// TODO: account for proof size weight
assert!(info1.call_weight.ref_time() > 0);
assert_eq!(info1.call_weight, <Test as Config>::WeightInfo::accumulate_dummy());
// `set_dummy` is simpler than `accumulate_dummy`, and the weight
// should be less.
let custom_call = pezpallet_example_basic::Call::<Test>::set_dummy { new_value: 20 };
let info2 = custom_call.get_dispatch_info();
// TODO: account for proof size weight
assert!(info1.call_weight.ref_time() > info2.call_weight.ref_time());
}
@@ -0,0 +1,100 @@
// This file is part of Bizinikiwi.
// SPDX-License-Identifier: MIT-0
// 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, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 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.
//! Autogenerated weights for pezpallet_example_basic
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-10-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `Shawns-MacBook-Pro.local`, CPU: `<UNKNOWN>`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ./target/release/bizinikiwi
// benchmark
// pallet
// --chain=dev
// --execution=wasm
// --wasm-execution=compiled
// --pallet=pezpallet_example_basic
// --extrinsic=*
// --steps=50
// --repeat=20
// --output=./
// --template
// ./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weight functions needed for pezpallet_example_basic.
pub trait WeightInfo {
fn set_dummy_benchmark() -> Weight;
fn accumulate_dummy() -> Weight;
fn sort_vector(x: u32, ) -> Weight;
}
/// Weights for pezpallet_example_basic using the Bizinikiwi node and recommended hardware.
pub struct BizinikiwiWeight<T>(PhantomData<T>);
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
// Storage: BasicExample Dummy (r:0 w:1)
fn set_dummy_benchmark() -> Weight {
Weight::from_parts(19_000_000 as u64, 0)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: BasicExample Dummy (r:1 w:1)
fn accumulate_dummy() -> Weight {
Weight::from_parts(18_000_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
/// The range of component `x` is `[0, 10000]`.
fn sort_vector(x: u32, ) -> Weight {
Weight::from_parts(0 as u64, 0)
// Standard Error: 2
.saturating_add(Weight::from_parts(520 as u64, 0).saturating_mul(x as u64))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
// Storage: BasicExample Dummy (r:0 w:1)
fn set_dummy_benchmark() -> Weight {
Weight::from_parts(19_000_000 as u64, 0)
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: BasicExample Dummy (r:1 w:1)
fn accumulate_dummy() -> Weight {
Weight::from_parts(18_000_000 as u64, 0)
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
/// The range of component `x` is `[0, 10000]`.
fn sort_vector(x: u32, ) -> Weight {
Weight::from_parts(0 as u64, 0)
// Standard Error: 2
.saturating_add(Weight::from_parts(520 as u64, 0).saturating_mul(x as u64))
}
}