├── .dockerignore
├── support
├── src
│ ├── math_helper
│ │ ├── mod.rs
│ │ └── f64.rs
│ └── lib.rs
└── Cargo.toml
├── scripts
├── helper
│ ├── .env.example
│ ├── .yarnrc.yml
│ ├── .prettierrc.json
│ ├── src
│ │ ├── main.ts
│ │ ├── config
│ │ │ └── index.ts
│ │ └── commands
│ │ │ ├── get
│ │ │ ├── derivative.ts
│ │ │ ├── xcm_units_per_second.ts
│ │ │ └── sovereign.ts
│ │ │ ├── ump
│ │ │ └── transact.ts
│ │ │ ├── hrmp
│ │ │ ├── accept.ts
│ │ │ └── open.ts
│ │ │ ├── set
│ │ │ └── market-reward.ts
│ │ │ └── democracy
│ │ │ └── runtime-upgrade.ts
│ ├── .eslintrc.json
│ ├── tsconfig.json
│ ├── Dockerfile.release
│ └── package.json
├── srtool-build.sh
├── bump.sh
├── upgrade.sh
├── create-volume.sh
├── benchmark.sh
├── ci
│ └── extrinsic-ordering-filter.sh
├── fullnode.sh
├── collator.sh
└── collator-dev.sh
├── rust-toolchain
├── typos.toml
├── runtime
├── vanilla
│ ├── build.rs
│ └── src
│ │ └── weights
│ │ ├── mod.rs
│ │ ├── pallet_timestamp.rs
│ │ ├── pallet_xcm_helper.rs
│ │ ├── pallet_router.rs
│ │ ├── frame_system.rs
│ │ ├── pallet_amm.rs
│ │ ├── pallet_balances.rs
│ │ ├── pallet_asset_registry.rs
│ │ └── pallet_streaming.rs
├── kerria
│ ├── src
│ │ └── weights
│ │ │ ├── mod.rs
│ │ │ ├── pallet_timestamp.rs
│ │ │ ├── pallet_xcm_helper.rs
│ │ │ ├── pallet_router.rs
│ │ │ ├── frame_system.rs
│ │ │ ├── pallet_amm.rs
│ │ │ ├── pallet_balances.rs
│ │ │ ├── pallet_asset_registry.rs
│ │ │ └── pallet_streaming.rs
│ └── build.rs
├── heiko
│ ├── src
│ │ └── weights
│ │ │ ├── mod.rs
│ │ │ ├── pallet_xcm_helper.rs
│ │ │ ├── pallet_timestamp.rs
│ │ │ ├── cumulus_pallet_xcmp_queue.rs
│ │ │ ├── pallet_router.rs
│ │ │ ├── pallet_utility.rs
│ │ │ ├── pallet_amm.rs
│ │ │ ├── pallet_streaming.rs
│ │ │ ├── orml_oracle.rs
│ │ │ └── pallet_balances.rs
│ └── build.rs
├── parallel
│ ├── src
│ │ └── weights
│ │ │ ├── mod.rs
│ │ │ ├── pallet_xcm_helper.rs
│ │ │ ├── pallet_timestamp.rs
│ │ │ ├── cumulus_pallet_xcmp_queue.rs
│ │ │ ├── pallet_router.rs
│ │ │ ├── pallet_utility.rs
│ │ │ ├── pallet_amm.rs
│ │ │ ├── pallet_streaming.rs
│ │ │ ├── orml_oracle.rs
│ │ │ └── pallet_balances.rs
│ └── build.rs
└── common
│ └── src
│ ├── lib.rs
│ └── evm_migration.rs
├── rustfmt.toml
├── .githooks
└── pre-commit
├── .gitmodules
├── docs
├── EVM.md
├── RUNTIME-UPGRADE.md
└── COLLATOR.md
├── .github
├── ISSUE_TEMPLATE
│ ├── ask-a-question.md
│ ├── suggest-a-feature.md
│ └── report-a-bug.md
└── workflows
│ ├── njsscan.yml
│ └── typos.yml
├── .editorconfig
├── pallets
├── loans
│ ├── rpc
│ │ ├── runtime-api
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ └── Cargo.toml
│ └── Cargo.toml
├── router
│ ├── rpc
│ │ ├── runtime-api
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ └── Cargo.toml
│ └── Cargo.toml
├── stableswap
│ ├── README.md
│ ├── src
│ │ ├── types.rs
│ │ └── weights.rs
│ └── Cargo.toml
├── currency-adapter
│ └── Cargo.toml
├── xcm-helper
│ ├── src
│ │ ├── benchmarking.rs
│ │ ├── tests.rs
│ │ └── weights.rs
│ └── Cargo.toml
├── emergency-shutdown
│ ├── Cargo.toml
│ └── src
│ │ └── mock.rs
├── asset-registry
│ └── Cargo.toml
├── evm-signatures
│ ├── Cargo.toml
│ └── src
│ │ └── weights.rs
├── bridge
│ └── Cargo.toml
├── traits
│ └── Cargo.toml
├── prices
│ ├── Cargo.toml
│ └── src
│ │ └── weights.rs
├── farming
│ └── Cargo.toml
├── amm
│ └── Cargo.toml
└── streaming
│ └── Cargo.toml
├── precompiles
├── utils
│ ├── macro
│ │ ├── Cargo.toml
│ │ └── tests
│ │ │ └── tests.rs
│ └── Cargo.toml
├── balances-erc20
│ ├── Permit.sol
│ └── Cargo.toml
└── assets-erc20
│ └── Cargo.toml
├── CODEOWNERS
├── primitives
├── src
│ ├── network.rs
│ └── paras.rs
└── Cargo.toml
├── LIVE.md
├── node
└── parallel
│ ├── build.rs
│ └── src
│ └── main.rs
├── integration-tests
└── src
│ ├── lib.rs
│ ├── kusama_call.rs
│ └── kusama_transfer.rs
├── config.yml
├── .gitignore
├── Dockerfile.release
├── docker-compose.override.yml
└── config.json
/.dockerignore:
--------------------------------------------------------------------------------
1 | **/target
2 |
--------------------------------------------------------------------------------
/support/src/math_helper/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod f64;
2 |
--------------------------------------------------------------------------------
/scripts/helper/.env.example:
--------------------------------------------------------------------------------
1 | #RELAY_CHAIN_TYPE:kusama|polkadot
2 | RELAY_CHAIN_TYPE=polkadot
--------------------------------------------------------------------------------
/rust-toolchain:
--------------------------------------------------------------------------------
1 | [toolchain]
2 | channel = "nightly-2022-11-15"
3 | components = [ "rustfmt", "clippy" ]
4 | targets = [ "wasm32-unknown-unknown" ]
5 | profile = "minimal"
6 |
--------------------------------------------------------------------------------
/typos.toml:
--------------------------------------------------------------------------------
1 | [files]
2 | extend-exclude = ["scripts/polkadot-launch/*", "resources/specs/*", "scripts/evm/*"]
3 |
4 | [default.extend-words]
5 | accured = "accured"
6 | Nd = "Nd"
7 |
--------------------------------------------------------------------------------
/scripts/helper/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | nodeLinker: node-modules
2 |
3 | plugins:
4 | - path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
5 | spec: "https://mskelton.dev/yarn-outdated/v2"
6 |
7 | yarnPath: .yarn/releases/yarn-3.3.0.cjs
8 |
--------------------------------------------------------------------------------
/runtime/vanilla/build.rs:
--------------------------------------------------------------------------------
1 | use substrate_wasm_builder::WasmBuilder;
2 |
3 | fn main() {
4 | WasmBuilder::new()
5 | .with_current_project()
6 | .import_memory()
7 | .export_heap_base()
8 | .build()
9 | }
10 |
--------------------------------------------------------------------------------
/scripts/helper/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 100,
3 | "tabWidth": 2,
4 | "useTabs": false,
5 | "singleQuote": true,
6 | "semi": false,
7 | "trailingComma": "none",
8 | "bracketSpacing": true,
9 | "arrowParens": "avoid"
10 | }
11 |
--------------------------------------------------------------------------------
/rustfmt.toml:
--------------------------------------------------------------------------------
1 | #we can enable all files check later
2 | #license_template_path = "LICENSE_TEMPLATE"
3 | ignore = [
4 | "weights.rs",
5 | "runtime/heiko/src/weights",
6 | "runtime/parallel/src/weights",
7 | "runtime/kerria/src/weights",
8 | "runtime/vanilla/src/weights",
9 | ]
10 |
--------------------------------------------------------------------------------
/.githooks/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Forked from: https://github.com/AcalaNetwork/Acala/blob/master/githooks/pre-commit
4 |
5 | set -e
6 |
7 | files=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true)
8 |
9 | if [ ! -z "${files}" ]; then
10 | make fmt
11 | git add $(echo "$files" | paste -s -d " " -)
12 | fi
13 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "resources/specs"]
2 | path = resources/specs
3 | url = https://github.com/parallel-finance/specs
4 | [submodule "scripts/polkadot-launch"]
5 | path = scripts/polkadot-launch
6 | url = https://github.com/parallel-finance/polkadot-launch
7 | [submodule "scripts/evm"]
8 | path = scripts/evm
9 | url = https://github.com/parallel-finance/evm-script
10 |
--------------------------------------------------------------------------------
/docs/EVM.md:
--------------------------------------------------------------------------------
1 | # Public Endpoints
2 |
3 | |Network |Type | Endpoint| GasLimit
4 | --- | --- | ---| ---
5 | |kerria-test-net|JSON RPC|https://kerria-rpc.parallel.fi/evm| 15_000_000
6 |
7 | # Launch dev chain
8 |
9 | - launch chain locally
10 |
11 | ```
12 | make init && make run-dev-node
13 | ```
14 |
15 | - provisioning
16 |
17 | ```
18 | make provisioning-evm
19 | ```
20 |
--------------------------------------------------------------------------------
/scripts/helper/src/main.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ts-node
2 | import { program } from '@caporal/core'
3 | import dotenv from 'dotenv'
4 | import path from 'path'
5 |
6 | dotenv.config()
7 |
8 | program.cast(false).bin('parallel-helper').discover(path.join(__dirname, 'commands'))
9 |
10 | program.run().catch(err => {
11 | console.error(err.message)
12 | process.exit(1)
13 | })
14 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/ask-a-question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Ask a Question
3 | about: Ask a question.
4 | title: ''
5 | labels: question
6 | assignees: ''
7 | ---
8 |
9 | **Question**
10 |
11 | _Please include information such as the following: is your question to clarify an existing resource
12 | or are you asking about something new? what are you trying to accomplish? where have you looked for
13 | answers?_
14 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod frame_system;
2 | pub mod pallet_amm;
3 | pub mod pallet_asset_registry;
4 | pub mod pallet_balances;
5 | pub mod pallet_bridge;
6 | pub mod pallet_crowdloans;
7 | pub mod pallet_farming;
8 | pub mod pallet_liquid_staking;
9 | pub mod pallet_loans;
10 | pub mod pallet_membership;
11 | pub mod pallet_router;
12 | pub mod pallet_streaming;
13 | pub mod pallet_timestamp;
14 | pub mod pallet_xcm_helper;
15 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod frame_system;
2 | pub mod pallet_amm;
3 | pub mod pallet_asset_registry;
4 | pub mod pallet_balances;
5 | pub mod pallet_bridge;
6 | pub mod pallet_crowdloans;
7 | pub mod pallet_farming;
8 | pub mod pallet_liquid_staking;
9 | pub mod pallet_loans;
10 | pub mod pallet_membership;
11 | pub mod pallet_router;
12 | pub mod pallet_streaming;
13 | pub mod pallet_timestamp;
14 | pub mod pallet_xcm_helper;
15 |
--------------------------------------------------------------------------------
/scripts/helper/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "plugins": ["@typescript-eslint", "prettier"],
5 | "extends": [
6 | "eslint:recommended",
7 | "plugin:@typescript-eslint/eslint-recommended",
8 | "plugin:@typescript-eslint/recommended",
9 | "prettier"
10 | ],
11 | "rules": {
12 | "no-console": "off",
13 | "prettier/prettier": 2,
14 | "ban-ts-comment": "off"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.github/workflows/njsscan.yml:
--------------------------------------------------------------------------------
1 | name: Njsscan
2 | on:
3 | push:
4 | branches: [master]
5 | pull_request:
6 | branches: [master]
7 | jobs:
8 | njsscan:
9 | runs-on: ubuntu-latest
10 | name: njsscan check
11 | steps:
12 | - name: Checkout the code
13 | uses: actions/checkout@v3
14 | - name: nodejsscan scan
15 | id: njsscan
16 | uses: ajinabraham/njsscan-action@master
17 | with:
18 | args: "."
19 |
--------------------------------------------------------------------------------
/scripts/srtool-build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 |
5 | cd $DIR/../
6 |
7 | set -xe
8 |
9 | RUSTC_VERSION=1.66.1;
10 | PACKAGE=${PACKAGE:-vanilla-runtime};
11 | BUILD_OPTS=$BUILD_OPTS;
12 |
13 | docker run --rm -it \
14 | -e PACKAGE=$PACKAGE \
15 | -e BUILD_OPTS="$BUILD_OPTS" \
16 | -v $PWD:/build \
17 | -v $TMPDIR/cargo:/cargo-home \
18 | --user root \
19 | --network=host \
20 | paritytech/srtool:$RUSTC_VERSION
--------------------------------------------------------------------------------
/scripts/helper/src/config/index.ts:
--------------------------------------------------------------------------------
1 | import heikoConfig from './heiko.json'
2 | import parallelConfig from './parallel.json'
3 |
4 | export default function getConfig(network: string) {
5 | switch (network) {
6 | case 'vanilla-dev':
7 | case 'heiko-dev':
8 | return heikoConfig
9 | case 'kerria-dev':
10 | case 'parallel-dev':
11 | return parallelConfig
12 | default:
13 | throw new Error(`unsupported network detected: ${network}`)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 | [*]
3 | indent_style=tab
4 | indent_size=tab
5 | tab_width=4
6 | end_of_line=lf
7 | charset=utf-8
8 | trim_trailing_whitespace=true
9 | max_line_length=100
10 | insert_final_newline=true
11 |
12 | [*.md]
13 | max_line_length=80
14 | indent_style=space
15 | indent_size=2
16 |
17 | [*.yml]
18 | indent_style=space
19 | indent_size=2
20 | tab_width=8
21 | end_of_line=lf
22 |
23 | [*.sh]
24 | indent_style=space
25 | indent_size=2
26 | tab_width=8
27 | end_of_line=lf
28 |
--------------------------------------------------------------------------------
/.github/workflows/typos.yml:
--------------------------------------------------------------------------------
1 | name: Check typos
2 |
3 | on:
4 | # Triggers the workflow on push or pull request events but only for the master branch
5 | push:
6 | branches: [master]
7 | pull_request:
8 | branches: [master]
9 |
10 | jobs:
11 | run:
12 | name: Spell Check with Typos
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout Actions Repository
16 | uses: actions/checkout@v3
17 |
18 | - name: Check spelling of file.txt
19 | uses: crate-ci/typos@master
20 |
--------------------------------------------------------------------------------
/pallets/loans/rpc/runtime-api/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-loans-rpc-runtime-api'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, features = ['derive'] }
9 | primitives = { workspace = true }
10 | sp-api = { workspace = true }
11 | sp-runtime = { workspace = true }
12 |
13 | [features]
14 | default = ['std']
15 | std = ['codec/std', 'sp-api/std', 'sp-runtime/std']
16 |
17 | [lib]
18 | doctest = false
19 |
--------------------------------------------------------------------------------
/precompiles/utils/macro/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "precompile-utils-macro"
3 | authors = { workspace = true }
4 | edition = "2021"
5 | version = { workspace = true }
6 |
7 | [lib]
8 | proc-macro = true
9 |
10 | [[test]]
11 | name = "tests"
12 | path = "tests/tests.rs"
13 |
14 | [dependencies]
15 | num_enum = { workspace = true }
16 | sha3 = { workspace = true }
17 | proc-macro2 = { workspace = true }
18 | quote = { workspace = true }
19 | syn = { workspace = true, features = ["extra-traits", "fold", "full", "visit"] }
20 |
--------------------------------------------------------------------------------
/scripts/helper/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "esModuleInterop": true,
5 | "allowSyntheticDefaultImports": true,
6 | "resolveJsonModule": true,
7 | "target": "es6",
8 | "noImplicitAny": false,
9 | "moduleResolution": "node",
10 | "sourceMap": true,
11 | "outDir": "dist",
12 | "baseUrl": ".",
13 | "paths": {
14 | "*": ["node_modules/*", "src/types/*"],
15 | "@/*": ["./src/*"]
16 | }
17 | },
18 | "include": ["src/**/*"]
19 | }
20 |
--------------------------------------------------------------------------------
/pallets/router/rpc/runtime-api/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-router-rpc-runtime-api'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, features = ['derive'] }
9 | primitives = { workspace = true }
10 | sp-api = { workspace = true }
11 | sp-runtime = { workspace = true }
12 | sp-std = { workspace = true }
13 |
14 | [features]
15 | default = ['std']
16 | std = ['codec/std', 'sp-api/std', 'sp-runtime/std']
17 |
18 | [lib]
19 | doctest = false
20 |
--------------------------------------------------------------------------------
/pallets/stableswap/README.md:
--------------------------------------------------------------------------------
1 | # Stable Swap
2 |
3 | StableSwap implementation for Parallel.fi
4 |
5 | ## Functionality
6 | * To calculate delta simply call :- `Self::delta_util(tot_base_amount, tot_quote_amount).unwrap()`
7 |
8 | ## References
9 | * https://curve.fi/files/stableswap-paper.pdf
10 | * https://github.com/equilibrium-eosdt/equilibrium-curve-amm/blob/master/docs/deducing-get_y-formulas.pdf
11 | * https://miguelmota.com/blog/understanding-stableswap-curve/
12 | * https://github.com/curvefi/curve-contract/blob/master/contracts/pool-templates/base/SwapTemplateBase.vy
13 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Each line is a file pattern followed by one or more owners.
2 |
3 | # These owners will be the default owners for everything in
4 | # the repo. Unless a later match takes precedence,
5 | # @backend-leads will be requested for review when
6 | # someone opens a pull request.
7 | * @parallel-finance/backend-leads
8 |
9 | # Order is important; the last matching pattern takes the most
10 | # precedence. When someone opens a pull request that only
11 | # modifies github workflows files, only @workflows-owner and not
12 | # the global owner(s) will be requested for a review.
13 | .github/workflows @parallel-finance/workflows-owner
14 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/get/derivative.ts:
--------------------------------------------------------------------------------
1 | import { subAccountId } from '../../utils'
2 | import { Command, CreateCommandParameters, program } from '@caporal/core'
3 |
4 | export default function ({ createCommand }: CreateCommandParameters): Command {
5 | return createCommand('display derivative account address')
6 | .argument('
', 'address of source account')
7 | .argument('', 'derivative index', {
8 | validator: program.NUMBER
9 | })
10 | .action(actionParameters => {
11 | const {
12 | logger,
13 | args: { address, index }
14 | } = actionParameters
15 | logger.info(subAccountId(address.toString(), index.valueOf() as number))
16 | })
17 | }
18 |
--------------------------------------------------------------------------------
/primitives/src/network.rs:
--------------------------------------------------------------------------------
1 | #[cfg(feature = "std")]
2 | use serde::{Deserialize, Serialize};
3 | use sp_runtime::RuntimeDebug;
4 |
5 | /// Network type for parallel.
6 | #[derive(Clone, Copy, RuntimeDebug)]
7 | #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
8 | pub enum NetworkType {
9 | Parallel,
10 | Heiko,
11 | }
12 |
13 | impl NetworkType {
14 | /// Return ss58 address prefix from network type.
15 | pub fn ss58_addr_format_id(&self) -> u8 {
16 | match self {
17 | NetworkType::Heiko => HEIKO_PREFIX,
18 | NetworkType::Parallel => PARALLEL_PREFIX,
19 | }
20 | }
21 | }
22 |
23 | pub const HEIKO_PREFIX: u8 = 110;
24 | pub const PARALLEL_PREFIX: u8 = 172;
25 |
--------------------------------------------------------------------------------
/support/src/lib.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #![cfg_attr(not(feature = "std"), no_std)]
16 | pub mod math_helper;
17 |
--------------------------------------------------------------------------------
/scripts/bump.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 | # usage: ./scripts/bump.sh 1.7.9
4 |
5 | # The following line ensure we run from the project root
6 | PROJECT_ROOT=`git rev-parse --show-toplevel`
7 | cd ${PROJECT_ROOT}
8 |
9 | if [ $# -lt 1 ]; then
10 | echo "help: ./scripts/bump.sh " && exit 1
11 | fi
12 |
13 | FROM=`grep "^version" ./node/parallel/Cargo.toml | egrep -o "([0-9\.]+)"`
14 | TO=${1}
15 |
16 | cargo_toml_list=$(find . -name "Cargo.toml" -not -path "./target/*")
17 | echo "bump parallel version from ${FROM} to ${TO}..."
18 | for cargo_toml in $cargo_toml_list
19 | do
20 | if [ "$(uname)" == "Darwin" ];then # Mac
21 | sed -i "" "s/$FROM/$TO/g" ${cargo_toml}
22 | else
23 | sed -i "s/$FROM/$TO/g" ${cargo_toml} # Linux
24 | fi
25 | done
26 |
--------------------------------------------------------------------------------
/scripts/helper/Dockerfile.release:
--------------------------------------------------------------------------------
1 | FROM node:14.17.0 as builder
2 | LABEL description="This is the build stage for parallel helper. Here we create the dist."
3 |
4 | WORKDIR /parallel-helper
5 |
6 | COPY . /parallel-helper
7 |
8 | RUN yarn && yarn build
9 |
10 | # ===== SECOND STAGE ======
11 |
12 | FROM node:14.17.0
13 | LABEL description="This is the 2nd stage: a very small image where we copy the parallel helper."
14 |
15 | COPY --from=builder /parallel-helper/dist /usr/local/lib/dist
16 | COPY --from=builder /parallel-helper/node_modules /usr/local/lib/node_modules
17 |
18 | RUN sed -i '1i\#!/usr/bin/env node' /usr/local/lib/dist/main.js \
19 | && chmod +x /usr/local/lib/dist/main.js \
20 | && ln -s /usr/local/lib/dist/main.js /usr/local/bin/parallel-helper
21 |
22 | ENTRYPOINT ["/usr/local/bin/parallel-helper"]
23 |
--------------------------------------------------------------------------------
/scripts/upgrade.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e
3 | # usage: ./scripts/upgrade.sh v0.9.17
4 |
5 | # The following line ensure we run from the project root
6 | PROJECT_ROOT=`git rev-parse --show-toplevel`
7 | cd ${PROJECT_ROOT}
8 |
9 | if [ $# -lt 1 ]; then
10 | echo "help: ./scripts/upgrade.sh " && exit 1
11 | fi
12 |
13 | FROM=`grep "^substrate-build-script-utils" ./node/parallel/Cargo.toml | egrep -o "(v[0-9\.]+)"`
14 | TO=${1}
15 |
16 | cargo_toml_list=$(find . -name "Cargo.toml" -not -path "./target/*")
17 | echo "upgrading substrate dependencies from ${FROM} to ${TO}..."
18 | for cargo_toml in $cargo_toml_list
19 | do
20 | if [ "$(uname)" == "Darwin" ];then # Mac
21 | sed -i "" "s/$FROM/$TO/g" ${cargo_toml}
22 | else
23 | sed -i "s/$FROM/$TO/g" ${cargo_toml} # Linux
24 | fi
25 | done
26 |
--------------------------------------------------------------------------------
/LIVE.md:
--------------------------------------------------------------------------------
1 | ## Heiko
2 |
3 | - `node`: parallelfinance/parallel:v1.9.5
4 | - `runtime`: 195
5 | - `branch`: https://github.com/parallel-finance/parallel/tree/v1.9.5
6 | - `polkadot`: v0.9.32
7 | - `wasm`: https://github.com/parallel-finance/parallel/releases/download/v1.9.5/heiko_runtime.compact.compressed.wasm
8 | - `blake256_hash`: 0xaac1e44cfe5a88fdfad237b47961a3fe13c464bcf4c9d840e55afb6abcfd8454
9 | - `deployment_date`: 2023/02/21
10 |
11 | ## Parallel
12 |
13 | - `node`: parallelfinance/parallel:v1.9.5
14 | - `runtime`: 195
15 | - `branch`: https://github.com/parallel-finance/parallel/tree/v1.9.5
16 | - `polkadot`: v0.9.32
17 | - `wasm`: https://github.com/parallel-finance/parallel/releases/download/v1.9.5/parallel_runtime.compact.compressed.wasm
18 | - `blake256_hash`: 0x2b14ff980bafc6ba62f9a1ae9f56a0f52fd36c2e68cc19d1efc8faecda580831
19 | - `deployment_date`: 2023/02/21
20 |
--------------------------------------------------------------------------------
/pallets/loans/rpc/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-loans-rpc'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, features = ['std'] }
9 | jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
10 | primitives = { workspace = true }
11 | serde = { workspace = true, features = ['derive'] }
12 | sp-api = { workspace = true, features = ['std'] }
13 | sp-blockchain = { workspace = true }
14 | sp-core = { workspace = true, features = ['std'] }
15 | sp-rpc = { workspace = true }
16 | sp-runtime = { workspace = true, features = ['std'] }
17 |
18 | pallet-loans-rpc-runtime-api = { path = 'runtime-api', default-features = false }
19 |
20 | [lib]
21 | doctest = false
22 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod frame_system;
2 | pub mod pallet_assets;
3 | pub mod pallet_collator_selection;
4 | pub mod pallet_collective;
5 | pub mod pallet_democracy;
6 | pub mod pallet_multisig;
7 | pub mod pallet_proxy;
8 | pub mod pallet_scheduler;
9 | pub mod pallet_amm;
10 | pub mod pallet_asset_registry;
11 | pub mod pallet_balances;
12 | pub mod pallet_bridge;
13 | pub mod pallet_crowdloans;
14 | pub mod pallet_farming;
15 | pub mod pallet_liquid_staking;
16 | pub mod pallet_loans;
17 | pub mod pallet_membership;
18 | pub mod pallet_router;
19 | pub mod pallet_streaming;
20 | pub mod pallet_timestamp;
21 | pub mod pallet_xcm_helper;
22 | pub mod cumulus_pallet_xcmp_queue;
23 | pub mod orml_oracle;
24 | pub mod orml_vesting;
25 | pub mod pallet_identity;
26 | pub mod pallet_preimage;
27 | pub mod pallet_treasury;
28 | pub mod pallet_utility;
29 | pub mod pallet_xcm;
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod frame_system;
2 | pub mod pallet_assets;
3 | pub mod pallet_collator_selection;
4 | pub mod pallet_collective;
5 | pub mod pallet_democracy;
6 | pub mod pallet_multisig;
7 | pub mod pallet_proxy;
8 | pub mod pallet_scheduler;
9 | pub mod pallet_amm;
10 | pub mod pallet_asset_registry;
11 | pub mod pallet_balances;
12 | pub mod pallet_bridge;
13 | pub mod pallet_crowdloans;
14 | pub mod pallet_farming;
15 | pub mod pallet_liquid_staking;
16 | pub mod pallet_loans;
17 | pub mod pallet_membership;
18 | pub mod pallet_router;
19 | pub mod pallet_streaming;
20 | pub mod pallet_timestamp;
21 | pub mod pallet_xcm_helper;
22 | pub mod cumulus_pallet_xcmp_queue;
23 | pub mod orml_oracle;
24 | pub mod orml_vesting;
25 | pub mod pallet_identity;
26 | pub mod pallet_preimage;
27 | pub mod pallet_treasury;
28 | pub mod pallet_utility;
29 | pub mod pallet_xcm;
--------------------------------------------------------------------------------
/node/parallel/build.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
16 |
17 | fn main() {
18 | generate_cargo_keys();
19 | rerun_if_git_head_changed();
20 | }
21 |
--------------------------------------------------------------------------------
/primitives/src/paras.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | pub mod statemint {
16 | pub const ID: u32 = 1000;
17 | }
18 |
19 | pub mod statemine {
20 | pub const ID: u32 = 1000;
21 | pub const PALLET_INSTANCE: u8 = 50;
22 | }
23 |
--------------------------------------------------------------------------------
/pallets/currency-adapter/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-currency-adapter'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len'] }
12 | frame-support = { workspace = true }
13 | frame-system = { workspace = true }
14 | primitives = { workspace = true }
15 | scale-info = { workspace = true, features = ['derive'] }
16 | sp-runtime = { workspace = true }
17 |
18 | [features]
19 | default = ['std']
20 | std = [
21 | 'codec/std',
22 | 'frame-support/std',
23 | 'frame-system/std',
24 | 'sp-runtime/std',
25 | 'scale-info/std',
26 | 'primitives/std',
27 | ]
28 | try-runtime = ['frame-support/try-runtime']
29 |
30 | [lib]
31 | doctest = false
32 |
--------------------------------------------------------------------------------
/pallets/router/rpc/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-router-rpc'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, features = ['std'] }
9 | jsonrpsee = { workspace = true, features = ["server", "macros"] }
10 | primitives = { workspace = true }
11 | serde = { workspace = true, features = ['derive'] }
12 | sp-api = { workspace = true, features = ['std'] }
13 | sp-blockchain = { workspace = true }
14 | sp-core = { workspace = true, features = ['std'] }
15 | sp-rpc = { workspace = true }
16 | sp-runtime = { workspace = true, features = ['std'] }
17 | sp-std = { workspace = true }
18 |
19 | pallet-router-rpc-runtime-api = { path = 'runtime-api', default-features = false }
20 |
21 | [lib]
22 | doctest = false
23 |
--------------------------------------------------------------------------------
/integration-tests/src/lib.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #![cfg(test)]
16 |
17 | mod kusama_call;
18 | mod kusama_test_net;
19 | mod kusama_transfer;
20 | mod polkadot_test_net;
21 | mod polkadot_transfer;
22 | mod setup;
23 | mod sibling_transfer;
24 | mod statemine;
25 |
--------------------------------------------------------------------------------
/runtime/heiko/build.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | use substrate_wasm_builder::WasmBuilder;
16 |
17 | fn main() {
18 | WasmBuilder::new()
19 | .with_current_project()
20 | .export_heap_base()
21 | .import_memory()
22 | .build()
23 | }
24 |
--------------------------------------------------------------------------------
/runtime/kerria/build.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | use substrate_wasm_builder::WasmBuilder;
16 |
17 | fn main() {
18 | WasmBuilder::new()
19 | .with_current_project()
20 | .export_heap_base()
21 | .import_memory()
22 | .build()
23 | }
24 |
--------------------------------------------------------------------------------
/runtime/parallel/build.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | use substrate_wasm_builder::WasmBuilder;
16 |
17 | fn main() {
18 | WasmBuilder::new()
19 | .with_current_project()
20 | .export_heap_base()
21 | .import_memory()
22 | .build()
23 | }
24 |
--------------------------------------------------------------------------------
/node/parallel/src/main.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #![warn(unused_extern_crates)]
16 |
17 | mod chain_spec;
18 | #[macro_use]
19 | mod service;
20 | mod cli;
21 | mod client;
22 | mod command;
23 | mod rpc;
24 |
25 | fn main() -> sc_cli::Result<()> {
26 | command::run()
27 | }
28 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/get/xcm_units_per_second.ts:
--------------------------------------------------------------------------------
1 | import { calcWeightPerSecond } from '../../utils'
2 | import { Command, CreateCommandParameters, program } from '@caporal/core'
3 |
4 | export default function ({ createCommand }: CreateCommandParameters): Command {
5 | return createCommand('calculate units_per_second for xcm reserved transfer')
6 | .argument('', 'precision of asset', {
7 | validator: program.NUMBER
8 | })
9 | .argument('', 'price of asset', {
10 | validator: program.NUMBER
11 | })
12 | .action(actionParameters => {
13 | const {
14 | logger,
15 | args: { precision, price }
16 | } = actionParameters
17 | const precision_num = precision.valueOf() as number
18 | const price_num = price.valueOf() as number
19 | const result = calcWeightPerSecond(precision_num, price_num)
20 | logger.info(result.toString())
21 | })
22 | }
23 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/suggest-a-feature.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Suggest a Feature
3 | about: Suggest a new feature or an improvement to an existing feature.
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 | ---
8 |
9 | **Motivation**
10 |
11 | _Describe the need or frustration that motivated you to make this suggestion. Please note that the
12 | goal of this project is to provide a general-purpose template project, so please take care when
13 | suggesting features that may be specific to a particular use case._
14 |
15 | **Suggested Solution**
16 |
17 | _Describe your suggested solution to the need or frustration that you are experiencing._
18 |
19 | **Alternatives**
20 |
21 | _Describe any alternative solutions or features you considered and why you believe your suggested
22 | solution is preferable._
23 |
24 | **Additional Information**
25 |
26 | _Provide any additional information that you believe may help us evaluate your suggestion._
27 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/get/sovereign.ts:
--------------------------------------------------------------------------------
1 | import { sovereignParaOf, sovereignRelayOf } from '../../utils'
2 | import { Command, CreateCommandParameters, program } from '@caporal/core'
3 |
4 | export default function ({ createCommand }: CreateCommandParameters): Command {
5 | return createCommand("display parachain's sovereign account")
6 | .argument('', 'parachain id', {
7 | validator: program.NUMBER
8 | })
9 | .option('-s,--sibling [boolean]', 'sibling mode', {
10 | validator: program.BOOLEAN,
11 | default: false
12 | })
13 | .action(actionParameters => {
14 | const {
15 | logger,
16 | args: { parachainId },
17 | options: { sibling }
18 | } = actionParameters
19 | logger.info(
20 | sibling
21 | ? sovereignParaOf(parachainId.valueOf() as number)
22 | : sovereignRelayOf(parachainId.valueOf() as number)
23 | )
24 | })
25 | }
26 |
--------------------------------------------------------------------------------
/scripts/create-volume.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 |
5 | cd $DIR
6 |
7 | set -xe
8 |
9 | # https://dot-rocksdb.polkashots.io
10 | # https://ksm-rocksdb.polkashots.io
11 | # https://snapshot-parallel.s3.us-east-2.amazonaws.com/db.7z
12 | # https://snapshot-heiko.s3.us-east-2.amazonaws.com/db.7z
13 |
14 | DB_PATH="polkadot/chains/ksmcc3"
15 | SNAPSHOT_PATH="db/full"
16 | VOLUME="chains"
17 |
18 | if [ "$1" == "--polkadot" ]; then
19 | DB_PATH="polkadot/chains/polkadot"
20 | elif [ "$1" == "--westend" ]; then
21 | DB_PATH="polkadot/chains/westend2"
22 | fi
23 |
24 | # docker volume rm $VOLUME || true
25 | docker volume create $VOLUME || true
26 |
27 | mountpoint=$(docker volume inspect $VOLUME | jq '.[].Mountpoint' | tr -d '"')
28 | sudo mkdir -p $mountpoint/$DB_PATH/db || true
29 | sudo rm -fr $mountpoint/$DB_PATH/db/full || true
30 | sudo mv $SNAPSHOT_PATH $mountpoint/$DB_PATH/db
31 |
32 | sudo chown -R $(id -un):$(id -gn) $mountpoint
33 |
--------------------------------------------------------------------------------
/docs/RUNTIME-UPGRADE.md:
--------------------------------------------------------------------------------
1 | ## Runtime Upgrade Guide
2 |
3 | ### Checklist
4 |
5 | - [ ] Spec_version, transaction_version is bumped
6 | - [ ] Previous storage migration should have been removed from runtime's OnRuntimeUpgrade impl
7 | - [ ] New storage migration should have been added to runtime
8 | - [ ] Node should be bumped first. After starting to produce blocks in a stable way we can then bump runtime
9 | - [ ] Srtool compiled runtime wasm should be preferred, compressed runtime wasm is preferred
10 | - [ ] Runtime wasm should be <= 1MB, if it's a bit more than 1MB it's ok but shouldn't excess too much
11 | - [ ] Live.md should be updated after the runtime upgrade
12 |
13 | ### via Sudo
14 |
15 | ```
16 | sudo -> sudo -> parachainSystem -> authorizeUpgrade
17 | sudo -> sudo -> parachainSystem -> enactUpgrade
18 | ```
19 |
20 | ### via Council (council member only)
21 |
22 | 1. propose motion
23 | 2. vote for your motion
24 | 3. ask other council members to vote
25 | 4. close and execute the motion
26 |
--------------------------------------------------------------------------------
/pallets/xcm-helper/src/benchmarking.rs:
--------------------------------------------------------------------------------
1 | //! Crowdloans pallet benchmarking.
2 |
3 | #![cfg(feature = "runtime-benchmarks")]
4 | use super::*;
5 | use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
6 | use frame_system::{self, RawOrigin as SystemOrigin};
7 |
8 | const XCM_WEIGHT_FEE: XcmWeightFeeMisc = XcmWeightFeeMisc {
9 | weight: Weight::from_ref_time(3_000_000_000),
10 | fee: 50000000000u128,
11 | };
12 |
13 | fn assert_last_event(generic_event: ::RuntimeEvent) {
14 | frame_system::Pallet::::assert_last_event(generic_event.into());
15 | }
16 |
17 | benchmarks! {
18 | where_clause {
19 | where
20 | ::RuntimeOrigin: From
21 | }
22 |
23 | update_xcm_weight_fee {
24 | }: _(SystemOrigin::Root, XcmCall::AddMemo, XCM_WEIGHT_FEE)
25 | verify {
26 | assert_last_event::(Event::XcmWeightFeeUpdated(XCM_WEIGHT_FEE).into())
27 | }
28 |
29 | }
30 |
31 | impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test,);
32 |
--------------------------------------------------------------------------------
/pallets/emergency-shutdown/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-emergency-shutdown'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len']}
12 | frame-support = { workspace = true }
13 | frame-system = { workspace = true }
14 | pallet-traits = { workspace = true }
15 | scale-info = { workspace = true, features = ['derive'] }
16 | sp-io = { workspace = true }
17 | sp-runtime = { workspace = true }
18 | sp-std = { workspace = true }
19 |
20 | [dev-dependencies]
21 | sp-core = { workspace = true, features = ['std'] }
22 |
23 | [features]
24 | default = ['std']
25 | std = [
26 | 'codec/std',
27 | 'frame-support/std',
28 | 'frame-system/std',
29 | 'pallet-traits/std',
30 | 'sp-runtime/std',
31 | 'scale-info/std',
32 | 'sp-std/std',
33 | ]
34 | try-runtime = ['frame-support/try-runtime']
35 |
36 | [lib]
37 | doctest = false
38 |
--------------------------------------------------------------------------------
/config.yml:
--------------------------------------------------------------------------------
1 | relaychain:
2 | image: parallelfinance/polkadot:v0.9.42
3 | chain: polkadot-local
4 | env:
5 | RUST_LOG: xcm=trace
6 | flags:
7 | - --rpc-methods=unsafe
8 | - --wasm-execution=compiled
9 | - --execution=wasm
10 | - --state-cache-size=0
11 | nodes:
12 | - name: alice
13 | - name: bob
14 | - name: charlie
15 | - name: dave
16 | parachains:
17 | - image: parallelfinance/parallel:latest
18 | chain:
19 | base: kerria-dev
20 | collators:
21 | - alice
22 | sudo: dave
23 | id: 2012
24 | parachain: true
25 | flags:
26 | - --rpc-methods=unsafe
27 | - --unsafe-rpc-external
28 | - --force-authoring
29 | - --wasm-execution=compiled
30 | - --execution=wasm
31 | - --pruning=archive
32 | - --state-cache-size=0
33 | relaychainFlags:
34 | - --wasm-execution=compiled
35 | - --execution=wasm
36 | - --state-cache-size=0
37 | env:
38 | RUST_LOG: eth=trace,xcm=trace,loans=trace,liquidStaking=trace,crowdloans=trace,amm=trace,stableswap=trace,router=trace,bridge=trace,prices=trace
39 | nodes:
40 | - flags:
41 | - --alice
42 |
--------------------------------------------------------------------------------
/scripts/helper/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "parallel-helper",
3 | "version": "1.0.0",
4 | "main": "src/main.ts",
5 | "bin": "dist/main.js",
6 | "scripts": {
7 | "start": "ts-node src/main.ts",
8 | "build": "tsc",
9 | "format": "prettier --config .prettierrc.json 'src/**/*.ts' --write",
10 | "lint": "eslint . --ext .ts --fix"
11 | },
12 | "devDependencies": {
13 | "@types/node": "^17.0.21",
14 | "@types/shelljs": "^0.8.9",
15 | "@typescript-eslint/eslint-plugin": "5.12.1",
16 | "@typescript-eslint/parser": "5.12.1",
17 | "eslint": "^8.10.0",
18 | "eslint-config-prettier": "^8.4.0",
19 | "eslint-plugin-prettier": "^4.0.0",
20 | "prettier": "^2.5.1",
21 | "ts-node": "^10.2.1",
22 | "typescript": "~4.5.5"
23 | },
24 | "dependencies": {
25 | "@caporal/core": "^2.0.2",
26 | "@polkadot/api": "^10.11.2",
27 | "@polkadot/keyring": "^12.6.2",
28 | "@polkadot/rpc-core": "^10.11.2",
29 | "@polkadot/types": "^10.11.2",
30 | "@polkadot/util": "^12.6.2",
31 | "@polkadot/util-crypto": "^12.6.2",
32 | "axios": "^0.27.2",
33 | "bignumber.js": "^9.0.2",
34 | "dotenv": "^16.0.0",
35 | "shelljs": "^0.8.5"
36 | },
37 | "packageManager": "yarn@3.3.0"
38 | }
39 |
--------------------------------------------------------------------------------
/pallets/router/rpc/runtime-api/src/lib.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #![cfg_attr(not(feature = "std"), no_std)]
16 |
17 | use codec::Codec;
18 | use primitives::CurrencyId;
19 | use sp_runtime::DispatchError;
20 | use sp_std::vec::Vec;
21 |
22 | sp_api::decl_runtime_apis! {
23 | pub trait RouterApi where
24 | Balance: Codec, {
25 | fn get_best_route(
26 | amount: Balance,
27 | token_in: CurrencyId,
28 | token_out: CurrencyId,
29 | reversed: bool,
30 | ) -> Result<(Vec, Balance), DispatchError>;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Editor
2 | .idea/
3 | .vim/
4 | .vscode/
5 |
6 | # will have compiled files and executables
7 | **/target/
8 | # These are backup files generated by rustfmt
9 | **/*.rs.bk
10 |
11 | .DS_Store
12 |
13 | # The cache for docker container dependency
14 | .docker
15 |
16 | # The cache for chain data in container
17 | .local
18 |
19 | # cargo-remote configuration
20 | .cargo-remote.toml
21 |
22 | # archives
23 | *.tar.xz
24 | *.tar.gz
25 | *.tgz
26 | *.7z
27 |
28 | # The directory for creating release
29 | dist/
30 |
31 | # temporary files generated by polkadot-launch
32 | *.log
33 | *-local*.json
34 | *-dev*.json
35 | *-staging*.json
36 |
37 | # chain db
38 | chains/
39 | db/
40 | local-test/
41 |
42 | # secrets
43 | **/keystore*
44 |
45 | # parachain launch output directory
46 | output/
47 |
48 | # snapshot generated by try-runtime subcommand
49 | snapshot.bin
50 |
51 | # vimspector debugger config
52 | .vimspector.json
53 |
54 | # Setting for non zero-installs (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
55 | **/.yarn/*
56 | **/.pnp.*
57 | **/node_modules/
58 | **/yarn-error.log
59 | !**/.yarn/releases
60 | !**/.yarn/plugins
61 | !**/.yarn/sdks
62 | !**/.yarn/versions
63 |
64 | scripts/helper/.env
65 | soljson*
66 |
67 | info/
68 |
--------------------------------------------------------------------------------
/primitives/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'parallel-primitives'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, package = 'parity-scale-codec' }
9 | cumulus-primitives-core = { workspace = true }
10 | frame-support = { workspace = true }
11 | frame-system = { workspace = true }
12 | log = { workspace = true }
13 | orml-oracle = { workspace = true }
14 | scale-info = { workspace = true, features = ['derive'] }
15 | serde = { workspace = true, optional = true }
16 | sp-consensus-aura = { workspace = true }
17 | sp-core = { workspace = true }
18 | sp-io = { workspace = true }
19 | sp-runtime = { workspace = true }
20 | sp-std = { workspace = true }
21 |
22 | [features]
23 | default = ['std']
24 | std = [
25 | 'serde',
26 | 'codec/std',
27 | 'sp-runtime/std',
28 | 'sp-core/std',
29 | 'sp-std/std',
30 | 'sp-io/std',
31 | 'orml-oracle/std',
32 | 'sp-consensus-aura/std',
33 | 'frame-system/std',
34 | 'frame-support/std',
35 | 'scale-info/std',
36 | 'cumulus-primitives-core/std',
37 | ]
38 |
39 | [lib]
40 | doctest = false
41 |
--------------------------------------------------------------------------------
/support/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'parallel-support'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, features = ['max-encoded-len'] }
12 | frame-support = { workspace = true }
13 | log = { workspace = true }
14 | num-bigint = { workspace = true }
15 | num-traits = { workspace = true }
16 | scale-info = { workspace = true, features = ['derive'] }
17 | serde = { workspace = true, features = ['derive'], optional = true }
18 | sp-core = { workspace = true }
19 | sp-io = { workspace = true }
20 | sp-runtime = { workspace = true }
21 | sp-std = { workspace = true }
22 | substrate-fixed = { workspace = true }
23 |
24 | [dev-dependencies]
25 | sp-core = { workspace = true }
26 |
27 | [features]
28 | default = ['std']
29 | std = [
30 | 'serde',
31 | 'codec/std',
32 | 'frame-support/std',
33 | 'sp-runtime/std',
34 | 'scale-info/std',
35 | 'sp-std/std',
36 | 'num-bigint/std',
37 | 'num-traits/std',
38 | 'sp-core/std',
39 | ]
40 |
41 | try-runtime = ['frame-support/try-runtime']
42 |
43 | [lib]
44 | doctest = false
45 |
46 | [package.metadata.cargo-udeps.ignore]
47 | normal = ['frame-support']
48 |
--------------------------------------------------------------------------------
/precompiles/utils/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "precompile-utils"
3 | authors = { workspace = true }
4 | edition = '2021'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | impl-trait-for-tuples = { workspace = true }
9 | log = { workspace = true }
10 | num_enum = { workspace = true }
11 | similar-asserts = { workspace = true, optional = true }
12 |
13 | precompile-utils-macro = { path = "macro" }
14 |
15 | # Substrate
16 | codec = { workspace = true, package = 'parity-scale-codec' }
17 | frame-support = { workspace = true }
18 | frame-system = { workspace = true }
19 | sp-core = { workspace = true }
20 | sp-io = { workspace = true }
21 | sp-runtime = { workspace = true }
22 | sp-std = { workspace = true }
23 |
24 | # Frontier
25 | evm = { workspace = true, features = ["with-codec"] }
26 | fp-evm = { workspace = true }
27 | pallet-evm = { workspace = true, features = ['forbid-evm-reentrancy'] }
28 |
29 | # Polkadot / XCM
30 | xcm = { workspace = true }
31 |
32 | [dev-dependencies]
33 | hex-literal = { workspace = true }
34 | sha3 = { workspace = true }
35 |
36 | [features]
37 | default = ["std"]
38 | std = [
39 | "codec/std",
40 | "fp-evm/std",
41 | "frame-support/std",
42 | "frame-system/std",
43 | "pallet-evm/std",
44 | "sp-core/std",
45 | "sp-io/std",
46 | "sp-std/std",
47 | "sp-runtime/std",
48 | "xcm/std",
49 | ]
50 | testing = ["similar-asserts", "std"]
51 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_timestamp.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_timestamp`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_timestamp
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_timestamp.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_timestamp`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_timestamp::WeightInfo for WeightInfo {
31 | // Storage: Timestamp Now (r:1 w:1)
32 | fn set() -> Weight {
33 | Weight::from_ref_time(12_928_000 as u64)
34 | .saturating_add(T::DbWeight::get().reads(1 as u64))
35 | .saturating_add(T::DbWeight::get().writes(1 as u64))
36 | }
37 | fn on_finalize() -> Weight {
38 | Weight::from_ref_time(8_360_000 as u64)
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_timestamp.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_timestamp`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vanilla-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=vanilla-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_timestamp
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/vanilla/src/weights/pallet_timestamp.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_timestamp`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_timestamp::WeightInfo for WeightInfo {
31 | // Storage: Timestamp Now (r:1 w:1)
32 | fn set() -> Weight {
33 | Weight::from_ref_time(12_673_000 as u64)
34 | .saturating_add(T::DbWeight::get().reads(1 as u64))
35 | .saturating_add(T::DbWeight::get().writes(1 as u64))
36 | }
37 | fn on_finalize() -> Weight {
38 | Weight::from_ref_time(8_620_000 as u64)
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_xcm_helper.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_xcm_helper`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_xcm_helper
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_xcm_helper.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_xcm_helper`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_xcm_helper::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: XcmHelper XcmWeightFee (r:1 w:1)
33 | fn update_xcm_weight_fee() -> Weight {
34 | Weight::from_ref_time(37_674_000 as u64)
35 | .saturating_add(T::DbWeight::get().reads(2 as u64))
36 | .saturating_add(T::DbWeight::get().writes(2 as u64))
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_xcm_helper.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_xcm_helper`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vanilla-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=vanilla-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_xcm_helper
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/vanilla/src/weights/pallet_xcm_helper.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_xcm_helper`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_xcm_helper::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: XcmHelper XcmWeightFee (r:1 w:1)
33 | fn update_xcm_weight_fee() -> Weight {
34 | Weight::from_ref_time(38_001_000 as u64)
35 | .saturating_add(T::DbWeight::get().reads(2 as u64))
36 | .saturating_add(T::DbWeight::get().writes(2 as u64))
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Dockerfile.release:
--------------------------------------------------------------------------------
1 | FROM docker.io/paritytech/ci-linux:production as builder
2 | LABEL description="This is the build stage for Parallel. Here we create the binary."
3 |
4 | ARG PROFILE=production
5 | ARG BIN=parallel
6 |
7 | WORKDIR /parallel
8 |
9 | COPY . /parallel
10 |
11 | RUN rustup default nightly
12 |
13 | RUN cargo build --workspace --exclude runtime-integration-tests --profile $PROFILE --bin $BIN --features runtime-benchmarks --features try-runtime
14 |
15 | # ===== SECOND STAGE ======
16 |
17 | FROM docker.io/library/ubuntu:20.04
18 | ENV DEBIAN_FRONTEND=noninteractive
19 | LABEL description="This is the 2nd stage: a very small image where we copy the Parallel binary."
20 |
21 | ARG PROFILE=production
22 | ARG BIN=parallel
23 |
24 | ENV BIN_PATH=/usr/local/bin/$BIN
25 |
26 | COPY --from=builder /parallel/target/$PROFILE/$BIN /usr/local/bin
27 |
28 | RUN apt update -y \
29 | && apt install -y ca-certificates libssl-dev tzdata \
30 | && useradd -m -u 1000 -U -s /bin/sh -d /parallel parallel \
31 | && mkdir -p /parallel/.local \
32 | && mkdir /data \
33 | && chown -R parallel:parallel /data \
34 | && ln -s /data /parallel/.local/share \
35 | && chown -R parallel:parallel /parallel/.local/share
36 |
37 | USER parallel
38 | WORKDIR /parallel
39 | EXPOSE 30333 9933 9944 29933
40 | VOLUME ["/data"]
41 |
42 | RUN echo '#!/bin/bash\n$BIN_PATH $@' > .entrypoint.sh
43 | RUN chmod u+x .entrypoint.sh
44 |
45 | ENTRYPOINT ["/parallel/.entrypoint.sh"]
46 |
--------------------------------------------------------------------------------
/pallets/loans/rpc/runtime-api/src/lib.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #![cfg_attr(not(feature = "std"), no_std)]
16 |
17 | use codec::Codec;
18 | use primitives::{CurrencyId, Liquidity, Rate, Ratio, Shortfall};
19 | use sp_runtime::{DispatchError, FixedU128};
20 |
21 | sp_api::decl_runtime_apis! {
22 | pub trait LoansApi where
23 | AccountId: Codec,
24 | Balance: Codec {
25 | fn get_account_liquidity(account: AccountId) -> Result<(Liquidity, Shortfall, Liquidity, Shortfall), DispatchError>;
26 | fn get_market_status(asset_id: CurrencyId) -> Result<(Rate, Rate, Rate, Ratio, Balance, Balance, FixedU128), DispatchError>;
27 | fn get_liquidation_threshold_liquidity(account: AccountId) -> Result<(Liquidity, Shortfall, Liquidity, Shortfall), DispatchError>;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/pallets/asset-registry/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-asset-registry'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | log = { workspace = true }
9 | serde = { workspace = true, optional = true }
10 |
11 | # Substrate
12 | frame-support = { workspace = true }
13 | frame-system = { workspace = true }
14 | pallet-traits = { workspace = true }
15 | codec = { workspace = true, package = 'parity-scale-codec', features = ['derive'] }
16 | scale-info = { workspace = true, features = ['derive'] }
17 | sp-io = { workspace = true }
18 | sp-runtime = { workspace = true }
19 | sp-std = { workspace = true }
20 |
21 | # Polkadot
22 | xcm = { workspace = true }
23 |
24 | # Benchmarks
25 | frame-benchmarking = { workspace = true, optional = true }
26 |
27 | [dev-dependencies]
28 | pallet-balances = { workspace = true, features = ['std'] }
29 | sp-core = { workspace = true, features = ['std'] }
30 |
31 | [features]
32 | default = ['std']
33 | runtime-benchmarks = ['frame-benchmarking']
34 | std = [
35 | 'frame-support/std',
36 | 'frame-system/std',
37 | 'codec/std',
38 | 'pallet-traits/std',
39 | 'scale-info/std',
40 | 'serde',
41 | 'sp-io/std',
42 | 'sp-runtime/std',
43 | 'sp-std/std',
44 | 'xcm/std',
45 | ]
46 | try-runtime = ['frame-support/try-runtime']
47 |
48 | [lib]
49 | doctest = false
50 |
--------------------------------------------------------------------------------
/pallets/evm-signatures/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-evm-signatures"
3 | authors = { workspace = true }
4 | edition = '2021'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, package = 'parity-scale-codec', features = ['derive'] }
9 | frame-support = { workspace = true }
10 | frame-system = { workspace = true }
11 | scale-info = { workspace = true, features = ["derive"] }
12 | serde = { workspace = true, features = ["derive"], optional = true }
13 | sp-core = { workspace = true }
14 | sp-io = { workspace = true }
15 | sp-runtime = { workspace = true }
16 | sp-std = { workspace = true }
17 | pallet-evm = { workspace = true, features = ['forbid-evm-reentrancy'] }
18 | primitives = { workspace = true }
19 |
20 |
21 | [dev-dependencies]
22 | hex-literal = { workspace = true }
23 | libsecp256k1 = { workspace = true }
24 | pallet-balances = { workspace = true, features = ['std'] }
25 | sp-core = { workspace = true, features = ['std'] }
26 | sp-keyring = { workspace = true }
27 | pallet-assets = { workspace = true, features = ['std'] }
28 |
29 | [features]
30 | default = ["std"]
31 | std = [
32 | "serde",
33 | "codec/std",
34 | "scale-info/std",
35 | "sp-io/std",
36 | "sp-std/std",
37 | "sp-core/std",
38 | "sp-runtime/std",
39 | "frame-support/std",
40 | "frame-system/std",
41 | "pallet-evm/std",
42 | "primitives/std",
43 | ]
44 | try-runtime = ["frame-support/try-runtime"]
45 |
46 | runtime-benchmarks = ['pallet-assets/runtime-benchmarks']
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_xcm_helper.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_xcm_helper`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_xcm_helper
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_xcm_helper.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_xcm_helper`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_xcm_helper::WeightInfo for WeightInfo {
32 | // Storage: XcmHelper XcmWeightFee (r:1 w:1)
33 | fn update_xcm_weight_fee() -> Weight {
34 | // Minimum execution time: 29_045 nanoseconds.
35 | Weight::from_ref_time(30_369_000)
36 | .saturating_add(T::DbWeight::get().reads(1))
37 | .saturating_add(T::DbWeight::get().writes(1))
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_xcm_helper.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_xcm_helper`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_xcm_helper
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_xcm_helper.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_xcm_helper`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_xcm_helper::WeightInfo for WeightInfo {
32 | // Storage: XcmHelper XcmWeightFee (r:1 w:1)
33 | fn update_xcm_weight_fee() -> Weight {
34 | // Minimum execution time: 30_135 nanoseconds.
35 | Weight::from_ref_time(30_699_000)
36 | .saturating_add(T::DbWeight::get().reads(1))
37 | .saturating_add(T::DbWeight::get().writes(1))
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/pallets/xcm-helper/src/tests.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | use crate::mock::*;
3 | use frame_support::{assert_noop, assert_ok};
4 |
5 | use sp_runtime::traits::{One, Zero};
6 |
7 | #[test]
8 | fn update_xcm_fees_should_work() {
9 | new_test_ext().execute_with(|| {
10 | // check error code
11 | assert_noop!(
12 | XcmHelpers::update_xcm_weight_fee(
13 | frame_system::RawOrigin::Root.into(), // origin
14 | XcmCall::Bond,
15 | XcmWeightFeeMisc {
16 | weight: Weight::from_ref_time(One::one()),
17 | fee: Zero::zero()
18 | }
19 | ),
20 | Error::::ZeroXcmFees
21 | );
22 |
23 | assert_noop!(
24 | XcmHelpers::update_xcm_weight_fee(
25 | frame_system::RawOrigin::Root.into(), // origin
26 | XcmCall::Bond,
27 | XcmWeightFeeMisc {
28 | weight: Zero::zero(),
29 | fee: One::one()
30 | }
31 | ),
32 | Error::::ZeroXcmWeightMisc
33 | );
34 |
35 | assert_ok!(XcmHelpers::update_xcm_weight_fee(
36 | frame_system::RawOrigin::Root.into(), // origin
37 | XcmCall::Bond,
38 | XcmWeightFeeMisc::default()
39 | ));
40 |
41 | assert_eq!(
42 | XcmWeightFee::::get(XcmCall::Bond),
43 | XcmWeightFeeMisc::default()
44 | );
45 | });
46 | }
47 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/report-a-bug.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Report a Bug
3 | about: Report a problem.
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 | ---
8 |
9 | **Description**
10 |
11 | _Tell us what happened. In particular, be specific about any changes you made to this template.
12 | Ideally, provide a link to your project's GitHub repository. Please note that we are not able to
13 | support all conceivable changes to this template project, but the more information you are able to
14 | provide the more equipped we will be to help._
15 |
16 | **Steps to Reproduce**
17 |
18 | _Replace the example steps below with actual steps to reproduce the bug you're reporting._
19 |
20 | 1. Go to '...'
21 | 2. Click on '....'
22 | 3. Scroll down to '....'
23 | 4. See error
24 |
25 | **Expected vs. Actual Behavior**
26 |
27 | _What did you expect to happen after you followed the steps you described in the last section? What
28 | actually happened?_
29 |
30 | **Environment**
31 |
32 | _Describe the environment in which you encountered this bug. Use the list below as a starting point
33 | and add additional information if you think it's relevant._
34 |
35 | - Operating system:
36 | - Template version/tag:
37 | - Rust version (run `rustup show`):
38 |
39 | **Logs, Errors or Screenshots**
40 |
41 | _Please provide the text of any logs or errors that you experienced; if
42 | applicable, provide screenshots to help illustrate the problem._
43 |
44 | **Additional Information**
45 |
46 | _Please add any other details that you think may help us solve your problem._
47 |
--------------------------------------------------------------------------------
/pallets/bridge/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-bridge'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec' }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | scale-info = { workspace = true, features = ['derive'] }
16 |
17 | pallet-assets = { workspace = true }
18 | pallet-balances = { workspace = true }
19 | pallet-membership = { workspace = true }
20 | primitives = { workspace = true }
21 | sp-runtime = { workspace = true }
22 | sp-std = { workspace = true }
23 |
24 | [dev-dependencies]
25 | pallet-currency-adapter = { workspace = true, features = ['std'] }
26 | sp-core = { workspace = true, features = ['std'] }
27 | sp-io = { workspace = true, features = ['std'] }
28 |
29 | [features]
30 | default = ['std']
31 | runtime-benchmarks = ['frame-benchmarking']
32 | std = [
33 | 'codec/std',
34 | 'scale-info/std',
35 | 'frame-support/std',
36 | 'frame-system/std',
37 | 'frame-benchmarking/std',
38 | 'primitives/std',
39 | 'pallet-assets/std',
40 | 'pallet-membership/std',
41 | 'pallet-balances/std',
42 | 'sp-runtime/std',
43 | 'sp-std/std',
44 | ]
45 | try-runtime = ['frame-support/try-runtime']
46 |
47 | [lib]
48 | doctest = false
49 |
--------------------------------------------------------------------------------
/scripts/benchmark.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 |
5 | cd $DIR/..
6 |
7 | set -xe
8 |
9 | steps=50
10 | repeat=20
11 | parallelOutput=./runtime/parallel/src/weights
12 | heikoOutput=./runtime/heiko/src/weights
13 | parallelChain=parallel-dev
14 | heikoChain=heiko-dev
15 |
16 | pallets=(
17 | # frame_system
18 | # pallet_assets
19 | # pallet_balances
20 | # pallet_timestamp
21 | # pallet_multisig
22 | # pallet_membership
23 | # pallet_collator_selection
24 | # pallet_proxy
25 | # pallet_utility
26 | # cumulus_pallet_xcmp_queue
27 | # pallet_identity
28 | # pallet_democracy
29 | # pallet_collective
30 | # pallet_preimage
31 | # pallet_scheduler
32 | # pallet_treasury
33 | pallet_amm
34 | pallet_asset_registry
35 | pallet_bridge
36 | pallet_crowdloans
37 | pallet_farming
38 | pallet_loans
39 | pallet_router
40 | pallet_xcm_helper
41 | pallet_streaming
42 | pallet_liquid_staking
43 | )
44 |
45 | for p in ${pallets[@]}
46 | do
47 | ./target/release/parallel benchmark \
48 | pallet \
49 | --chain=$parallelChain \
50 | --execution=wasm \
51 | --wasm-execution=compiled \
52 | --pallet=$p \
53 | --extrinsic='*' \
54 | --steps=$steps \
55 | --repeat=$repeat \
56 | --output=$parallelOutput/$p.rs
57 |
58 | ./target/release/parallel benchmark \
59 | pallet \
60 | --chain=$heikoChain \
61 | --execution=wasm \
62 | --wasm-execution=compiled \
63 | --pallet=$p \
64 | --extrinsic='*' \
65 | --steps=$steps \
66 | --repeat=$repeat \
67 | --output=$heikoOutput/$p.rs
68 | done
69 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_timestamp.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_timestamp`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_timestamp
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_timestamp.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_timestamp`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_timestamp::WeightInfo for WeightInfo {
32 | // Storage: Timestamp Now (r:1 w:1)
33 | fn set() -> Weight {
34 | // Minimum execution time: 13_360 nanoseconds.
35 | Weight::from_ref_time(13_729_000)
36 | .saturating_add(T::DbWeight::get().reads(1))
37 | .saturating_add(T::DbWeight::get().writes(1))
38 | }
39 | fn on_finalize() -> Weight {
40 | // Minimum execution time: 7_093 nanoseconds.
41 | Weight::from_ref_time(7_334_000)
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/pallets/traits/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-traits'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | serde = { workspace = true, features = ['derive'], optional = true }
12 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len'] }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | log = { workspace = true }
16 | num-bigint = { workspace = true }
17 | num-traits = { workspace = true }
18 | primitives = { workspace = true }
19 | scale-info = { workspace = true, features = ['derive'] }
20 | sp-core = { workspace = true }
21 | sp-io = { workspace = true }
22 | sp-runtime = { workspace = true }
23 | sp-std = { workspace = true }
24 | xcm = { workspace = true }
25 | xcm-builder = { workspace = true }
26 | xcm-executor = { workspace = true }
27 |
28 | [dev-dependencies]
29 | sp-core = { workspace = true, features = ['std'] }
30 |
31 | [features]
32 | default = ['std']
33 | std = [
34 | 'serde',
35 | 'codec/std',
36 | 'frame-support/std',
37 | 'frame-system/std',
38 | 'sp-runtime/std',
39 | 'scale-info/std',
40 | 'sp-std/std',
41 | 'primitives/std',
42 | 'num-bigint/std',
43 | 'num-traits/std',
44 | 'sp-core/std',
45 | 'xcm-executor/std',
46 | 'xcm/std',
47 | 'xcm-builder/std',
48 | ]
49 |
50 | try-runtime = ['frame-support/try-runtime']
51 |
52 | [lib]
53 | doctest = false
54 |
--------------------------------------------------------------------------------
/precompiles/balances-erc20/Permit.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.8.0;
2 |
3 | /// @title Extension of the ERC20 interface that allows users to
4 | /// sign permit messages to interact with contracts without needing to
5 | /// make a first approve transaction.
6 | interface Permit {
7 | /// @dev Consumes an approval permit.
8 | /// Anyone can call this function for a permit.
9 | /// @custom:selector d505accf
10 | /// @param owner Owner of the tokens issuing the permit
11 | /// @param spender Address whose allowance will be increased.
12 | /// @param value Allowed value.
13 | /// @param deadline Timestamp after which the permit will no longer be valid.
14 | /// @param v V component of the signature.
15 | /// @param r R component of the signature.
16 | /// @param s S component of the signature.
17 | function permit(
18 | address owner,
19 | address spender,
20 | uint256 value,
21 | uint256 deadline,
22 | uint8 v,
23 | bytes32 r,
24 | bytes32 s
25 | ) external;
26 |
27 | /// @dev Returns the current nonce for given owner.
28 | /// A permit must have this nonce to be consumed, which will
29 | /// increase the nonce by one.
30 | /// @custom:selector 7ecebe00
31 | function nonces(address owner) external view returns (uint256);
32 |
33 | /// @dev Returns the EIP712 domain separator. It is used to avoid replay
34 | /// attacks across assets or other similar EIP712 message structures.
35 | /// @custom:selector 3644e515
36 | function DOMAIN_SEPARATOR() external view returns (bytes32);
37 | }
38 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_timestamp.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_timestamp`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_timestamp
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_timestamp.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_timestamp`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_timestamp::WeightInfo for WeightInfo {
32 | // Storage: Timestamp Now (r:1 w:1)
33 | fn set() -> Weight {
34 | // Minimum execution time: 12_990 nanoseconds.
35 | Weight::from_ref_time(13_596_000)
36 | .saturating_add(T::DbWeight::get().reads(1))
37 | .saturating_add(T::DbWeight::get().writes(1))
38 | }
39 | fn on_finalize() -> Weight {
40 | // Minimum execution time: 7_204 nanoseconds.
41 | Weight::from_ref_time(7_489_000)
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/pallets/stableswap/src/types.rs:
--------------------------------------------------------------------------------
1 | use codec::{Decode, Encode, MaxEncodedLen};
2 | use frame_support::traits::tokens::Balance as BalanceT;
3 | use scale_info::TypeInfo;
4 | use sp_runtime::{traits::Zero, RuntimeDebug};
5 |
6 | #[derive(
7 | Encode,
8 | Decode,
9 | Eq,
10 | PartialEq,
11 | Copy,
12 | Clone,
13 | RuntimeDebug,
14 | PartialOrd,
15 | Ord,
16 | TypeInfo,
17 | MaxEncodedLen,
18 | )]
19 | #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
20 | pub struct Pool {
21 | pub base_amount: Balance,
22 | pub quote_amount: Balance,
23 | pub base_amount_last: Balance,
24 | pub quote_amount_last: Balance,
25 | pub lp_token_id: CurrencyId,
26 | pub block_timestamp_last: BlockNumber,
27 | pub price_0_cumulative_last: Balance,
28 | pub price_1_cumulative_last: Balance,
29 | }
30 |
31 | impl Pool {
32 | pub fn new(lp_token_id: CurrencyId) -> Self {
33 | Self {
34 | base_amount: Zero::zero(),
35 | quote_amount: Zero::zero(),
36 | base_amount_last: Zero::zero(),
37 | quote_amount_last: Zero::zero(),
38 | lp_token_id,
39 | block_timestamp_last: Zero::zero(),
40 | price_0_cumulative_last: Zero::zero(),
41 | price_1_cumulative_last: Zero::zero(),
42 | }
43 | }
44 |
45 | pub fn is_empty(&self) -> bool {
46 | self.base_amount.is_zero() && self.quote_amount.is_zero()
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/pallets/router/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-router'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | frame-benchmarking = { workspace = true, optional = true }
12 | frame-support = { workspace = true }
13 | frame-system = { workspace = true }
14 | pallet-amm = { workspace = true }
15 | pallet-assets = { workspace = true }
16 | pallet-traits = { workspace = true }
17 | codec = { workspace = true, package = 'parity-scale-codec', features = ['derive'] }
18 | primitives = { workspace = true }
19 | scale-info = { workspace = true, features = ['derive'] }
20 | sp-runtime = { workspace = true }
21 | sp-std = { workspace = true }
22 |
23 | [dev-dependencies]
24 | pallet-balances = { workspace = true, features = ['std'] }
25 | pallet-currency-adapter = { workspace = true, features = ['std'] }
26 | sp-core = { workspace = true, features = ['std'] }
27 | sp-io = { workspace = true, features = ['std'] }
28 |
29 | [features]
30 | default = ['std']
31 | runtime-benchmarks = ['frame-benchmarking', 'frame-system/runtime-benchmarks']
32 | std = [
33 | 'frame-support/std',
34 | 'frame-system/std',
35 | 'pallet-amm/std',
36 | 'pallet-assets/std',
37 | 'codec/std',
38 | 'primitives/std',
39 | 'sp-std/std',
40 | 'sp-runtime/std',
41 | 'scale-info/std',
42 | 'pallet-traits/std',
43 | ]
44 | try-runtime = ['frame-support/try-runtime']
45 |
46 | [lib]
47 | doctest = false
48 |
--------------------------------------------------------------------------------
/support/src/math_helper/f64.rs:
--------------------------------------------------------------------------------
1 | use sp_runtime::{FixedPointNumber, FixedU128};
2 | use substrate_fixed::{
3 | traits::LossyInto,
4 | transcendental::pow as fpow,
5 | types::{I32F32, I64F64},
6 | };
7 |
8 | pub fn fixed_u128_to_float(rate: FixedU128) -> f64 {
9 | rate.into_inner() as f64 / (FixedU128::DIV as f64)
10 | }
11 |
12 | pub fn fixed_u128_from_float(rate: f64) -> FixedU128 {
13 | FixedU128::from_inner((rate * (FixedU128::DIV as f64)) as u128)
14 | }
15 |
16 | pub fn power_float(rate: f64, exp: f64) -> Result {
17 | let result: I64F64 = fpow(I32F32::from_num(rate), I32F32::from_num(exp))
18 | .expect("Arithmetic power float overflow");
19 | Ok(result.lossy_into())
20 | }
21 |
22 | #[cfg(test)]
23 | mod tests {
24 | use super::*;
25 |
26 | #[test]
27 | fn test_power_float_should_work() {
28 | let total_term_by_year = FixedU128::from_inner(1_753_333_333_000_000_000);
29 | let term_rate = FixedU128::from_inner(FixedU128::DIV / 100 * 12);
30 | let start_exchange_rate = FixedU128::from_inner(FixedU128::DIV / 100 * 45);
31 | let remaining_year =
32 | fixed_u128_to_float(total_term_by_year) * (1_f64 - fixed_u128_to_float(term_rate));
33 | let current_rate = power_float(
34 | 1_f64 + fixed_u128_to_float(start_exchange_rate),
35 | remaining_year,
36 | )
37 | .ok()
38 | .unwrap();
39 | let current_rate = fixed_u128_from_float(current_rate as f64)
40 | .reciprocal()
41 | .unwrap();
42 | assert_eq!(current_rate, FixedU128::from_inner(563663518378716343));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/pallets/evm-signatures/src/weights.rs:
--------------------------------------------------------------------------------
1 | // This file is part of Substrate.
2 |
3 | // Copyright (C) 2021 Parity Technologies (UK) Ltd.
4 | // SPDX-License-Identifier: Apache-2.0
5 |
6 | // Licensed under the Apache License, Version 2.0 (the "License");
7 | // you may not use this file except in compliance with the License.
8 | // You may obtain a copy of the License at
9 | //
10 | // http://www.apache.org/licenses/LICENSE-2.0
11 | //
12 | // Unless required by applicable law or agreed to in writing, software
13 | // distributed under the License is distributed on an "AS IS" BASIS,
14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | // See the License for the specific language governing permissions and
16 | // limitations under the License.
17 | #![allow(unused_parens)]
18 | #![allow(unused_imports)]
19 | #![allow(clippy::all)]
20 |
21 | use frame_support::weights::Weight;
22 | use sp_runtime::traits::Get;
23 | use sp_std::marker::PhantomData;
24 |
25 | /// Weight functions needed for pallet_prices.
26 | pub trait WeightInfo {
27 | fn withdraw() -> Weight;
28 | }
29 |
30 | /// use max weight of Assets and Balance,better to rebenchmark later
31 | pub struct SubstrateWeight(PhantomData);
32 | impl WeightInfo for SubstrateWeight {
33 | fn withdraw() -> Weight {
34 | Weight::from_ref_time(92_361_000 as u64)
35 | .saturating_add(T::DbWeight::get().reads(4 as u64))
36 | .saturating_add(T::DbWeight::get().writes(4 as u64))
37 | }
38 | }
39 |
40 | impl WeightInfo for () {
41 | fn withdraw() -> Weight {
42 | Weight::from_ref_time(10_000 as u64)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/pallets/prices/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-prices'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | codec = { workspace = true, package = 'parity-scale-codec' }
9 | frame-support = { workspace = true }
10 | frame-system = { workspace = true }
11 | sp-core = { workspace = true }
12 | pallet-amm = { workspace = true }
13 | pallet-assets = { workspace = true }
14 | orml-oracle = { workspace = true }
15 | orml-traits = { workspace = true }
16 | pallet-traits = { workspace = true }
17 | primitives = { workspace = true }
18 | scale-info = { workspace = true, features = ['derive'] }
19 | serde = { workspace = true, optional = true }
20 | num-traits = { workspace = true }
21 | sp-runtime = { workspace = true }
22 | sp-std = { workspace = true }
23 |
24 | [dev-dependencies]
25 | sp-io = { workspace = true, features = ['std'] }
26 | pallet-balances = { workspace = true, features = ['std'] }
27 | pallet-currency-adapter = { workspace = true, features = ['std'] }
28 |
29 | [features]
30 | default = ['std']
31 | std = [
32 | 'serde',
33 | 'codec/std',
34 | 'sp-runtime/std',
35 | 'frame-support/std',
36 | 'frame-system/std',
37 | 'sp-std/std',
38 | 'sp-core/std',
39 | 'orml-traits/std',
40 | 'orml-oracle/std',
41 | 'primitives/std',
42 | 'scale-info/std',
43 | 'num-traits/std',
44 | 'pallet-traits/std',
45 | 'pallet-amm/std',
46 | 'pallet-assets/std',
47 | ]
48 | try-runtime = ['frame-support/try-runtime']
49 |
50 | runtime-benchmarks = ['pallet-assets/runtime-benchmarks']
51 |
52 | [lib]
53 | doctest = false
54 |
--------------------------------------------------------------------------------
/docker-compose.override.yml:
--------------------------------------------------------------------------------
1 | version: "3.7"
2 | services:
3 | heiko-dapp:
4 | ports:
5 | - "8080:80"
6 | image: parallelfinance/heiko-dapp:latest
7 | restart: always
8 | parallel-dapp:
9 | ports:
10 | - "8081:80"
11 | image: parallelfinance/parallel-dapp:latest
12 | restart: always
13 | oracle-client:
14 | image: parallelfinance/oracle-client:latest
15 | command: start -m 12000 -w ws://parachain-${PARA_ID}-0:9944
16 | restart: always
17 | stake-client-claim:
18 | image: parallelfinance/stake-client:latest
19 | command: claim --para-ws=ws://parachain-${PARA_ID}-0:9944 --batch-size 50
20 | restart: always
21 | stake-client-sync-era:
22 | image: parallelfinance/stake-client:latest
23 | command: sync era --relay-ws=ws://relaychain-alice:9944 --para-ws=ws://parachain-${PARA_ID}-0:9944
24 | restart: always
25 | stake-client-sync-ledger-0:
26 | image: parallelfinance/stake-client:latest
27 | command: sync ledger --relay-ws=ws://relaychain-alice:9944 --para-ws=ws://parachain-${PARA_ID}-0:9944 --derivative-index 0
28 | restart: always
29 | stake-client-sync-ledger-1:
30 | image: parallelfinance/stake-client:latest
31 | command: sync ledger --relay-ws=ws://relaychain-bob:9944 --para-ws=ws://parachain-${PARA_ID}-0:9944 --derivative-index 1
32 | restart: always
33 | stake-client-fast-match-unstake:
34 | image: parallelfinance/stake-client:latest
35 | command: fast-match-unstake --para-ws=ws://parachain-${PARA_ID}-0:9944 --batch-size 30
36 | restart: always
37 | liquidation-client:
38 | image: parallelfinance/liquidation-client:latest
39 | command: --endpoint ws://parachain-${PARA_ID}-0:9944
40 | restart: always
41 |
--------------------------------------------------------------------------------
/precompiles/utils/macro/tests/tests.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | use sha3::{Digest, Keccak256};
16 |
17 | #[precompile_utils_macro::generate_function_selector]
18 | pub enum Action {
19 | Toto = "toto()",
20 | Tata = "tata()",
21 | }
22 |
23 | #[test]
24 | fn test_keccak256() {
25 | assert_eq!(
26 | &precompile_utils_macro::keccak256!(""),
27 | Keccak256::digest(b"").as_slice(),
28 | );
29 | assert_eq!(
30 | &precompile_utils_macro::keccak256!("toto()"),
31 | Keccak256::digest(b"toto()").as_slice(),
32 | );
33 | assert_ne!(
34 | &precompile_utils_macro::keccak256!("toto()"),
35 | Keccak256::digest(b"tata()").as_slice(),
36 | );
37 | }
38 |
39 | #[test]
40 | fn test_generate_function_selector() {
41 | assert_eq!(
42 | &(Action::Toto as u32).to_be_bytes()[..],
43 | &Keccak256::digest(b"toto()")[0..4],
44 | );
45 | assert_eq!(
46 | &(Action::Tata as u32).to_be_bytes()[..],
47 | &Keccak256::digest(b"tata()")[0..4],
48 | );
49 | assert_ne!(Action::Toto as u32, Action::Tata as u32);
50 | }
51 |
--------------------------------------------------------------------------------
/precompiles/balances-erc20/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-evm-precompile-balances-erc20"
3 | authors = { workspace = true }
4 | description = "A Precompile to expose a Balances pallet through an ERC20-compliant interface."
5 | edition = "2021"
6 | version = { workspace = true }
7 |
8 | [dependencies]
9 | log = { workspace = true }
10 | num_enum = { workspace = true }
11 | paste = { workspace = true }
12 | slices = { workspace = true }
13 |
14 | # Moonbeam
15 | precompile-utils = { workspace = true }
16 |
17 | # Substrate
18 | codec = { workspace = true, package = 'parity-scale-codec', features = [ "max-encoded-len" ] }
19 | frame-support = { workspace = true }
20 | frame-system = { workspace = true }
21 | pallet-balances = { workspace = true }
22 | pallet-timestamp = { workspace = true }
23 | sp-core = { workspace = true }
24 | sp-io = { workspace = true }
25 | sp-std = { workspace = true }
26 |
27 | # Frontier
28 | fp-evm = { workspace = true }
29 | pallet-evm = { workspace = true, features = ['forbid-evm-reentrancy'] }
30 |
31 | [dev-dependencies]
32 | derive_more = { workspace = true }
33 | hex-literal = { workspace = true }
34 | libsecp256k1 = { workspace = true }
35 | serde = { workspace = true }
36 | sha3 = { workspace = true }
37 |
38 | # Moonbeam
39 | precompile-utils = { workspace = true, features = [ "testing" ] }
40 |
41 | pallet-timestamp = { workspace = true }
42 | scale-info = { workspace = true, features = [ "derive" ] }
43 | sp-runtime = { workspace = true }
44 |
45 | [features]
46 | default = [ "std" ]
47 | std = [
48 | "codec/std",
49 | "fp-evm/std",
50 | "frame-support/std",
51 | "frame-system/std",
52 | "pallet-balances/std",
53 | "pallet-evm/std",
54 | "precompile-utils/std",
55 | "sp-core/std",
56 | "sp-io/std",
57 | "sp-std/std",
58 | ]
59 |
--------------------------------------------------------------------------------
/pallets/farming/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-farming'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len'] }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | num-traits = { workspace = true }
16 | pallet-assets = { workspace = true }
17 | pallet-traits = { workspace = true }
18 | primitives = { workspace = true }
19 | scale-info = { workspace = true, features = ['derive'] }
20 | serde = { workspace = true, features = ['derive'], optional = true }
21 | sp-io = { workspace = true }
22 | sp-runtime = { workspace = true }
23 | sp-std = { workspace = true }
24 |
25 | [dev-dependencies]
26 | pallet-balances = { workspace = true, features = ['std'] }
27 | pallet-currency-adapter = { workspace = true, features = ['std'] }
28 | sp-core = { workspace = true, features = ['std'] }
29 |
30 | [features]
31 | default = ['std']
32 | runtime-benchmarks = ['frame-benchmarking', 'frame-system/runtime-benchmarks']
33 | std = [
34 | 'serde',
35 | 'codec/std',
36 | 'frame-benchmarking/std',
37 | 'frame-support/std',
38 | 'frame-system/std',
39 | 'primitives/std',
40 | 'sp-runtime/std',
41 | 'pallet-assets/std',
42 | 'scale-info/std',
43 | 'sp-std/std',
44 | 'num-traits/std',
45 | 'pallet-traits/std',
46 | ]
47 | try-runtime = ['frame-support/try-runtime']
48 |
49 | [lib]
50 | doctest = false
51 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/cumulus_pallet_xcmp_queue.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `cumulus_pallet_xcmp_queue`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=cumulus_pallet_xcmp_queue
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/cumulus_pallet_xcmp_queue.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `cumulus_pallet_xcmp_queue`.
30 | pub struct WeightInfo(PhantomData);
31 | impl cumulus_pallet_xcmp_queue::WeightInfo for WeightInfo {
32 | // Storage: XcmpQueue QueueConfig (r:1 w:1)
33 | fn set_config_with_u32() -> Weight {
34 | // Minimum execution time: 11_820 nanoseconds.
35 | Weight::from_ref_time(12_248_000)
36 | .saturating_add(T::DbWeight::get().reads(1))
37 | .saturating_add(T::DbWeight::get().writes(1))
38 | }
39 | // Storage: XcmpQueue QueueConfig (r:1 w:1)
40 | fn set_config_with_weight() -> Weight {
41 | // Minimum execution time: 12_102 nanoseconds.
42 | Weight::from_ref_time(12_272_000)
43 | .saturating_add(T::DbWeight::get().reads(1))
44 | .saturating_add(T::DbWeight::get().writes(1))
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/cumulus_pallet_xcmp_queue.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `cumulus_pallet_xcmp_queue`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=cumulus_pallet_xcmp_queue
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/cumulus_pallet_xcmp_queue.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `cumulus_pallet_xcmp_queue`.
30 | pub struct WeightInfo(PhantomData);
31 | impl cumulus_pallet_xcmp_queue::WeightInfo for WeightInfo {
32 | // Storage: XcmpQueue QueueConfig (r:1 w:1)
33 | fn set_config_with_u32() -> Weight {
34 | // Minimum execution time: 11_698 nanoseconds.
35 | Weight::from_ref_time(12_115_000)
36 | .saturating_add(T::DbWeight::get().reads(1))
37 | .saturating_add(T::DbWeight::get().writes(1))
38 | }
39 | // Storage: XcmpQueue QueueConfig (r:1 w:1)
40 | fn set_config_with_weight() -> Weight {
41 | // Minimum execution time: 11_549 nanoseconds.
42 | Weight::from_ref_time(12_060_000)
43 | .saturating_add(T::DbWeight::get().reads(1))
44 | .saturating_add(T::DbWeight::get().writes(1))
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/precompiles/assets-erc20/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = 'pallet-evm-precompile-assets-erc20'
3 | authors = { workspace = true }
4 | edition = '2021'
5 | version = { workspace = true }
6 |
7 | [dependencies]
8 | log = { workspace = true }
9 | num_enum = { workspace = true }
10 | paste = { workspace = true }
11 | slices = { workspace = true }
12 |
13 | precompile-utils = { workspace = true }
14 |
15 | # Substrate
16 | codec = { workspace = true, package = 'parity-scale-codec', features = ["max-encoded-len"] }
17 | frame-support = { workspace = true }
18 | frame-system = { workspace = true }
19 | pallet-assets = { workspace = true }
20 | pallet-balances = { workspace = true }
21 | pallet-timestamp = { workspace = true }
22 | scale-info = { workspace = true, features = [ "derive" ] }
23 | sp-core = { workspace = true }
24 | sp-io = { workspace = true }
25 | sp-runtime = { workspace = true }
26 | sp-std = { workspace = true }
27 |
28 | # Frontier
29 | fp-evm = { workspace = true }
30 | pallet-evm = { workspace = true, features = ['forbid-evm-reentrancy'] }
31 |
32 | [dev-dependencies]
33 | derive_more = { workspace = true }
34 | serde = { workspace = true }
35 | sha3 = { workspace = true }
36 |
37 | precompile-utils = { workspace = true, features = ["testing"] }
38 |
39 | codec = { workspace = true, features = ["max-encoded-len", "std"] }
40 | scale-info = { workspace = true, features = ["derive"] }
41 | sp-runtime = { workspace = true }
42 |
43 | [features]
44 | default = ["std"]
45 | std = [
46 | "codec/std",
47 | "fp-evm/std",
48 | "frame-support/std",
49 | "frame-system/std",
50 | "pallet-assets/std",
51 | "pallet-evm/std",
52 | "pallet-balances/std",
53 | "pallet-timestamp/std",
54 | "precompile-utils/std",
55 | "sp-core/std",
56 | "sp-io/std",
57 | "sp-runtime/std",
58 | "sp-std/std",
59 | ]
60 | runtime-benchmarks = ['pallet-assets/runtime-benchmarks']
--------------------------------------------------------------------------------
/runtime/common/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![cfg_attr(not(feature = "std"), no_std)]
2 |
3 | pub mod constants;
4 | pub mod evm_migration;
5 | pub mod precompiles;
6 |
7 | pub use fp_rpc;
8 | pub use fp_self_contained;
9 | pub use pallet_evm_precompile_assets_erc20::AddressToAssetId;
10 | pub use pallet_evm_precompile_balances_erc20::Erc20Metadata;
11 |
12 | use frame_support::log;
13 | use sp_std::{marker::PhantomData, result::Result};
14 | use xcm::latest::{
15 | Instruction::{self, *},
16 | MultiLocation, Weight,
17 | };
18 | use xcm_executor::traits::{OnResponse, ShouldExecute};
19 |
20 | /// TODO: Belowing code can be removed once upgrade to polkadot-v1.0.0
21 | /// Copy from polkadot-v0.9.38
22 | /// Polakdot-v1.0.0 have made changes of ShouldExecute
23 | pub struct AllowKnownQueryResponses(PhantomData);
24 | impl ShouldExecute for AllowKnownQueryResponses {
25 | fn should_execute(
26 | origin: &MultiLocation,
27 | instructions: &mut [Instruction],
28 | _max_weight: Weight,
29 | _weight_credit: &mut Weight,
30 | ) -> Result<(), ()> {
31 | log::trace!(
32 | target: "xcm::barriers",
33 | "Parallel AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
34 | origin, instructions, _max_weight, _weight_credit,
35 | );
36 | // ignore other instructions
37 | // ensure!(instructions.len() == 1, ());
38 | match instructions.first() {
39 | Some(QueryResponse {
40 | query_id, querier, ..
41 | }) if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) => {
42 | Ok(())
43 | }
44 | _ => Err(()),
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/pallets/amm/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-amm'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len'] }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | num-traits = { workspace = true }
16 | pallet-assets = { workspace = true }
17 | pallet-traits = { workspace = true }
18 | primitives = { workspace = true }
19 | scale-info = { workspace = true, features = ['derive'] }
20 | serde = { workspace = true, features = ['derive'], optional = true }
21 | sp-arithmetic = { workspace = true }
22 | sp-runtime = { workspace = true }
23 | sp-std = { workspace = true }
24 |
25 | [dev-dependencies]
26 | pallet-balances = { workspace = true, features = ['std'] }
27 | pallet-currency-adapter = { workspace = true, features = ['std'] }
28 | sp-core = { workspace = true, features = ['std'] }
29 | sp-io = { workspace = true, features = ['std'] }
30 |
31 | [features]
32 | default = ['std']
33 | runtime-benchmarks = ['frame-benchmarking', 'frame-system/runtime-benchmarks']
34 | std = [
35 | 'serde',
36 | 'codec/std',
37 | 'frame-benchmarking/std',
38 | 'frame-support/std',
39 | 'frame-system/std',
40 | 'primitives/std',
41 | 'sp-arithmetic/std',
42 | 'sp-runtime/std',
43 | 'sp-std/std',
44 | 'pallet-assets/std',
45 | 'scale-info/std',
46 | 'num-traits/std',
47 | 'pallet-traits/std',
48 | ]
49 | try-runtime = ['frame-support/try-runtime']
50 |
51 | [lib]
52 | doctest = false
53 |
--------------------------------------------------------------------------------
/pallets/stableswap/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-stableswap'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len'] }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | num-traits = { workspace = true }
16 | pallet-assets = { workspace = true }
17 | pallet-traits = { workspace = true }
18 | primitives = { workspace = true }
19 | scale-info = { workspace = true, features = ['derive'] }
20 | serde = { workspace = true, features = ['derive'], optional = true }
21 | sp-arithmetic = { workspace = true }
22 | sp-runtime = { workspace = true }
23 | sp-std = { workspace = true }
24 |
25 | [dev-dependencies]
26 | pallet-balances = { workspace = true, features = ['std'] }
27 | pallet-currency-adapter = { workspace = true, features = ['std'] }
28 | sp-core = { workspace = true, features = ['std'] }
29 | sp-io = { workspace = true, features = ['std'] }
30 |
31 | [features]
32 | default = ['std']
33 | runtime-benchmarks = ['frame-benchmarking', 'frame-system/runtime-benchmarks']
34 | std = [
35 | 'serde',
36 | 'codec/std',
37 | 'frame-benchmarking/std',
38 | 'frame-support/std',
39 | 'frame-system/std',
40 | 'primitives/std',
41 | 'sp-arithmetic/std',
42 | 'sp-runtime/std',
43 | 'sp-std/std',
44 | 'pallet-assets/std',
45 | 'scale-info/std',
46 | 'num-traits/std',
47 | 'pallet-traits/std',
48 | ]
49 | try-runtime = ['frame-support/try-runtime']
50 |
51 | [lib]
52 | doctest = false
53 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_router.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_router`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_router
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_router.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_router`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_router::WeightInfo for WeightInfo {
32 | // Storage: Assets Asset (r:2 w:2)
33 | // Storage: Assets Account (r:4 w:4)
34 | // Storage: AMM Pools (r:1 w:1)
35 | fn swap_exact_tokens_for_tokens() -> Weight {
36 | // Minimum execution time: 162_033 nanoseconds.
37 | Weight::from_ref_time(163_500_000)
38 | .saturating_add(T::DbWeight::get().reads(7))
39 | .saturating_add(T::DbWeight::get().writes(7))
40 | }
41 | // Storage: AMM Pools (r:1 w:1)
42 | // Storage: Assets Asset (r:2 w:2)
43 | // Storage: Assets Account (r:4 w:4)
44 | fn swap_tokens_for_exact_tokens() -> Weight {
45 | // Minimum execution time: 162_807 nanoseconds.
46 | Weight::from_ref_time(164_482_000)
47 | .saturating_add(T::DbWeight::get().reads(7))
48 | .saturating_add(T::DbWeight::get().writes(7))
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_router.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_router`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_router
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_router.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_router`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_router::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: Assets Asset (r:2 w:2)
33 | // Storage: Assets Account (r:4 w:4)
34 | // Storage: AMM Pools (r:1 w:1)
35 | fn swap_exact_tokens_for_tokens() -> Weight {
36 | Weight::from_ref_time(204_503_000 as u64)
37 | .saturating_add(T::DbWeight::get().reads(8 as u64))
38 | .saturating_add(T::DbWeight::get().writes(8 as u64))
39 | }
40 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
41 | // Storage: AMM Pools (r:1 w:1)
42 | // Storage: Assets Account (r:4 w:4)
43 | // Storage: Assets Asset (r:2 w:2)
44 | fn swap_tokens_for_exact_tokens() -> Weight {
45 | Weight::from_ref_time(202_029_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(8 as u64))
47 | .saturating_add(T::DbWeight::get().writes(8 as u64))
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_router.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_router`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vanilla-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=vanilla-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_router
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/vanilla/src/weights/pallet_router.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_router`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_router::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: Assets Asset (r:2 w:2)
33 | // Storage: Assets Account (r:4 w:4)
34 | // Storage: AMM Pools (r:1 w:1)
35 | fn swap_exact_tokens_for_tokens() -> Weight {
36 | Weight::from_ref_time(201_255_000 as u64)
37 | .saturating_add(T::DbWeight::get().reads(8 as u64))
38 | .saturating_add(T::DbWeight::get().writes(8 as u64))
39 | }
40 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
41 | // Storage: AMM Pools (r:1 w:1)
42 | // Storage: Assets Account (r:4 w:4)
43 | // Storage: Assets Asset (r:2 w:2)
44 | fn swap_tokens_for_exact_tokens() -> Weight {
45 | Weight::from_ref_time(196_427_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(8 as u64))
47 | .saturating_add(T::DbWeight::get().writes(8 as u64))
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_router.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_router`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_router
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_router.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_router`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_router::WeightInfo for WeightInfo {
32 | // Storage: Assets Asset (r:2 w:2)
33 | // Storage: Assets Account (r:4 w:4)
34 | // Storage: AMM Pools (r:1 w:1)
35 | fn swap_exact_tokens_for_tokens() -> Weight {
36 | // Minimum execution time: 159_385 nanoseconds.
37 | Weight::from_ref_time(161_069_000)
38 | .saturating_add(T::DbWeight::get().reads(7))
39 | .saturating_add(T::DbWeight::get().writes(7))
40 | }
41 | // Storage: AMM Pools (r:1 w:1)
42 | // Storage: Assets Asset (r:2 w:2)
43 | // Storage: Assets Account (r:4 w:4)
44 | fn swap_tokens_for_exact_tokens() -> Weight {
45 | // Minimum execution time: 159_751 nanoseconds.
46 | Weight::from_ref_time(161_736_000)
47 | .saturating_add(T::DbWeight::get().reads(7))
48 | .saturating_add(T::DbWeight::get().writes(7))
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/scripts/ci/extrinsic-ordering-filter.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # This script is used in a Github Workflow. It helps filtering out what is interesting
3 | # when comparing metadata and spot what would require a tx version bump.
4 |
5 | # shellcheck disable=SC2002,SC2086
6 |
7 | FILE=$1
8 |
9 | # Highlight indexes that were deleted
10 | function find_deletions() {
11 | echo "\n## Deletions\n"
12 | RES=$(cat "$FILE" | grep -n '\[\-\]' | tr -s " ")
13 | if [ "$RES" ]; then
14 | echo "$RES" | awk '{ printf "%s\\n", $0 }'
15 | else
16 | echo "n/a"
17 | fi
18 | }
19 |
20 | # Highlight indexes that have been deleted
21 | function find_index_changes() {
22 | echo "\n## Index changes\n"
23 | RES=$(cat "$FILE" | grep -E -n -i 'idx:\s*([0-9]+)\s*(->)\s*([0-9]+)' | tr -s " ")
24 | if [ "$RES" ]; then
25 | echo "$RES" | awk '{ printf "%s\\n", $0 }'
26 | else
27 | echo "n/a"
28 | fi
29 | }
30 |
31 | # Highlight values that decreased
32 | function find_decreases() {
33 | echo "\n## Decreases\n"
34 | OUT=$(cat "$FILE" | grep -E -i -o '([0-9]+)\s*(->)\s*([0-9]+)' | awk '$1 > $3 { printf "%s;", $0 }')
35 | IFS=$';' LIST=("$OUT")
36 | unset RES
37 | for line in "${LIST[@]}"; do
38 | RES="$RES\n$(cat "$FILE" | grep -E -i -n \"$line\" | tr -s " ")"
39 | done
40 |
41 | if [ "$RES" ]; then
42 | echo "$RES" | awk '{ printf "%s\\n", $0 }' | sort -u -g | uniq
43 | else
44 | echo "n/a"
45 | fi
46 | }
47 |
48 | echo "\n------------------------------ SUMMARY -------------------------------"
49 | echo "\n⚠️ This filter is here to help spotting changes that should be reviewed carefully."
50 | echo "\n⚠️ It catches only index changes, deletions and value decreases".
51 |
52 | find_deletions "$FILE"
53 | find_index_changes "$FILE"
54 | find_decreases "$FILE"
55 | echo "\n----------------------------------------------------------------------\n"
56 |
--------------------------------------------------------------------------------
/pallets/streaming/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-streaming'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec' }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | orml-traits = { workspace = true }
16 | pallet-assets = { workspace = true }
17 | pallet-balances = { workspace = true }
18 | pallet-timestamp = { workspace = true }
19 | primitives = { workspace = true }
20 | scale-info = { workspace = true, features = ['derive'] }
21 | serde = { workspace = true, features = ['derive'], optional = true }
22 | sp-runtime = { workspace = true }
23 | sp-std = { workspace = true }
24 | pallet-traits = { workspace = true }
25 |
26 | [dev-dependencies]
27 | orml-oracle = { workspace = true, features = ['std'] }
28 | pallet-currency-adapter = { workspace = true, features = ['std'] }
29 | sp-core = { workspace = true, features = ['std'] }
30 | sp-io = { workspace = true, features = ['std'] }
31 |
32 |
33 | [features]
34 | default = ['std']
35 | runtime-benchmarks = ['frame-benchmarking']
36 | std = [
37 | 'codec/std',
38 | 'frame-support/std',
39 | 'frame-system/std',
40 | 'frame-benchmarking/std',
41 | 'orml-traits/std',
42 | 'primitives/std',
43 | 'sp-runtime/std',
44 | 'sp-std/std',
45 | 'pallet-assets/std',
46 | 'pallet-balances/std',
47 | 'pallet-assets/std',
48 | 'pallet-timestamp/std',
49 | 'serde',
50 | 'scale-info/std',
51 | 'pallet-traits/std',
52 | ]
53 | try-runtime = ['frame-support/try-runtime']
54 |
55 | [lib]
56 | doctest = false
57 |
--------------------------------------------------------------------------------
/pallets/loans/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-loans'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec' }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | num-traits = { workspace = true }
16 | orml-traits = { workspace = true }
17 | pallet-assets = { workspace = true }
18 | pallet-balances = { workspace = true }
19 | pallet-prices = { workspace = true }
20 | pallet-timestamp = { workspace = true }
21 | pallet-traits = { workspace = true }
22 | primitives = { workspace = true }
23 | scale-info = { workspace = true, features = ['derive'] }
24 | serde = { workspace = true, features = ['derive'], optional = true }
25 | sp-io = { workspace = true }
26 | sp-runtime = { workspace = true }
27 | sp-std = { workspace = true }
28 |
29 | [dev-dependencies]
30 | orml-oracle = { workspace = true, features = ['std'] }
31 | pallet-amm = { workspace = true, features = ['std'] }
32 | pallet-currency-adapter = { workspace = true, features = ['std'] }
33 | sp-core = { workspace = true, features = ['std'] }
34 |
35 | [features]
36 | default = ['std']
37 | runtime-benchmarks = ['frame-benchmarking']
38 | std = [
39 | 'codec/std',
40 | 'frame-support/std',
41 | 'frame-system/std',
42 | 'frame-benchmarking/std',
43 | 'orml-traits/std',
44 | 'primitives/std',
45 | 'sp-runtime/std',
46 | 'sp-std/std',
47 | 'sp-io/std',
48 | 'pallet-assets/std',
49 | 'pallet-prices/std',
50 | 'pallet-balances/std',
51 | 'pallet-timestamp/std',
52 | 'serde',
53 | 'scale-info/std',
54 | 'num-traits/std',
55 | 'pallet-traits/std',
56 | ]
57 | try-runtime = ['frame-support/try-runtime']
58 |
59 | [lib]
60 | doctest = false
61 |
--------------------------------------------------------------------------------
/scripts/fullnode.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 |
5 | cd $DIR
6 |
7 | set -xe
8 |
9 | RELAY_WS_PORT=9945
10 | RELAY_RPC_PORT=9934
11 | RELAY_P2P_PORT=30334
12 |
13 | PARA_WS_PORT=9944
14 | PARA_RPC_PORT=9933
15 | PARA_P2P_PORT=30333
16 |
17 | PARA_CHAIN="${2:-heiko}"
18 | RELAY_CHAIN="${3:-kusama}"
19 | VOLUME="chains"
20 | NODE_NAME="$1"
21 | DOCKER_IMAGE="parallelfinance/parallel:v1.9.6"
22 | BASE_PATH="/data"
23 |
24 | if [ $# -lt 1 ]; then
25 | echo "help: ./fullnode.sh " && exit 1
26 | fi
27 |
28 | docker container stop $PARA_CHAIN-fullnode || true
29 | docker container rm $PARA_CHAIN-fullnode || true
30 |
31 | # docker volume rm $VOLUME || true
32 |
33 | docker volume create $VOLUME || true
34 |
35 | docker run --restart=always --name $PARA_CHAIN-fullnode \
36 | -d \
37 | -p $PARA_WS_PORT:$PARA_WS_PORT \
38 | -p $PARA_RPC_PORT:$PARA_RPC_PORT \
39 | -p $PARA_P2P_PORT:$PARA_P2P_PORT \
40 | -p $RELAY_WS_PORT:$RELAY_WS_PORT \
41 | -p $RELAY_RPC_PORT:$RELAY_RPC_PORT \
42 | -p $RELAY_P2P_PORT:$RELAY_P2P_PORT \
43 | -v "$VOLUME:$BASE_PATH" \
44 | $DOCKER_IMAGE \
45 | -d $BASE_PATH \
46 | --chain=$PARA_CHAIN \
47 | --ws-port=$PARA_WS_PORT \
48 | --rpc-port=$PARA_RPC_PORT \
49 | --ws-external \
50 | --rpc-external \
51 | --rpc-cors all \
52 | --ws-max-connections 4096 \
53 | --pruning archive \
54 | --wasm-execution=compiled \
55 | --execution=wasm \
56 | --state-cache-size 0 \
57 | --listen-addr=/ip4/0.0.0.0/tcp/$PARA_P2P_PORT \
58 | --name=$NODE_NAME \
59 | --prometheus-external \
60 | -- \
61 | --chain=$RELAY_CHAIN \
62 | --ws-port=$RELAY_WS_PORT \
63 | --rpc-port=$RELAY_RPC_PORT \
64 | --ws-external \
65 | --rpc-external \
66 | --rpc-cors all \
67 | --ws-max-connections 4096 \
68 | --wasm-execution=compiled \
69 | --execution=wasm \
70 | --database=RocksDb \
71 | --state-cache-size 0 \
72 | --unsafe-pruning \
73 | --pruning=1000 \
74 | --listen-addr=/ip4/0.0.0.0/tcp/$RELAY_P2P_PORT \
75 | --name="${NODE_NAME}_Embedded_Relay"
76 |
77 | # docker logs -f $PARA_CHAIN-fullnode
78 |
--------------------------------------------------------------------------------
/runtime/common/src/evm_migration.rs:
--------------------------------------------------------------------------------
1 | use frame_support::{log, traits::OnRuntimeUpgrade};
2 | use pallet_evm::Config;
3 | use sp_core::{Get, H160};
4 | use sp_std::vec::Vec;
5 |
6 | fn revert_bytecode() -> Vec {
7 | sp_std::vec![0x60, 0x00, 0x60, 0x00, 0xFD]
8 | }
9 |
10 | fn used_addresses() -> impl Iterator- {
11 | sp_std::vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 1024, 1025, 1026, 1027, 2050]
12 | .into_iter()
13 | .map(hash)
14 | }
15 | fn hash(a: u64) -> H160 {
16 | H160::from_low_u64_be(a)
17 | }
18 |
19 | pub struct InitEvmGenesis(sp_std::marker::PhantomData);
20 | impl OnRuntimeUpgrade for InitEvmGenesis {
21 | #[cfg(feature = "try-runtime")]
22 | fn pre_upgrade() -> Result, &'static str> {
23 | for addr in used_addresses() {
24 | frame_support::ensure!(
25 | !>::contains_key(addr),
26 | "Expected empty account code"
27 | );
28 | }
29 | log::info!(target: "runtime::pallet_evm", "pre_upgrade: ready for migrate");
30 |
31 | Ok(Default::default())
32 | }
33 |
34 | fn on_runtime_upgrade() -> frame_support::weights::Weight {
35 | if >::contains_key(hash(1)) {
36 | log::warn!(target: "runtime::pallet_evm", "already init evm genesis code");
37 | return T::DbWeight::get().reads(1);
38 | }
39 | for addr in used_addresses() {
40 | pallet_evm::Pallet::::create_account(addr, revert_bytecode());
41 | }
42 | log::info!(target: "runtime::pallet_evm", "init evm genesis code successfully");
43 | T::DbWeight::get().reads_writes(15, 15 * 2)
44 | }
45 |
46 | #[cfg(feature = "try-runtime")]
47 | fn post_upgrade(_state: Vec) -> Result<(), &'static str> {
48 | for addr in used_addresses() {
49 | frame_support::ensure!(
50 | >::get(addr) == revert_bytecode(),
51 | "Expected equal account code"
52 | );
53 | }
54 | log::info!(target: "runtime::pallet_evm", "post_upgrade: migrate successfully");
55 | Ok(())
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/ump/transact.ts:
--------------------------------------------------------------------------------
1 | import { createXcm, getApi, getCouncilThreshold, nextNonce, sovereignRelayOf } from '../../utils'
2 | import { Command, CreateCommandParameters, program } from '@caporal/core'
3 | import { Keyring } from '@polkadot/api'
4 | import { u32 } from '@polkadot/types'
5 |
6 | export default function ({ createCommand }: CreateCommandParameters): Command {
7 | return createCommand('open hrmp channel to specific chain')
8 | .option('-p, --para-ws [url]', 'the parachain API endpoint', {
9 | default: 'wss://parallel-rpc.dwellir.com'
10 | })
11 | .option('-e, --encoded-call-data [hex]', 'the hex encoded call data', {
12 | default: '0x0001081234'
13 | })
14 | .option('-d, --dry-run [boolean]', 'whether to execute using PARA_CHAIN_SUDO_KEY', {
15 | validator: program.BOOLEAN,
16 | default: true
17 | })
18 | .action(async actionParameters => {
19 | const {
20 | logger,
21 | options: { paraWs, dryRun, encodedCallData }
22 | } = actionParameters
23 | const api = await getApi(paraWs.toString())
24 | const paraId = (await api.query.parachainInfo.parachainId()) as unknown as u32
25 | const signer = new Keyring({ type: 'sr25519' }).addFromUri(
26 | `${process.env.PARA_CHAIN_SUDO_KEY || '//Dave'}`
27 | )
28 | const proposal = api.tx.ormlXcm.sendAsSovereign(
29 | {
30 | V1: {
31 | parents: 1,
32 | interior: 'Here'
33 | }
34 | },
35 | createXcm(
36 | `${encodedCallData.toString()}`,
37 | sovereignRelayOf(paraId.toNumber()),
38 | 'SovereignAccount'
39 | )
40 | )
41 | const tx = api.tx.generalCouncil.propose(
42 | await getCouncilThreshold(api),
43 | proposal,
44 | proposal.length
45 | )
46 |
47 | if (dryRun) {
48 | return logger.info(`hex-encoded call: ${tx.toHex()}`)
49 | }
50 |
51 | await tx
52 | .signAndSend(signer, { nonce: await nextNonce(api, signer) })
53 | .then(() => process.exit(0))
54 | .catch(err => {
55 | logger.error(err.message)
56 | process.exit(1)
57 | })
58 | })
59 | }
60 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_utility.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_utility`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_utility
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_utility.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_utility`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_utility::WeightInfo for WeightInfo {
32 | /// The range of component `c` is `[0, 1000]`.
33 | fn batch(c: u32, ) -> Weight {
34 | // Minimum execution time: 21_450 nanoseconds.
35 | Weight::from_ref_time(32_416_541)
36 | // Standard Error: 2_617
37 | .saturating_add(Weight::from_ref_time(8_462_329).saturating_mul(c.into()))
38 | }
39 | fn as_derivative() -> Weight {
40 | // Minimum execution time: 12_403 nanoseconds.
41 | Weight::from_ref_time(12_588_000)
42 | }
43 | /// The range of component `c` is `[0, 1000]`.
44 | fn batch_all(c: u32, ) -> Weight {
45 | // Minimum execution time: 21_153 nanoseconds.
46 | Weight::from_ref_time(22_958_862)
47 | // Standard Error: 2_221
48 | .saturating_add(Weight::from_ref_time(8_909_848).saturating_mul(c.into()))
49 | }
50 | fn dispatch_as() -> Weight {
51 | // Minimum execution time: 25_340 nanoseconds.
52 | Weight::from_ref_time(25_735_000)
53 | }
54 | /// The range of component `c` is `[0, 1000]`.
55 | fn force_batch(c: u32, ) -> Weight {
56 | // Minimum execution time: 21_321 nanoseconds.
57 | Weight::from_ref_time(26_900_973)
58 | // Standard Error: 2_119
59 | .saturating_add(Weight::from_ref_time(8_469_583).saturating_mul(c.into()))
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_utility.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_utility`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_utility
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_utility.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_utility`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_utility::WeightInfo for WeightInfo {
32 | /// The range of component `c` is `[0, 1000]`.
33 | fn batch(c: u32, ) -> Weight {
34 | // Minimum execution time: 21_041 nanoseconds.
35 | Weight::from_ref_time(37_722_957)
36 | // Standard Error: 2_140
37 | .saturating_add(Weight::from_ref_time(7_780_596).saturating_mul(c.into()))
38 | }
39 | fn as_derivative() -> Weight {
40 | // Minimum execution time: 11_677 nanoseconds.
41 | Weight::from_ref_time(11_976_000)
42 | }
43 | /// The range of component `c` is `[0, 1000]`.
44 | fn batch_all(c: u32, ) -> Weight {
45 | // Minimum execution time: 21_157 nanoseconds.
46 | Weight::from_ref_time(31_688_389)
47 | // Standard Error: 2_072
48 | .saturating_add(Weight::from_ref_time(8_200_339).saturating_mul(c.into()))
49 | }
50 | fn dispatch_as() -> Weight {
51 | // Minimum execution time: 24_883 nanoseconds.
52 | Weight::from_ref_time(25_367_000)
53 | }
54 | /// The range of component `c` is `[0, 1000]`.
55 | fn force_batch(c: u32, ) -> Weight {
56 | // Minimum execution time: 21_128 nanoseconds.
57 | Weight::from_ref_time(32_997_782)
58 | // Standard Error: 2_313
59 | .saturating_add(Weight::from_ref_time(7_808_716).saturating_mul(c.into()))
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/scripts/collator.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 |
5 | cd $DIR
6 |
7 | set -xe
8 |
9 | RELAY_WS_PORT=9945
10 | RELAY_RPC_PORT=9934
11 | RELAY_P2P_PORT=30334
12 |
13 | PARA_WS_PORT=9944
14 | PARA_RPC_PORT=9933
15 | PARA_P2P_PORT=30333
16 |
17 | PARA_CHAIN="${4:-heiko}"
18 | RELAY_CHAIN="${5:-kusama}"
19 | VOLUME="chains"
20 | NODE_KEY="$1"
21 | KEYSTORE_PATH="$2"
22 | NODE_NAME="$3"
23 | DOCKER_IMAGE="parallelfinance/parallel:v2.1.1"
24 | BASE_PATH="/data"
25 |
26 | if [ $# -lt 3 ]; then
27 | echo "help: ./collator.sh " && exit 1
28 | fi
29 |
30 | docker container stop $PARA_CHAIN-collator || true
31 | docker container rm $PARA_CHAIN-collator || true
32 |
33 | # docker volume rm $VOLUME || true
34 |
35 | docker volume create $VOLUME || true
36 |
37 | docker run --restart=always --name $PARA_CHAIN-collator \
38 | -d \
39 | -p $PARA_WS_PORT:$PARA_WS_PORT \
40 | -p $PARA_RPC_PORT:$PARA_RPC_PORT \
41 | -p $PARA_P2P_PORT:$PARA_P2P_PORT \
42 | -p $RELAY_WS_PORT:$RELAY_WS_PORT \
43 | -p $RELAY_RPC_PORT:$RELAY_RPC_PORT \
44 | -p $RELAY_P2P_PORT:$RELAY_P2P_PORT \
45 | -v "$VOLUME:$BASE_PATH" \
46 | -v "$(realpath $KEYSTORE_PATH):/app/keystore" \
47 | $DOCKER_IMAGE \
48 | -d $BASE_PATH \
49 | --chain=$PARA_CHAIN \
50 | --collator \
51 | --ws-port=$PARA_WS_PORT \
52 | --rpc-port=$PARA_RPC_PORT \
53 | --keystore-path=/app/keystore \
54 | --node-key=$NODE_KEY \
55 | --pruning archive \
56 | --wasm-execution=compiled \
57 | --execution=wasm \
58 | --ws-external \
59 | --rpc-external \
60 | --rpc-cors all \
61 | --rpc-methods Unsafe \
62 | --state-cache-size 0 \
63 | --listen-addr=/ip4/0.0.0.0/tcp/$PARA_P2P_PORT \
64 | --name=$NODE_NAME \
65 | --log='xcm=trace,loans=trace,liquidStaking=trace,crowdloans=trace,amm=trace,stableswap=trace,router=trace,bridge=trace' \
66 | --prometheus-external \
67 | -- \
68 | --chain=$RELAY_CHAIN \
69 | --ws-port=$RELAY_WS_PORT \
70 | --rpc-port=$RELAY_RPC_PORT \
71 | --wasm-execution=compiled \
72 | --execution=wasm \
73 | --database=RocksDb \
74 | --state-cache-size 0 \
75 | --unsafe-pruning \
76 | --pruning=1000 \
77 | --listen-addr=/ip4/0.0.0.0/tcp/$RELAY_P2P_PORT \
78 | --log='xcm=trace' \
79 | --name="${NODE_NAME}_Embedded_Relay"
80 |
81 | # docker logs -f $PARA_CHAIN-collator
82 |
--------------------------------------------------------------------------------
/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "relaychain": {
3 | "bin": "../polkadot/target/release/polkadot",
4 | "chain": "polkadot-local",
5 | "nodes": [
6 | {
7 | "name": "alice",
8 | "wsPort": 9944,
9 | "rpcPort": 9933,
10 | "port": 30333,
11 | "flags": [
12 | "-l",
13 | "xcm=trace",
14 | "--state-cache-size",
15 | "0"
16 | ]
17 | },
18 | {
19 | "name": "bob",
20 | "wsPort": 9945,
21 | "rpcPort": 9934,
22 | "port": 30334,
23 | "flags": [
24 | "-l",
25 | "xcm=trace",
26 | "--state-cache-size",
27 | "0"
28 | ]
29 | },
30 | {
31 | "name": "charlie",
32 | "wsPort": 9946,
33 | "rpcPort": 9935,
34 | "port": 30335,
35 | "flags": [
36 | "-l",
37 | "xcm=trace",
38 | "--state-cache-size",
39 | "0"
40 | ]
41 | },
42 | {
43 | "name": "dave",
44 | "wsPort": 9947,
45 | "rpcPort": 9936,
46 | "port": 30336,
47 | "flags": [
48 | "-l",
49 | "xcm=trace",
50 | "--state-cache-size",
51 | "0"
52 | ]
53 | }
54 | ],
55 | "genesis": {
56 | "runtime": {
57 | "runtime_genesis_config": {
58 | "configuration": {
59 | "config": {
60 | "validation_upgrade_frequency": 10,
61 | "validation_upgrade_delay": 10
62 | }
63 | }
64 | }
65 | }
66 | }
67 | },
68 | "parachains": [
69 | {
70 | "bin": "./target/release/parallel",
71 | "chain": "kerria-dev",
72 | "nodes": [
73 | {
74 | "wsPort": 9948,
75 | "port": 30337,
76 | "rpcPort": 9937,
77 | "name": "alice",
78 | "flags": [
79 | "-l",
80 | "evm=trace,xcm=trace,loans=trace,liquidStaking=trace,crowdloans=trace,amm=trace,stableswap=trace,router=trace,bridge=trace",
81 | "--state-cache-size",
82 | "0",
83 | "--",
84 | "--execution=wasm",
85 | "--state-cache-size",
86 | "0"
87 | ]
88 | }
89 | ],
90 | "id": 2012
91 | }
92 | ],
93 | "simpleParachains": [],
94 | "hrmpChannels": [],
95 | "types": {},
96 | "finalization": false
97 | }
98 |
--------------------------------------------------------------------------------
/scripts/collator-dev.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 |
5 | cd $DIR
6 |
7 | set -xe
8 |
9 | RELAY_WS_PORT=9945
10 | RELAY_RPC_PORT=9934
11 | RELAY_P2P_PORT=30334
12 |
13 | PARA_WS_PORT=9944
14 | PARA_RPC_PORT=9933
15 | PARA_P2P_PORT=30333
16 |
17 | PARA_CHAIN="${3:-vanilla-dev.json}"
18 | RELAY_CHAIN="${4:-kusama-local.json}"
19 | VOLUME="chains"
20 | NODE_NAME="$1"
21 | COLLATOR_NAME="${2:-alice}"
22 | DOCKER_IMAGE="parallelfinance/parallel:v1.9.6"
23 | BASE_PATH="/data"
24 | RELAY_BOOTNODES="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWDEyCAUKviazJuXdWcAAVEf7nSm9BvPXyK6odp5PetCfV"
25 |
26 | if [ $# -lt 1 ]; then
27 | echo "help: ./collator-dev.sh " && exit 1
28 | fi
29 |
30 | docker container stop $NODE_NAME || true
31 | docker container rm $NODE_NAME || true
32 |
33 | # docker volume rm $VOLUME || true
34 |
35 | docker volume create $VOLUME || true
36 |
37 | docker run --restart=always --name $NODE_NAME \
38 | -d \
39 | -p $PARA_WS_PORT:$PARA_WS_PORT \
40 | -p $PARA_RPC_PORT:$PARA_RPC_PORT \
41 | -p $PARA_P2P_PORT:$PARA_P2P_PORT \
42 | -p $RELAY_WS_PORT:$RELAY_WS_PORT \
43 | -p $RELAY_RPC_PORT:$RELAY_RPC_PORT \
44 | -p $RELAY_P2P_PORT:$RELAY_P2P_PORT \
45 | -v "$VOLUME:$BASE_PATH" \
46 | -v "$(pwd):/app" \
47 | $DOCKER_IMAGE \
48 | -d $BASE_PATH \
49 | --chain=/app/$PARA_CHAIN \
50 | --collator \
51 | --$COLLATOR_NAME \
52 | --ws-port=$PARA_WS_PORT \
53 | --rpc-port=$PARA_RPC_PORT \
54 | --pruning archive \
55 | --wasm-execution=compiled \
56 | --force-authoring \
57 | --execution=wasm \
58 | --ws-external \
59 | --rpc-external \
60 | --rpc-cors all \
61 | --rpc-methods Unsafe \
62 | --state-cache-size 0 \
63 | --listen-addr=/ip4/0.0.0.0/tcp/$PARA_P2P_PORT \
64 | --name=$NODE_NAME \
65 | --log='xcm=trace,loans=trace,liquidStaking=trace,crowdloans=trace,amm=trace,stableswap=trace,router=trace,bridge=trace' \
66 | --prometheus-external \
67 | -- \
68 | --chain=/app/$RELAY_CHAIN \
69 | --ws-port=$RELAY_WS_PORT \
70 | --rpc-port=$RELAY_RPC_PORT \
71 | --wasm-execution=compiled \
72 | --execution=wasm \
73 | --database=RocksDb \
74 | --state-cache-size 0 \
75 | --unsafe-pruning \
76 | --pruning=1000 \
77 | --listen-addr=/ip4/0.0.0.0/tcp/$RELAY_P2P_PORT \
78 | --name="${NODE_NAME}_Embedded_Relay" \
79 | --log='xcm=trace' \
80 | --bootnodes $RELAY_BOOTNODES
81 |
82 | docker logs -f $NODE_NAME
83 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/hrmp/accept.ts:
--------------------------------------------------------------------------------
1 | import {
2 | createXcm,
3 | getApi,
4 | getCouncilThreshold,
5 | getRelayApi,
6 | nextNonce,
7 | sovereignRelayOf
8 | } from '../../utils'
9 | import { Command, CreateCommandParameters, program } from '@caporal/core'
10 | import { Keyring } from '@polkadot/api'
11 |
12 | export default function ({ createCommand }: CreateCommandParameters): Command {
13 | return createCommand('accept hrmp channel from specific chain')
14 | .argument('', 'paraId of source chain', {
15 | validator: program.NUMBER
16 | })
17 | .argument('', 'paraId of target chain', {
18 | validator: program.NUMBER
19 | })
20 | .option('-r, --relay-ws [url]', 'the relaychain API endpoint', {
21 | default: 'wss://rpc.polkadot.io'
22 | })
23 | .option('-p, --para-ws [url]', 'the parachain API endpoint', {
24 | default: 'wss://parallel-rpc.dwellir.com'
25 | })
26 | .option('-d, --dry-run [boolean]', 'whether to execute using PARA_CHAIN_SUDO_KEY', {
27 | validator: program.BOOLEAN,
28 | default: true
29 | })
30 | .action(async actionParameters => {
31 | const {
32 | logger,
33 | args: { source, target },
34 | options: { relayWs, paraWs, dryRun }
35 | } = actionParameters
36 | const relayApi = await getRelayApi(relayWs.toString())
37 | const encoded = relayApi.tx.hrmp.hrmpAcceptOpenChannel(source.valueOf() as number).toHex()
38 | const api = await getApi(paraWs.toString())
39 | const signer = new Keyring({ type: 'sr25519' }).addFromUri(
40 | `${process.env.PARA_CHAIN_SUDO_KEY || '//Dave'}`
41 | )
42 | const proposal = api.tx.ormlXcm.sendAsSovereign(
43 | {
44 | V1: {
45 | parents: 1,
46 | interior: 'Here'
47 | }
48 | },
49 | createXcm(`0x${encoded.slice(6)}`, sovereignRelayOf(target.valueOf() as number))
50 | )
51 | const tx = api.tx.generalCouncil.propose(
52 | await getCouncilThreshold(api),
53 | proposal,
54 | proposal.length
55 | )
56 |
57 | if (dryRun) {
58 | return logger.info(`hex-encoded call: ${tx.toHex()}`)
59 | }
60 |
61 | await tx
62 | .signAndSend(signer, { nonce: await nextNonce(api, signer) })
63 | .then(() => process.exit(0))
64 | .catch(err => {
65 | logger.error(err.message)
66 | process.exit(1)
67 | })
68 | })
69 | }
70 |
--------------------------------------------------------------------------------
/pallets/stableswap/src/weights.rs:
--------------------------------------------------------------------------------
1 | // This file is part of Substrate.
2 |
3 | // Copyright (C) 2021 Parity Technologies (UK) Ltd.
4 | // SPDX-License-Identifier: Apache-2.0
5 |
6 | // Licensed under the Apache License, Version 2.0 (the "License");
7 | // you may not use this file except in compliance with the License.
8 | // You may obtain a copy of the License at
9 | //
10 | // http://www.apache.org/licenses/LICENSE-2.0
11 | //
12 | // Unless required by applicable law or agreed to in writing, software
13 | // distributed under the License is distributed on an "AS IS" BASIS,
14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | // See the License for the specific language governing permissions and
16 | // limitations under the License.
17 | #![allow(unused_parens)]
18 | #![allow(unused_imports)]
19 | #![allow(clippy::all)]
20 |
21 | use frame_support::weights::Weight;
22 | use sp_std::marker::PhantomData;
23 |
24 | /// Weight functions needed for pallet_stableswap
25 | pub trait WeightInfo {
26 | fn get_delta() -> Weight;
27 | fn get_alternative_var() -> Weight;
28 | fn add_liquidity() -> Weight;
29 | fn remove_liquidity() -> Weight;
30 | fn create_pool() -> Weight;
31 | }
32 |
33 | /// Weights for stableswap using the Substrate node and recommended hardware.
34 | pub struct SubstrateWeight(PhantomData);
35 | impl WeightInfo for SubstrateWeight {
36 | fn get_delta() -> Weight {
37 | Weight::from_ref_time(10_000 as u64)
38 | }
39 | fn get_alternative_var() -> Weight {
40 | Weight::from_ref_time(10_000 as u64)
41 | }
42 | fn add_liquidity() -> Weight {
43 | Weight::from_ref_time(10_000 as u64)
44 | }
45 | fn remove_liquidity() -> Weight {
46 | Weight::from_ref_time(10_000 as u64)
47 | }
48 | fn create_pool() -> Weight {
49 | Weight::from_ref_time(10_000 as u64)
50 | }
51 | }
52 |
53 | // For backwards compatibility and tests
54 | impl WeightInfo for () {
55 | fn get_delta() -> Weight {
56 | Weight::from_ref_time(10_000 as u64)
57 | }
58 | fn get_alternative_var() -> Weight {
59 | Weight::from_ref_time(10_000 as u64)
60 | }
61 | fn add_liquidity() -> Weight {
62 | Weight::from_ref_time(10_000 as u64)
63 | }
64 | fn remove_liquidity() -> Weight {
65 | Weight::from_ref_time(10_000 as u64)
66 | }
67 | fn create_pool() -> Weight {
68 | Weight::from_ref_time(10_000 as u64)
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/docs/COLLATOR.md:
--------------------------------------------------------------------------------
1 | # How to run collators for parallel?
2 |
3 | Parallel/Heiko network will open collators to the community once the chain becomes stable for some days. You will be able to run collators
4 | using the following methods.
5 |
6 | ## Method One - Governance (not advised, mostly for Parallel Team)
7 |
8 | You'll need to submit a motion first to increase the default invulerables set. If the council agreed on this motion, you can then
9 | start to run your collators.
10 |
11 | The steps are as following:
12 |
13 | 1. Submit motion, `collatorSelection -> setInvulerables` and add your collator's account id.
14 |
15 | 2. Generate collator's keystore using key command
16 |
17 | ```
18 | ./target/debug/parallel key insert -d . --keystore-path keystore --key-type aura
19 | ```
20 |
21 | 3. Launch collator
22 |
23 | ```
24 | ./scripts/collator.sh
25 | ```
26 |
27 | 4. Set session keys
28 |
29 | You'll need to prepare your collator's Sr25519 public key, and then use it to set collator's session keys
30 |
31 | ```
32 | subkey inspect --scheme Sr25519
33 | ```
34 |
35 | Then connect to polkadot.js, add use collator account to sign the following extrinsic:
36 |
37 | ```
38 | Extrinsics -> session -> setKeys(sr25519_pubkey, 0x1234)
39 | ```
40 |
41 | 5. Wait the next session (6 hours)
42 |
43 | If everything has been done successfully, your collator will be able to start producing blocks in around 6 hours (the next session)
44 |
45 | ## Method Two - Register as candidate
46 |
47 | Before registering yourself as collator candidate, you'll need to prepare enough HKO, a fixed number of HKO will be locked util
48 | that you get kicked for not producing blocks.
49 |
50 | The steps are as following:
51 |
52 | 1. Prepare HKO
53 |
54 | 2. Launch collator and insert key
55 |
56 | ```
57 | curl http://localhost:9944 -H "Content-Type:application/json;charset=utf-8" -d '{
58 | "jsonrpc": "2.0",
59 | "id": 1,
60 | "method": "author_insertKey",
61 | "params": ["", "", ""]
62 | }'
63 | ```
64 |
65 | 3. Connect to collator using polkadot.js
66 |
67 | 4. Rotate keys
68 |
69 | ```
70 | Developer -> RPC calls -> author -> rotateKeys
71 | ```
72 |
73 | 5. Set session keys using collator account
74 |
75 | ```
76 | Developer -> Extrinsics -> session -> setKeys(sr25519_pubkey, 0x1234)
77 | ```
78 |
79 | 6. Register as collator candidate
80 |
81 | ```
82 | Developer -> Extrinsics -> collatorSelection -> registerAsCandidate
83 | ```
84 |
85 | 7. Wait the next session (6 hours)
86 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/frame_system.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `frame_system`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=frame_system
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/frame_system.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `frame_system`.
29 | pub struct WeightInfo(PhantomData);
30 | impl frame_system::WeightInfo for WeightInfo {
31 | fn remark(_b: u32, ) -> Weight {
32 | Weight::from_ref_time(0 as u64)
33 | }
34 | fn remark_with_event(b: u32, ) -> Weight {
35 | Weight::from_ref_time(13_176_000 as u64)
36 | // Standard Error: 0
37 | .saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(b as u64))
38 | }
39 | // Storage: System Digest (r:1 w:1)
40 | // Storage: unknown [0x3a686561707061676573] (r:0 w:1)
41 | fn set_heap_pages() -> Weight {
42 | Weight::from_ref_time(9_294_000 as u64)
43 | .saturating_add(T::DbWeight::get().reads(1 as u64))
44 | .saturating_add(T::DbWeight::get().writes(2 as u64))
45 | }
46 | // Storage: Skipped Metadata (r:0 w:0)
47 | fn set_storage(i: u32, ) -> Weight {
48 | Weight::from_ref_time(0 as u64)
49 | // Standard Error: 1_000
50 | .saturating_add(Weight::from_ref_time(1_048_000 as u64).saturating_mul(i as u64))
51 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64)))
52 | }
53 | // Storage: Skipped Metadata (r:0 w:0)
54 | fn kill_storage(i: u32, ) -> Weight {
55 | Weight::from_ref_time(0 as u64)
56 | // Standard Error: 1_000
57 | .saturating_add(Weight::from_ref_time(757_000 as u64).saturating_mul(i as u64))
58 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64)))
59 | }
60 | // Storage: Skipped Metadata (r:0 w:0)
61 | fn kill_prefix(p: u32, ) -> Weight {
62 | Weight::from_ref_time(0 as u64)
63 | // Standard Error: 1_000
64 | .saturating_add(Weight::from_ref_time(1_505_000 as u64).saturating_mul(p as u64))
65 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64)))
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/frame_system.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `frame_system`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=frame_system
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/frame_system.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `frame_system`.
29 | pub struct WeightInfo(PhantomData);
30 | impl frame_system::WeightInfo for WeightInfo {
31 | fn remark(_b: u32, ) -> Weight {
32 | Weight::from_ref_time(0 as u64)
33 | }
34 | fn remark_with_event(b: u32, ) -> Weight {
35 | Weight::from_ref_time(13_176_000 as u64)
36 | // Standard Error: 0
37 | .saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(b as u64))
38 | }
39 | // Storage: System Digest (r:1 w:1)
40 | // Storage: unknown [0x3a686561707061676573] (r:0 w:1)
41 | fn set_heap_pages() -> Weight {
42 | Weight::from_ref_time(9_294_000 as u64)
43 | .saturating_add(T::DbWeight::get().reads(1 as u64))
44 | .saturating_add(T::DbWeight::get().writes(2 as u64))
45 | }
46 | // Storage: Skipped Metadata (r:0 w:0)
47 | fn set_storage(i: u32, ) -> Weight {
48 | Weight::from_ref_time(0 as u64)
49 | // Standard Error: 1_000
50 | .saturating_add(Weight::from_ref_time(1_048_000 as u64).saturating_mul(i as u64))
51 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64)))
52 | }
53 | // Storage: Skipped Metadata (r:0 w:0)
54 | fn kill_storage(i: u32, ) -> Weight {
55 | Weight::from_ref_time(0 as u64)
56 | // Standard Error: 1_000
57 | .saturating_add(Weight::from_ref_time(757_000 as u64).saturating_mul(i as u64))
58 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64)))
59 | }
60 | // Storage: Skipped Metadata (r:0 w:0)
61 | fn kill_prefix(p: u32, ) -> Weight {
62 | Weight::from_ref_time(0 as u64)
63 | // Standard Error: 1_000
64 | .saturating_add(Weight::from_ref_time(1_505_000 as u64).saturating_mul(p as u64))
65 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64)))
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/integration-tests/src/kusama_call.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | //! add tests for relay-chain transact here
16 | //! for unit tests covering internal logic we may still maintain in pallet
17 | //!
18 | use crate::{kusama_test_net::*, setup::*};
19 | use frame_support::{assert_ok, storage::with_transaction};
20 | use primitives::AccountId;
21 | use sp_runtime::{DispatchResult, TransactionOutcome};
22 | use xcm_emulator::TestExt;
23 |
24 | #[test]
25 | /// Test liquidate_staking stake.
26 | fn liquidate_staking_call_should_work() {
27 | let mut amount = ksm(10f64);
28 | let sovereign_sub_account: AccountId =
29 | hex_literal::hex!["5d199b535508990c59f411757617904ce65c905fced6878bacfbf26d3b4a1e97"]
30 | .into();
31 | Heiko::execute_with(|| {
32 | use heiko_runtime::{LiquidStaking, RuntimeOrigin};
33 | assert_ok!(LiquidStaking::stake(
34 | RuntimeOrigin::signed(AccountId::from(ALICE)),
35 | amount
36 | ));
37 | assert_ok!(with_transaction(
38 | || -> TransactionOutcome {
39 | assert_ok!(LiquidStaking::do_advance_era(1));
40 | assert_ok!(LiquidStaking::do_matching());
41 | TransactionOutcome::Commit(Ok(()))
42 | }
43 | ));
44 | let reserved_factor = LiquidStaking::reserve_factor();
45 | let reserved = reserved_factor.mul_floor(amount);
46 | let xcm_fee = 5_000_000_000 as u128;
47 | amount = amount - (reserved + xcm_fee);
48 | });
49 |
50 | KusamaNet::execute_with(|| {
51 | use kusama_runtime::Staking;
52 | assert_eq!(
53 | Staking::ledger(&sovereign_sub_account.clone()),
54 | Some(pallet_staking::StakingLedger {
55 | stash: sovereign_sub_account.clone(),
56 | total: amount,
57 | active: amount,
58 | unlocking: Default::default(),
59 | claimed_rewards: Default::default()
60 | })
61 | );
62 | })
63 | }
64 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_amm.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_amm`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_amm
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_amm.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_amm`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_amm::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: AMM Pools (r:1 w:1)
33 | // Storage: Assets Asset (r:3 w:3)
34 | // Storage: Assets Account (r:5 w:5)
35 | fn add_liquidity() -> Weight {
36 | Weight::from_ref_time(214_746_000 as u64)
37 | .saturating_add(T::DbWeight::get().reads(10 as u64))
38 | .saturating_add(T::DbWeight::get().writes(10 as u64))
39 | }
40 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
41 | // Storage: AMM Pools (r:1 w:1)
42 | // Storage: Assets Asset (r:3 w:3)
43 | // Storage: Assets Account (r:5 w:5)
44 | fn remove_liquidity() -> Weight {
45 | Weight::from_ref_time(233_479_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(10 as u64))
47 | .saturating_add(T::DbWeight::get().writes(10 as u64))
48 | }
49 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
50 | // Storage: AMM Pools (r:1 w:1)
51 | // Storage: Assets Asset (r:3 w:3)
52 | // Storage: Assets Account (r:6 w:6)
53 | // Storage: System Account (r:2 w:2)
54 | fn create_pool() -> Weight {
55 | Weight::from_ref_time(286_985_000 as u64)
56 | .saturating_add(T::DbWeight::get().reads(13 as u64))
57 | .saturating_add(T::DbWeight::get().writes(13 as u64))
58 | }
59 | // Storage: AMM ProtocolFee (r:0 w:1)
60 | fn update_protocol_fee() -> Weight {
61 | Weight::from_ref_time(4_067_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
62 | }
63 | // Storage: AMM ProtocolFeeReceiver (r:0 w:1)
64 | fn update_protocol_fee_receiver() -> Weight {
65 | Weight::from_ref_time(4_114_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_amm.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_amm`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_amm
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_amm.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_amm`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_amm::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: AMM Pools (r:1 w:1)
33 | // Storage: Assets Asset (r:3 w:3)
34 | // Storage: Assets Account (r:5 w:5)
35 | fn add_liquidity() -> Weight {
36 | Weight::from_ref_time(214_746_000 as u64)
37 | .saturating_add(T::DbWeight::get().reads(10 as u64))
38 | .saturating_add(T::DbWeight::get().writes(10 as u64))
39 | }
40 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
41 | // Storage: AMM Pools (r:1 w:1)
42 | // Storage: Assets Asset (r:3 w:3)
43 | // Storage: Assets Account (r:5 w:5)
44 | fn remove_liquidity() -> Weight {
45 | Weight::from_ref_time(233_479_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(10 as u64))
47 | .saturating_add(T::DbWeight::get().writes(10 as u64))
48 | }
49 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
50 | // Storage: AMM Pools (r:1 w:1)
51 | // Storage: Assets Asset (r:3 w:3)
52 | // Storage: Assets Account (r:6 w:6)
53 | // Storage: System Account (r:2 w:2)
54 | fn create_pool() -> Weight {
55 | Weight::from_ref_time(286_985_000 as u64)
56 | .saturating_add(T::DbWeight::get().reads(13 as u64))
57 | .saturating_add(T::DbWeight::get().writes(13 as u64))
58 | }
59 | // Storage: AMM ProtocolFee (r:0 w:1)
60 | fn update_protocol_fee() -> Weight {
61 | Weight::from_ref_time(4_067_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
62 | }
63 | // Storage: AMM ProtocolFeeReceiver (r:0 w:1)
64 | fn update_protocol_fee_receiver() -> Weight {
65 | Weight::from_ref_time(4_114_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/set/market-reward.ts:
--------------------------------------------------------------------------------
1 | import { getApi, getCouncilThreshold, nextNonce } from '../../utils'
2 | import { Command, CreateCommandParameters, program } from '@caporal/core'
3 | import { Keyring } from '@polkadot/api'
4 | import { readFile } from '../../utils'
5 | import BigNumber from 'bignumber.js'
6 |
7 | export default function ({ createCommand }: CreateCommandParameters): Command {
8 | return createCommand('set market reward speed')
9 | .argument('', 'path to reward csv', {
10 | validator: program.STRING
11 | })
12 | .option('-p, --para-ws [url]', 'the parachain API endpoint', {
13 | default: 'wss://parallel-rpc.dwellir.com'
14 | })
15 | .option('-d, --dry-run [boolean]', 'whether to execute using PARA_CHAIN_SUDO_KEY', {
16 | validator: program.BOOLEAN,
17 | default: true
18 | })
19 | .action(async actionParameters => {
20 | const {
21 | logger,
22 | args: { input },
23 | options: { paraWs, dryRun }
24 | } = actionParameters
25 | const api = await getApi(paraWs.toString())
26 | const signer = new Keyring({ type: 'sr25519' }).addFromUri(
27 | `${process.env.PARA_CHAIN_SUDO_KEY || '//Dave'}`
28 | )
29 |
30 | const rewards = (await readFile(input.toString(), 'utf8'))
31 | .split(/\r?\n/)
32 | .slice(1)
33 | .map(row => row.split(',').filter(Boolean))
34 | .filter(cols => cols.length >= 4)
35 | .map(([assetId, assetName, borrowSpeed, supplySpeed]) => [
36 | assetId,
37 | assetName,
38 | new BigNumber(borrowSpeed).multipliedBy('1000000000000').toString(),
39 | new BigNumber(supplySpeed).multipliedBy('1000000000000').toString()
40 | ])
41 |
42 | const proposal = api.tx.utility.batchAll(
43 | rewards.map(([assetId, assetName, borrowSpeed, supplySpeed]) => {
44 | logger.info(
45 | ` assetId: ${assetId}, assetName: ${assetName}, borrowSpeed: ${borrowSpeed}, supplySpeed: ${supplySpeed} `
46 | )
47 | return api.tx.loans.updateMarketRewardSpeed(assetId, supplySpeed, borrowSpeed)
48 | })
49 | )
50 |
51 | const tx = api.tx.generalCouncil.propose(
52 | await getCouncilThreshold(api),
53 | proposal,
54 | proposal.length
55 | )
56 |
57 | if (dryRun) {
58 | return logger.info(`hex-encoded call: ${tx.toHex()}`)
59 | }
60 |
61 | await tx
62 | .signAndSend(signer, { nonce: await nextNonce(api, signer) })
63 | .then(() => process.exit(0))
64 | .catch(err => {
65 | logger.error(err.message)
66 | process.exit(1)
67 | })
68 | })
69 | }
70 |
--------------------------------------------------------------------------------
/pallets/emergency-shutdown/src/mock.rs:
--------------------------------------------------------------------------------
1 | use crate as pallet_emergency_shutdown;
2 | use crate::EmergencyCallFilter;
3 | use frame_support::{parameter_types, traits::Contains};
4 | use frame_system::EnsureRoot;
5 | use sp_core::H256;
6 | use sp_runtime::{
7 | testing::Header,
8 | traits::{BlakeTwo256, IdentityLookup},
9 | };
10 |
11 | type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic;
12 | type Block = frame_system::mocking::MockBlock;
13 |
14 | // Configure a mock runtime to test the pallet.
15 | frame_support::construct_runtime!(
16 | pub enum Test where
17 | Block = Block,
18 | NodeBlock = Block,
19 | UncheckedExtrinsic = UncheckedExtrinsic,
20 | {
21 | System: frame_system::{Pallet, Call, Config, Storage, Event},
22 | EmergencyShutdown: pallet_emergency_shutdown::{Pallet, Call, Event},
23 | }
24 | );
25 |
26 | parameter_types! {
27 | pub const BlockHashCount: u64 = 250;
28 | pub const SS58Prefix: u8 = 42;
29 | }
30 |
31 | pub struct BaseCallFilter;
32 | impl Contains for BaseCallFilter {
33 | fn contains(c: &RuntimeCall) -> bool {
34 | EmergencyShutdown::contains(c)
35 | }
36 | }
37 |
38 | pub struct WhiteListFilter;
39 | impl Contains for WhiteListFilter {
40 | fn contains(_c: &RuntimeCall) -> bool {
41 | false
42 | }
43 | }
44 |
45 | impl frame_system::Config for Test {
46 | type BaseCallFilter = BaseCallFilter;
47 | type BlockWeights = ();
48 | type BlockLength = ();
49 | type DbWeight = ();
50 | type RuntimeOrigin = RuntimeOrigin;
51 | type RuntimeCall = RuntimeCall;
52 | type Index = u64;
53 | type BlockNumber = u64;
54 | type Hash = H256;
55 | type Hashing = BlakeTwo256;
56 | type AccountId = u64;
57 | type Lookup = IdentityLookup;
58 | type Header = Header;
59 | type RuntimeEvent = RuntimeEvent;
60 | type BlockHashCount = BlockHashCount;
61 | type Version = ();
62 | type PalletInfo = PalletInfo;
63 | type AccountData = ();
64 | type OnNewAccount = ();
65 | type OnKilledAccount = ();
66 | type SystemWeightInfo = ();
67 | type SS58Prefix = SS58Prefix;
68 | type OnSetCode = ();
69 | type MaxConsumers = frame_support::traits::ConstU32<16>;
70 | }
71 |
72 | impl pallet_emergency_shutdown::Config for Test {
73 | type RuntimeEvent = RuntimeEvent;
74 | type Whitelist = WhiteListFilter;
75 | type ShutdownOrigin = EnsureRoot;
76 | type RuntimeCall = RuntimeCall;
77 | }
78 |
79 | // Build genesis storage according to the mock runtime.
80 | pub fn new_test_ext() -> sp_io::TestExternalities {
81 | frame_system::GenesisConfig::default()
82 | .build_storage::()
83 | .unwrap()
84 | .into()
85 | }
86 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_balances.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_balances`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_balances
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_balances.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_balances`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_balances::WeightInfo for WeightInfo {
31 | // Storage: System Account (r:1 w:1)
32 | fn transfer() -> Weight {
33 | Weight::from_ref_time(90_315_000 as u64)
34 | .saturating_add(T::DbWeight::get().reads(1 as u64))
35 | .saturating_add(T::DbWeight::get().writes(1 as u64))
36 | }
37 | // Storage: System Account (r:1 w:1)
38 | fn transfer_keep_alive() -> Weight {
39 | Weight::from_ref_time(69_776_000 as u64)
40 | .saturating_add(T::DbWeight::get().reads(1 as u64))
41 | .saturating_add(T::DbWeight::get().writes(1 as u64))
42 | }
43 | // Storage: System Account (r:1 w:1)
44 | fn set_balance_creating() -> Weight {
45 | Weight::from_ref_time(43_658_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(1 as u64))
47 | .saturating_add(T::DbWeight::get().writes(1 as u64))
48 | }
49 | // Storage: System Account (r:1 w:1)
50 | fn set_balance_killing() -> Weight {
51 | Weight::from_ref_time(50_944_000 as u64)
52 | .saturating_add(T::DbWeight::get().reads(1 as u64))
53 | .saturating_add(T::DbWeight::get().writes(1 as u64))
54 | }
55 | // Storage: System Account (r:2 w:2)
56 | fn force_transfer() -> Weight {
57 | Weight::from_ref_time(89_639_000 as u64)
58 | .saturating_add(T::DbWeight::get().reads(2 as u64))
59 | .saturating_add(T::DbWeight::get().writes(2 as u64))
60 | }
61 | // Storage: System Account (r:1 w:1)
62 | fn transfer_all() -> Weight {
63 | Weight::from_ref_time(82_166_000 as u64)
64 | .saturating_add(T::DbWeight::get().reads(1 as u64))
65 | .saturating_add(T::DbWeight::get().writes(1 as u64))
66 | }
67 | // Storage: System Account (r:1 w:1)
68 | fn force_unreserve() -> Weight {
69 | Weight::from_ref_time(39_551_000 as u64)
70 | .saturating_add(T::DbWeight::get().reads(1 as u64))
71 | .saturating_add(T::DbWeight::get().writes(1 as u64))
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_balances.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_balances`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vanilla-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=vanilla-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_balances
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/vanilla/src/weights/pallet_balances.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_balances`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_balances::WeightInfo for WeightInfo {
31 | // Storage: System Account (r:1 w:1)
32 | fn transfer() -> Weight {
33 | Weight::from_ref_time(92_025_000 as u64)
34 | .saturating_add(T::DbWeight::get().reads(1 as u64))
35 | .saturating_add(T::DbWeight::get().writes(1 as u64))
36 | }
37 | // Storage: System Account (r:1 w:1)
38 | fn transfer_keep_alive() -> Weight {
39 | Weight::from_ref_time(70_511_000 as u64)
40 | .saturating_add(T::DbWeight::get().reads(1 as u64))
41 | .saturating_add(T::DbWeight::get().writes(1 as u64))
42 | }
43 | // Storage: System Account (r:1 w:1)
44 | fn set_balance_creating() -> Weight {
45 | Weight::from_ref_time(44_304_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(1 as u64))
47 | .saturating_add(T::DbWeight::get().writes(1 as u64))
48 | }
49 | // Storage: System Account (r:1 w:1)
50 | fn set_balance_killing() -> Weight {
51 | Weight::from_ref_time(51_794_000 as u64)
52 | .saturating_add(T::DbWeight::get().reads(1 as u64))
53 | .saturating_add(T::DbWeight::get().writes(1 as u64))
54 | }
55 | // Storage: System Account (r:2 w:2)
56 | fn force_transfer() -> Weight {
57 | Weight::from_ref_time(90_299_000 as u64)
58 | .saturating_add(T::DbWeight::get().reads(2 as u64))
59 | .saturating_add(T::DbWeight::get().writes(2 as u64))
60 | }
61 | // Storage: System Account (r:1 w:1)
62 | fn transfer_all() -> Weight {
63 | Weight::from_ref_time(82_886_000 as u64)
64 | .saturating_add(T::DbWeight::get().reads(1 as u64))
65 | .saturating_add(T::DbWeight::get().writes(1 as u64))
66 | }
67 | // Storage: System Account (r:1 w:1)
68 | fn force_unreserve() -> Weight {
69 | Weight::from_ref_time(40_569_000 as u64)
70 | .saturating_add(T::DbWeight::get().reads(1 as u64))
71 | .saturating_add(T::DbWeight::get().writes(1 as u64))
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/pallets/xcm-helper/src/weights.rs:
--------------------------------------------------------------------------------
1 | // This file is part of Parallel Finance.
2 |
3 | // Copyright (C) 2022 Parallel Finance Developer.
4 | // SPDX-License-Identifier: Apache-2.0
5 |
6 | // Licensed under the Apache License, Version 2.0 (the "License");
7 | // you may not use this file except in compliance with the License.
8 | // You may obtain a copy of the License at
9 | //
10 | // http://www.apache.org/licenses/LICENSE-2.0
11 | //
12 | // Unless required by applicable law or agreed to in writing, software
13 | // distributed under the License is distributed on an "AS IS" BASIS,
14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | // See the License for the specific language governing permissions and
16 | // limitations under the License.
17 |
18 | //! Autogenerated weights for pallet_xcm_helper
19 | //!
20 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
22 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
23 |
24 | // Executed Command:
25 | // ./target/release/parallel
26 | // benchmark
27 | // pallet
28 | // --chain=kerria-dev
29 | // --execution=wasm
30 | // --wasm-execution=compiled
31 | // --pallet=pallet-xcm-helper
32 | // --extrinsic=*
33 | // --steps=50
34 | // --repeat=20
35 | // --heap-pages=4096
36 | // --template=./.maintain/frame-weight-template.hbs
37 | // --output=./pallets/xcm-helper/src/weights.rs
38 |
39 | #![cfg_attr(rustfmt, rustfmt_skip)]
40 | #![allow(unused_parens)]
41 | #![allow(unused_imports)]
42 |
43 | use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
44 | use sp_std::marker::PhantomData;
45 |
46 | /// Weight functions needed for pallet_xcm_helper.
47 | pub trait WeightInfo {
48 | fn update_xcm_weight_fee() -> Weight;
49 | }
50 |
51 | /// Weights for pallet_xcm_helper using the Substrate node and recommended hardware.
52 | pub struct SubstrateWeight(PhantomData);
53 | impl WeightInfo for SubstrateWeight {
54 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
55 | // Storage: XcmHelper XcmWeightFee (r:1 w:1)
56 | fn update_xcm_weight_fee() -> Weight {
57 | Weight::from_ref_time(37_853_000 as u64)
58 | .saturating_add(T::DbWeight::get().reads(2 as u64))
59 | .saturating_add(T::DbWeight::get().writes(2 as u64))
60 | }
61 | }
62 |
63 | // For backwards compatibility and tests
64 | impl WeightInfo for () {
65 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
66 | // Storage: XcmHelper XcmWeightFee (r:1 w:1)
67 | fn update_xcm_weight_fee() -> Weight {
68 | Weight::from_ref_time(37_853_000 as u64)
69 | .saturating_add(RocksDbWeight::get().reads(2 as u64))
70 | .saturating_add(RocksDbWeight::get().writes(2 as u64))
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_amm.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_amm`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_amm
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_amm.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_amm`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_amm::WeightInfo for WeightInfo {
32 | // Storage: AMM Pools (r:1 w:1)
33 | // Storage: AMM ProtocolFee (r:1 w:0)
34 | // Storage: Assets Asset (r:3 w:3)
35 | // Storage: Assets Account (r:5 w:5)
36 | fn add_liquidity() -> Weight {
37 | // Minimum execution time: 172_184 nanoseconds.
38 | Weight::from_ref_time(173_791_000)
39 | .saturating_add(T::DbWeight::get().reads(10))
40 | .saturating_add(T::DbWeight::get().writes(9))
41 | }
42 | // Storage: AMM Pools (r:1 w:1)
43 | // Storage: AMM ProtocolFee (r:1 w:0)
44 | // Storage: Assets Asset (r:3 w:3)
45 | // Storage: Assets Account (r:5 w:5)
46 | fn remove_liquidity() -> Weight {
47 | // Minimum execution time: 188_419 nanoseconds.
48 | Weight::from_ref_time(190_666_000)
49 | .saturating_add(T::DbWeight::get().reads(10))
50 | .saturating_add(T::DbWeight::get().writes(9))
51 | }
52 | // Storage: AMM Pools (r:1 w:1)
53 | // Storage: Assets Asset (r:3 w:3)
54 | // Storage: Assets Account (r:6 w:6)
55 | // Storage: System Account (r:2 w:2)
56 | // Storage: AMM ProtocolFee (r:1 w:0)
57 | fn create_pool() -> Weight {
58 | // Minimum execution time: 214_658 nanoseconds.
59 | Weight::from_ref_time(216_739_000)
60 | .saturating_add(T::DbWeight::get().reads(13))
61 | .saturating_add(T::DbWeight::get().writes(12))
62 | }
63 | // Storage: AMM ProtocolFee (r:0 w:1)
64 | fn update_protocol_fee() -> Weight {
65 | // Minimum execution time: 24_939 nanoseconds.
66 | Weight::from_ref_time(25_267_000)
67 | .saturating_add(T::DbWeight::get().writes(1))
68 | }
69 | // Storage: AMM ProtocolFeeReceiver (r:0 w:1)
70 | fn update_protocol_fee_receiver() -> Weight {
71 | // Minimum execution time: 25_759 nanoseconds.
72 | Weight::from_ref_time(26_507_000)
73 | .saturating_add(T::DbWeight::get().writes(1))
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/pallets/prices/src/weights.rs:
--------------------------------------------------------------------------------
1 | // This file is part of Substrate.
2 |
3 | // Copyright (C) 2021 Parity Technologies (UK) Ltd.
4 | // SPDX-License-Identifier: Apache-2.0
5 |
6 | // Licensed under the Apache License, Version 2.0 (the "License");
7 | // you may not use this file except in compliance with the License.
8 | // You may obtain a copy of the License at
9 | //
10 | // http://www.apache.org/licenses/LICENSE-2.0
11 | //
12 | // Unless required by applicable law or agreed to in writing, software
13 | // distributed under the License is distributed on an "AS IS" BASIS,
14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | // See the License for the specific language governing permissions and
16 | // limitations under the License.
17 | #![allow(unused_parens)]
18 | #![allow(unused_imports)]
19 | #![allow(clippy::all)]
20 |
21 | use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
22 | use sp_std::marker::PhantomData;
23 |
24 | /// Weight functions needed for pallet_prices.
25 | pub trait WeightInfo {
26 | fn set_price() -> Weight;
27 | fn reset_price() -> Weight;
28 | fn set_foreign_asset() -> Weight;
29 | }
30 |
31 | /// Weights for pallet_prices using the Substrate node and recommended hardware.
32 | pub struct SubstrateWeight(PhantomData);
33 | impl WeightInfo for SubstrateWeight {
34 | fn set_price() -> Weight {
35 | Weight::from_ref_time(22_361_000 as u64)
36 | .saturating_add(T::DbWeight::get().reads(1 as u64))
37 | .saturating_add(T::DbWeight::get().writes(1 as u64))
38 | }
39 | fn reset_price() -> Weight {
40 | Weight::from_ref_time(21_361_000 as u64)
41 | .saturating_add(T::DbWeight::get().reads(1 as u64))
42 | .saturating_add(T::DbWeight::get().writes(1 as u64))
43 | }
44 | fn set_foreign_asset() -> Weight {
45 | Weight::from_ref_time(23_361_000 as u64)
46 | .saturating_add(T::DbWeight::get().reads(1 as u64))
47 | .saturating_add(T::DbWeight::get().writes(1 as u64))
48 | }
49 | }
50 |
51 | // For backwards compatibility and tests
52 | impl WeightInfo for () {
53 | fn set_price() -> Weight {
54 | Weight::from_ref_time(22_361_000 as u64)
55 | .saturating_add(RocksDbWeight::get().reads(1 as u64))
56 | .saturating_add(RocksDbWeight::get().writes(1 as u64))
57 | }
58 | fn reset_price() -> Weight {
59 | Weight::from_ref_time(21_361_000 as u64)
60 | .saturating_add(RocksDbWeight::get().reads(1 as u64))
61 | .saturating_add(RocksDbWeight::get().writes(1 as u64))
62 | }
63 | fn set_foreign_asset() -> Weight {
64 | Weight::from_ref_time(23_361_000 as u64)
65 | .saturating_add(RocksDbWeight::get().reads(1 as u64))
66 | .saturating_add(RocksDbWeight::get().writes(1 as u64))
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_amm.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_amm`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_amm
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_amm.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_amm`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_amm::WeightInfo for WeightInfo {
32 | // Storage: AMM Pools (r:1 w:1)
33 | // Storage: AMM ProtocolFee (r:1 w:0)
34 | // Storage: Assets Asset (r:3 w:3)
35 | // Storage: Assets Account (r:5 w:5)
36 | fn add_liquidity() -> Weight {
37 | // Minimum execution time: 168_870 nanoseconds.
38 | Weight::from_ref_time(170_464_000)
39 | .saturating_add(T::DbWeight::get().reads(10))
40 | .saturating_add(T::DbWeight::get().writes(9))
41 | }
42 | // Storage: AMM Pools (r:1 w:1)
43 | // Storage: AMM ProtocolFee (r:1 w:0)
44 | // Storage: Assets Asset (r:3 w:3)
45 | // Storage: Assets Account (r:5 w:5)
46 | fn remove_liquidity() -> Weight {
47 | // Minimum execution time: 184_600 nanoseconds.
48 | Weight::from_ref_time(186_948_000)
49 | .saturating_add(T::DbWeight::get().reads(10))
50 | .saturating_add(T::DbWeight::get().writes(9))
51 | }
52 | // Storage: AMM Pools (r:1 w:1)
53 | // Storage: Assets Asset (r:3 w:3)
54 | // Storage: Assets Account (r:6 w:6)
55 | // Storage: System Account (r:2 w:2)
56 | // Storage: AMM ProtocolFee (r:1 w:0)
57 | fn create_pool() -> Weight {
58 | // Minimum execution time: 209_601 nanoseconds.
59 | Weight::from_ref_time(211_368_000)
60 | .saturating_add(T::DbWeight::get().reads(13))
61 | .saturating_add(T::DbWeight::get().writes(12))
62 | }
63 | // Storage: AMM ProtocolFee (r:0 w:1)
64 | fn update_protocol_fee() -> Weight {
65 | // Minimum execution time: 23_972 nanoseconds.
66 | Weight::from_ref_time(24_403_000)
67 | .saturating_add(T::DbWeight::get().writes(1))
68 | }
69 | // Storage: AMM ProtocolFeeReceiver (r:0 w:1)
70 | fn update_protocol_fee_receiver() -> Weight {
71 | // Minimum execution time: 24_587 nanoseconds.
72 | Weight::from_ref_time(25_100_000)
73 | .saturating_add(T::DbWeight::get().writes(1))
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_streaming.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_streaming`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_streaming
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_streaming.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_streaming`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_streaming::WeightInfo for WeightInfo {
32 | // Storage: Streaming MinimumDeposits (r:1 w:0)
33 | // Storage: Timestamp Now (r:1 w:0)
34 | // Storage: Assets Asset (r:1 w:1)
35 | // Storage: Assets Account (r:2 w:2)
36 | // Storage: System Account (r:1 w:1)
37 | // Storage: Streaming NextStreamId (r:1 w:1)
38 | // Storage: Streaming StreamLibrary (r:4 w:4)
39 | // Storage: Streaming Streams (r:0 w:1)
40 | fn create() -> Weight {
41 | // Minimum execution time: 121_637 nanoseconds.
42 | Weight::from_ref_time(123_046_000)
43 | .saturating_add(T::DbWeight::get().reads(11))
44 | .saturating_add(T::DbWeight::get().writes(10))
45 | }
46 | // Storage: Streaming Streams (r:1 w:1)
47 | // Storage: Timestamp Now (r:1 w:0)
48 | // Storage: Assets Asset (r:1 w:1)
49 | // Storage: Assets Account (r:2 w:2)
50 | // Storage: System Account (r:1 w:1)
51 | // Storage: Streaming StreamLibrary (r:2 w:2)
52 | fn cancel() -> Weight {
53 | // Minimum execution time: 132_915 nanoseconds.
54 | Weight::from_ref_time(134_222_000)
55 | .saturating_add(T::DbWeight::get().reads(8))
56 | .saturating_add(T::DbWeight::get().writes(7))
57 | }
58 | // Storage: Streaming Streams (r:1 w:1)
59 | // Storage: Timestamp Now (r:1 w:0)
60 | // Storage: Assets Asset (r:1 w:1)
61 | // Storage: Assets Account (r:2 w:2)
62 | // Storage: System Account (r:1 w:1)
63 | fn withdraw() -> Weight {
64 | // Minimum execution time: 108_244 nanoseconds.
65 | Weight::from_ref_time(109_698_000)
66 | .saturating_add(T::DbWeight::get().reads(6))
67 | .saturating_add(T::DbWeight::get().writes(5))
68 | }
69 | // Storage: Streaming MinimumDeposits (r:0 w:1)
70 | fn set_minimum_deposit() -> Weight {
71 | // Minimum execution time: 26_523 nanoseconds.
72 | Weight::from_ref_time(27_200_000)
73 | .saturating_add(T::DbWeight::get().writes(1))
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/democracy/runtime-upgrade.ts:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import https from 'https'
3 | import { Command, CreateCommandParameters, program } from '@caporal/core'
4 | import { Keyring } from '@polkadot/api'
5 | import { blake2AsHex } from '@polkadot/util-crypto'
6 | import { getApi, getCouncilThreshold, nextNonce } from '../../utils'
7 |
8 | export default function ({ createCommand }: CreateCommandParameters): Command {
9 | return createCommand('runtime upgrade via democracy')
10 | .option('-p, --para-ws [url]', 'the parachain API endpoint', {
11 | default: 'wss://heiko-rpc.parallel.fi'
12 | })
13 | .option('-r, --runtime-name [name]', 'runtime name', {
14 | default: 'heiko'
15 | })
16 | .option('-v, --runtime-version [version]', 'runtime version', {
17 | default: 'v1.8.5'
18 | })
19 | .option('-b, --blake256-hash [hash]', "runtime code's blake256 hash", {
20 | default: '0xe1caf000a36540de68a34ed2ce3d70eccd56b05fefda895dd308ee73c53fed40'
21 | })
22 | .option('-d, --dry-run [boolean]', 'whether to execute using PARA_CHAIN_SUDO_KEY', {
23 | validator: program.BOOLEAN,
24 | default: true
25 | })
26 | .action(async actionParameters => {
27 | const {
28 | logger,
29 | options: { paraWs, dryRun, runtimeVersion, runtimeName, blake256Hash }
30 | } = actionParameters
31 | const api = await getApi(paraWs.toString())
32 | const signer = new Keyring({ type: 'sr25519' }).addFromUri(
33 | `${process.env.PARA_CHAIN_SUDO_KEY || '//Dave'}`
34 | )
35 | const url = `https://github.com/parallel-finance/parallel/releases/download/${runtimeVersion.toString()}/${runtimeName.toString()}_runtime.compact.compressed.wasm`
36 | const res = await axios.get(url, {
37 | responseType: 'arraybuffer',
38 | httpsAgent: new https.Agent({ keepAlive: true })
39 | })
40 | const code = new Uint8Array(res.data)
41 | const codeHash = blake2AsHex(code, 256)
42 | if (codeHash !== blake256Hash.toString()) {
43 | return logger.error("Runtime code doesn't match blake256Hash")
44 | }
45 |
46 | const encoded = api.tx.parachainSystem.authorizeUpgrade(codeHash).method.toHex()
47 | const encodedHash = blake2AsHex(encoded)
48 |
49 | const external = api.tx.democracy.externalProposeMajority({ Legacy: encodedHash })
50 |
51 | const tx = api.tx.utility.batchAll([
52 | api.tx.preimage.notePreimage(encoded),
53 | api.tx.generalCouncil.propose(await getCouncilThreshold(api), external, external.length)
54 | ])
55 | if (dryRun) {
56 | return logger.info(`hex-encoded call: ${tx.toHex()}`)
57 | }
58 |
59 | await tx
60 | .signAndSend(signer, { nonce: await nextNonce(api, signer) })
61 | .then(() => process.exit(0))
62 | .catch(err => {
63 | logger.error(err.message)
64 | process.exit(1)
65 | })
66 | })
67 | }
68 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_streaming.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_streaming`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_streaming
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_streaming.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_streaming`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_streaming::WeightInfo for WeightInfo {
32 | // Storage: Streaming MinimumDeposits (r:1 w:0)
33 | // Storage: Timestamp Now (r:1 w:0)
34 | // Storage: Assets Asset (r:1 w:1)
35 | // Storage: Assets Account (r:2 w:2)
36 | // Storage: System Account (r:1 w:1)
37 | // Storage: Streaming NextStreamId (r:1 w:1)
38 | // Storage: Streaming StreamLibrary (r:4 w:4)
39 | // Storage: Streaming Streams (r:0 w:1)
40 | fn create() -> Weight {
41 | // Minimum execution time: 120_957 nanoseconds.
42 | Weight::from_ref_time(122_126_000)
43 | .saturating_add(T::DbWeight::get().reads(11))
44 | .saturating_add(T::DbWeight::get().writes(10))
45 | }
46 | // Storage: Streaming Streams (r:1 w:1)
47 | // Storage: Timestamp Now (r:1 w:0)
48 | // Storage: Assets Asset (r:1 w:1)
49 | // Storage: Assets Account (r:2 w:2)
50 | // Storage: System Account (r:1 w:1)
51 | // Storage: Streaming StreamLibrary (r:2 w:2)
52 | fn cancel() -> Weight {
53 | // Minimum execution time: 131_479 nanoseconds.
54 | Weight::from_ref_time(132_774_000)
55 | .saturating_add(T::DbWeight::get().reads(8))
56 | .saturating_add(T::DbWeight::get().writes(7))
57 | }
58 | // Storage: Streaming Streams (r:1 w:1)
59 | // Storage: Timestamp Now (r:1 w:0)
60 | // Storage: Assets Asset (r:1 w:1)
61 | // Storage: Assets Account (r:2 w:2)
62 | // Storage: System Account (r:1 w:1)
63 | fn withdraw() -> Weight {
64 | // Minimum execution time: 107_584 nanoseconds.
65 | Weight::from_ref_time(108_849_000)
66 | .saturating_add(T::DbWeight::get().reads(6))
67 | .saturating_add(T::DbWeight::get().writes(5))
68 | }
69 | // Storage: Streaming MinimumDeposits (r:0 w:1)
70 | fn set_minimum_deposit() -> Weight {
71 | // Minimum execution time: 26_785 nanoseconds.
72 | Weight::from_ref_time(27_346_000)
73 | .saturating_add(T::DbWeight::get().writes(1))
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/orml_oracle.rs:
--------------------------------------------------------------------------------
1 | // This file is part of Parallel.
2 |
3 | // Copyright (C) 2020-2022 Parallel Foundation.
4 | // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5 |
6 | // This program is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | //! Autogenerated weights for orml_oracle
20 | //!
21 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
22 | //! DATE: 2022-10-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
23 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
24 |
25 | // Executed Command:
26 | // ./target/release/parallel
27 | // benchmark
28 | // pallet
29 | // --chain=parallel-dev
30 | // --steps=50
31 | // --repeat=20
32 | // --pallet=*
33 | // --extrinsic=*
34 | // --execution=wasm
35 | // --wasm-execution=compiled
36 | // --heap-pages=4096
37 | // --template=./templates/runtime-weight-template.hbs
38 | // --output=./runtime/parallel/src/weights/
39 |
40 | #![cfg_attr(rustfmt, rustfmt_skip)]
41 | #![allow(unused_parens)]
42 | #![allow(unused_imports)]
43 |
44 | use frame_support::{traits::Get, weights::Weight};
45 | use sp_std::marker::PhantomData;
46 |
47 | /// Weight functions for orml_oracle.
48 | pub struct WeightInfo(PhantomData);
49 | impl orml_oracle::WeightInfo for WeightInfo {
50 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
51 | // Storage: ParallelOracle HasDispatched (r:1 w:1)
52 | // Storage: Timestamp Now (r:1 w:0)
53 | // Storage: OperatorMembershipParallel Members (r:1 w:0)
54 | // Storage: ParallelOracle Values (r:1 w:0)
55 | // Storage: ParallelOracle RawValues (r:0 w:1)
56 | fn feed_values(c: u32, ) -> Weight {
57 | Weight::from_ref_time(18_441_000 as u64)
58 | // Standard Error: 88_000
59 | .saturating_add(Weight::from_ref_time(6_603_000 as u64).saturating_mul(c as u64))
60 | .saturating_add(T::DbWeight::get().reads(3 as u64))
61 | .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64)))
62 | .saturating_add(T::DbWeight::get().writes(2 as u64))
63 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64)))
64 | }
65 | // Storage: ParallelOracle HasDispatched (r:0 w:1)
66 | fn on_finalize() -> Weight {
67 | Weight::from_ref_time(3_578_000 as u64)
68 | .saturating_add(T::DbWeight::get().writes(1 as u64))
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/orml_oracle.rs:
--------------------------------------------------------------------------------
1 | // This file is part of Parallel.
2 |
3 | // Copyright (C) 2020-2022 Parallel Foundation.
4 | // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5 |
6 | // This program is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | //! Autogenerated weights for orml_oracle
20 | //!
21 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
22 | //! DATE: 2022-10-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
23 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
24 |
25 | // Executed Command:
26 | // ./target/release/parallel
27 | // benchmark
28 | // pallet
29 | // --chain=parallel-dev
30 | // --steps=50
31 | // --repeat=20
32 | // --pallet=*
33 | // --extrinsic=*
34 | // --execution=wasm
35 | // --wasm-execution=compiled
36 | // --heap-pages=4096
37 | // --template=./templates/runtime-weight-template.hbs
38 | // --output=./runtime/parallel/src/weights/
39 |
40 | #![cfg_attr(rustfmt, rustfmt_skip)]
41 | #![allow(unused_parens)]
42 | #![allow(unused_imports)]
43 |
44 | use frame_support::{traits::Get, weights::Weight};
45 | use sp_std::marker::PhantomData;
46 |
47 | /// Weight functions for orml_oracle.
48 | pub struct WeightInfo(PhantomData);
49 | impl orml_oracle::WeightInfo for WeightInfo {
50 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
51 | // Storage: ParallelOracle HasDispatched (r:1 w:1)
52 | // Storage: Timestamp Now (r:1 w:0)
53 | // Storage: OperatorMembershipParallel Members (r:1 w:0)
54 | // Storage: ParallelOracle Values (r:1 w:0)
55 | // Storage: ParallelOracle RawValues (r:0 w:1)
56 | fn feed_values(c: u32, ) -> Weight {
57 | Weight::from_ref_time(18_441_000 as u64)
58 | // Standard Error: 88_000
59 | .saturating_add(Weight::from_ref_time(6_603_000 as u64).saturating_mul(c as u64))
60 | .saturating_add(T::DbWeight::get().reads(3 as u64))
61 | .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64)))
62 | .saturating_add(T::DbWeight::get().writes(2 as u64))
63 | .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64)))
64 | }
65 | // Storage: ParallelOracle HasDispatched (r:0 w:1)
66 | fn on_finalize() -> Weight {
67 | Weight::from_ref_time(3_578_000 as u64)
68 | .saturating_add(T::DbWeight::get().writes(1 as u64))
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/integration-tests/src/kusama_transfer.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Parallel Finance Developer.
2 | // This file is part of Parallel Finance.
3 |
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | //! Cross-chain transfer tests within Kusama network.
16 |
17 | use cumulus_primitives_core::ParaId;
18 | use frame_support::assert_ok;
19 | use heiko_runtime::Assets;
20 | use primitives::{tokens::*, AccountId};
21 | use sp_runtime::traits::AccountIdConversion;
22 | use xcm::{latest::prelude::*, VersionedMultiAssets, VersionedMultiLocation};
23 | use xcm_emulator::TestExt;
24 |
25 | use crate::{kusama_test_net::*, setup::*};
26 |
27 | #[test]
28 | fn transfer_from_relay_chain() {
29 | KusamaNet::execute_with(|| {
30 | assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets(
31 | kusama_runtime::RuntimeOrigin::signed(ALICE.into()),
32 | Box::new(VersionedMultiLocation::V3(X1(Parachain(2085)).into())),
33 | Box::new(VersionedMultiLocation::V3(
34 | X1(Junction::AccountId32 {
35 | id: BOB,
36 | network: None
37 | })
38 | .into()
39 | )),
40 | Box::new(VersionedMultiAssets::V3((Here, ksm(1f64)).into())),
41 | 0,
42 | ));
43 | });
44 |
45 | Heiko::execute_with(|| {
46 | assert_eq!(Assets::balance(KSM, &AccountId::from(BOB)), 999_860_956_000);
47 | //ksm fee in heiko is 139_044_000,seems increased 50% in v0.9.24
48 | });
49 | }
50 |
51 | #[test]
52 | fn transfer_to_relay_chain() {
53 | use heiko_runtime::{RuntimeOrigin, XTokens};
54 | Heiko::execute_with(|| {
55 | assert_ok!(XTokens::transfer(
56 | RuntimeOrigin::signed(ALICE.into()),
57 | KSM,
58 | ksm(1f64),
59 | Box::new(xcm::VersionedMultiLocation::V3(MultiLocation::new(
60 | 1,
61 | X1(Junction::AccountId32 {
62 | id: BOB,
63 | network: None
64 | })
65 | ))),
66 | WeightLimit::Limited(4_000_000_000.into())
67 | ));
68 | });
69 |
70 | KusamaNet::execute_with(|| {
71 | let para_acc: AccountId = ParaId::from(2085).into_account_truncating();
72 | println!("heiko para account in relaychain:{:?}", para_acc);
73 | assert_eq!(
74 | kusama_runtime::Balances::free_balance(&AccountId::from(BOB)),
75 | 999909712564
76 | );
77 | });
78 | }
79 |
--------------------------------------------------------------------------------
/scripts/helper/src/commands/hrmp/open.ts:
--------------------------------------------------------------------------------
1 | import {
2 | createXcm,
3 | getApi,
4 | getRelayApi,
5 | nextNonce,
6 | sovereignRelayOf,
7 | getDefaultRelayChainWsUrl,
8 | getDefaultParachainWsUrl,
9 | getCouncilThreshold
10 | } from '../../utils'
11 | import { Command, CreateCommandParameters, program } from '@caporal/core'
12 | import { Keyring } from '@polkadot/api'
13 | import { PolkadotRuntimeParachainsConfigurationHostConfiguration } from '@polkadot/types/lookup'
14 |
15 | export default function ({ createCommand }: CreateCommandParameters): Command {
16 | const relayChainUrl: string = getDefaultRelayChainWsUrl()
17 | const paraChainUrl: string = getDefaultParachainWsUrl()
18 | return createCommand('open hrmp channel to specific chain')
19 | .argument('', 'paraId of source chain', {
20 | validator: program.NUMBER
21 | })
22 | .argument('', 'paraId of target chain', {
23 | validator: program.NUMBER
24 | })
25 | .option('-r, --relay-ws [url]', 'the relaychain API endpoint', {
26 | default: relayChainUrl
27 | })
28 | .option('-p, --para-ws [url]', 'the parachain API endpoint', {
29 | default: paraChainUrl
30 | })
31 | .option('-d, --dry-run [boolean]', 'whether to execute using PARA_CHAIN_SUDO_KEY', {
32 | validator: program.BOOLEAN,
33 | default: true
34 | })
35 | .action(async actionParameters => {
36 | const {
37 | logger,
38 | args: { source, target },
39 | options: { relayWs, paraWs, dryRun }
40 | } = actionParameters
41 | const relayApi = await getRelayApi(relayWs.toString())
42 | const api = await getApi(paraWs.toString())
43 | const configuration =
44 | (await relayApi.query.configuration.activeConfig()) as unknown as PolkadotRuntimeParachainsConfigurationHostConfiguration
45 | const encoded = relayApi.tx.hrmp
46 | .hrmpInitOpenChannel(
47 | target.valueOf() as number,
48 | configuration.hrmpChannelMaxCapacity,
49 | configuration.hrmpChannelMaxMessageSize
50 | )
51 | .toHex()
52 | const signer = new Keyring({ type: 'sr25519' }).addFromUri(
53 | `${process.env.PARA_CHAIN_SUDO_KEY || '//Dave'}`
54 | )
55 | const proposal = api.tx.ormlXcm.sendAsSovereign(
56 | {
57 | V1: {
58 | parents: 1,
59 | interior: 'Here'
60 | }
61 | },
62 | createXcm(`0x${encoded.slice(6)}`, sovereignRelayOf(source.valueOf() as number))
63 | )
64 | const tx = api.tx.generalCouncil.propose(
65 | await getCouncilThreshold(api),
66 | proposal,
67 | proposal.length
68 | )
69 |
70 | if (dryRun) {
71 | return logger.info(`hex-encoded call: ${tx.toHex()}`)
72 | }
73 |
74 | await tx
75 | .signAndSend(signer, { nonce: await nextNonce(api, signer) })
76 | .then(() => process.exit(0))
77 | .catch(err => {
78 | logger.error(err.message)
79 | process.exit(1)
80 | })
81 | })
82 | }
83 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_asset_registry.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_asset_registry`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_asset_registry
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_asset_registry.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_asset_registry`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_asset_registry::WeightInfo for WeightInfo {
31 | // Storage: AssetRegistry AssetIdType (r:1 w:1)
32 | // Storage: AssetRegistry AssetTypeId (r:0 w:1)
33 | fn register_asset() -> Weight {
34 | Weight::from_ref_time(36_239_000 as u64)
35 | .saturating_add(T::DbWeight::get().reads(1 as u64))
36 | .saturating_add(T::DbWeight::get().writes(2 as u64))
37 | }
38 | // Storage: AssetRegistry AssetTypeId (r:1 w:0)
39 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
40 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:0 w:1)
41 | fn update_asset_units_per_second() -> Weight {
42 | Weight::from_ref_time(45_174_000 as u64)
43 | .saturating_add(T::DbWeight::get().reads(2 as u64))
44 | .saturating_add(T::DbWeight::get().writes(2 as u64))
45 | }
46 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
47 | // Storage: AssetRegistry AssetIdType (r:1 w:1)
48 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:1 w:2)
49 | // Storage: AssetRegistry AssetTypeId (r:0 w:2)
50 | fn update_asset_type() -> Weight {
51 | Weight::from_ref_time(61_733_000 as u64)
52 | .saturating_add(T::DbWeight::get().reads(3 as u64))
53 | .saturating_add(T::DbWeight::get().writes(6 as u64))
54 | }
55 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
56 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:0 w:1)
57 | fn remove_fee_payment_asset() -> Weight {
58 | Weight::from_ref_time(38_339_000 as u64)
59 | .saturating_add(T::DbWeight::get().reads(1 as u64))
60 | .saturating_add(T::DbWeight::get().writes(2 as u64))
61 | }
62 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
63 | // Storage: AssetRegistry AssetIdType (r:1 w:1)
64 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:0 w:1)
65 | // Storage: AssetRegistry AssetTypeId (r:0 w:1)
66 | fn deregister_asset() -> Weight {
67 | Weight::from_ref_time(48_719_000 as u64)
68 | .saturating_add(T::DbWeight::get().reads(2 as u64))
69 | .saturating_add(T::DbWeight::get().writes(4 as u64))
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_asset_registry.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_asset_registry`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vanilla-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=vanilla-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_asset_registry
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/vanilla/src/weights/pallet_asset_registry.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_asset_registry`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_asset_registry::WeightInfo for WeightInfo {
31 | // Storage: AssetRegistry AssetIdType (r:1 w:1)
32 | // Storage: AssetRegistry AssetTypeId (r:0 w:1)
33 | fn register_asset() -> Weight {
34 | Weight::from_ref_time(35_517_000 as u64)
35 | .saturating_add(T::DbWeight::get().reads(1 as u64))
36 | .saturating_add(T::DbWeight::get().writes(2 as u64))
37 | }
38 | // Storage: AssetRegistry AssetTypeId (r:1 w:0)
39 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
40 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:0 w:1)
41 | fn update_asset_units_per_second() -> Weight {
42 | Weight::from_ref_time(45_432_000 as u64)
43 | .saturating_add(T::DbWeight::get().reads(2 as u64))
44 | .saturating_add(T::DbWeight::get().writes(2 as u64))
45 | }
46 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
47 | // Storage: AssetRegistry AssetIdType (r:1 w:1)
48 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:1 w:2)
49 | // Storage: AssetRegistry AssetTypeId (r:0 w:2)
50 | fn update_asset_type() -> Weight {
51 | Weight::from_ref_time(60_684_000 as u64)
52 | .saturating_add(T::DbWeight::get().reads(3 as u64))
53 | .saturating_add(T::DbWeight::get().writes(6 as u64))
54 | }
55 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
56 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:0 w:1)
57 | fn remove_fee_payment_asset() -> Weight {
58 | Weight::from_ref_time(37_895_000 as u64)
59 | .saturating_add(T::DbWeight::get().reads(1 as u64))
60 | .saturating_add(T::DbWeight::get().writes(2 as u64))
61 | }
62 | // Storage: AssetRegistry SupportedFeePaymentAssets (r:1 w:1)
63 | // Storage: AssetRegistry AssetIdType (r:1 w:1)
64 | // Storage: AssetRegistry AssetTypeUnitsPerSecond (r:0 w:1)
65 | // Storage: AssetRegistry AssetTypeId (r:0 w:1)
66 | fn deregister_asset() -> Weight {
67 | Weight::from_ref_time(47_531_000 as u64)
68 | .saturating_add(T::DbWeight::get().reads(2 as u64))
69 | .saturating_add(T::DbWeight::get().writes(4 as u64))
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/pallets/xcm-helper/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | authors = { workspace = true }
3 | edition = '2021'
4 | name = 'pallet-xcm-helper'
5 | version = { workspace = true }
6 |
7 | [package.metadata.docs.rs]
8 | targets = ['x86_64-unknown-linux-gnu']
9 |
10 | [dependencies]
11 | codec = { workspace = true, package = 'parity-scale-codec', features = ['max-encoded-len'] }
12 | frame-benchmarking = { workspace = true, optional = true }
13 | frame-support = { workspace = true }
14 | frame-system = { workspace = true }
15 | pallet-assets = { workspace = true }
16 | pallet-traits = { workspace = true }
17 | pallet-xcm = { workspace = true }
18 | primitives = { workspace = true }
19 | scale-info = { workspace = true, features = ['derive'] }
20 | sp-core = { workspace = true }
21 | sp-io = { workspace = true }
22 | sp-runtime = { workspace = true }
23 | sp-std = { workspace = true }
24 | xcm = { workspace = true }
25 | xcm-executor = { workspace = true }
26 |
27 | [dev-dependencies]
28 | cumulus-pallet-dmp-queue = { workspace = true, features = ['std'] }
29 | cumulus-pallet-parachain-system = { workspace = true, features = ['std'] }
30 | cumulus-pallet-xcm = { workspace = true, features = ['std'] }
31 | cumulus-pallet-xcmp-queue = { workspace = true, features = ['std'] }
32 | kusama-runtime = { workspace = true, features = ['runtime-benchmarks'] }
33 | orml-xcm-support = { workspace = true, features = ['std'] }
34 | pallet-babe = { workspace = true, features = ['std'] }
35 | pallet-balances = { workspace = true, features = ['std'] }
36 | pallet-session = { workspace = true, features = ['std'] }
37 | pallet-timestamp = { workspace = true, features = ['std'] }
38 | pallet-utility = { workspace = true, features = ['std'] }
39 | parachain-info = { workspace = true, features = ['std'] }
40 | polkadot-core-primitives = { workspace = true }
41 | polkadot-parachain = { workspace = true, features = ['std'] }
42 | polkadot-runtime-parachains = { workspace = true }
43 | serde = { workspace = true }
44 | sp-io = { workspace = true }
45 | xcm-builder = { workspace = true, features = ['std'] }
46 | xcm-executor = { workspace = true, features = ['std'] }
47 | xcm-simulator = { workspace = true }
48 |
49 | [features]
50 | default = ['std']
51 | runtime-benchmarks = ['frame-benchmarking']
52 | std = [
53 | 'codec/std',
54 | 'frame-support/std',
55 | 'frame-system/std',
56 | 'frame-benchmarking/std',
57 | 'sp-runtime/std',
58 | 'scale-info/std',
59 | 'sp-std/std',
60 | 'xcm/std',
61 | 'xcm-executor/std',
62 | 'pallet-assets/std',
63 | 'pallet-xcm/std',
64 | 'primitives/std',
65 | 'pallet-traits/std',
66 | ]
67 | try-runtime = ['frame-support/try-runtime']
68 |
69 | [lib]
70 | doctest = false
71 |
--------------------------------------------------------------------------------
/runtime/kerria/src/weights/pallet_streaming.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_streaming`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kerria-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=kerria-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_streaming
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/kerria/src/weights/pallet_streaming.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_streaming`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_streaming::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: Streaming MinimumDeposits (r:1 w:0)
33 | // Storage: Timestamp Now (r:1 w:0)
34 | // Storage: Assets Asset (r:1 w:1)
35 | // Storage: Assets Account (r:2 w:2)
36 | // Storage: System Account (r:1 w:1)
37 | // Storage: Streaming NextStreamId (r:1 w:1)
38 | // Storage: Streaming StreamLibrary (r:4 w:4)
39 | // Storage: Streaming Streams (r:0 w:1)
40 | fn create() -> Weight {
41 | Weight::from_ref_time(165_768_000 as u64)
42 | .saturating_add(T::DbWeight::get().reads(12 as u64))
43 | .saturating_add(T::DbWeight::get().writes(11 as u64))
44 | }
45 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
46 | // Storage: Streaming Streams (r:1 w:1)
47 | // Storage: Timestamp Now (r:1 w:0)
48 | // Storage: Assets Asset (r:1 w:1)
49 | // Storage: Assets Account (r:2 w:2)
50 | // Storage: System Account (r:1 w:1)
51 | // Storage: Streaming StreamLibrary (r:2 w:2)
52 | fn cancel() -> Weight {
53 | Weight::from_ref_time(173_111_000 as u64)
54 | .saturating_add(T::DbWeight::get().reads(9 as u64))
55 | .saturating_add(T::DbWeight::get().writes(8 as u64))
56 | }
57 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
58 | // Storage: Streaming Streams (r:1 w:1)
59 | // Storage: Timestamp Now (r:1 w:0)
60 | // Storage: Assets Asset (r:1 w:1)
61 | // Storage: Assets Account (r:2 w:2)
62 | // Storage: System Account (r:1 w:1)
63 | fn withdraw() -> Weight {
64 | Weight::from_ref_time(131_966_000 as u64)
65 | .saturating_add(T::DbWeight::get().reads(7 as u64))
66 | .saturating_add(T::DbWeight::get().writes(6 as u64))
67 | }
68 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
69 | // Storage: Streaming MinimumDeposits (r:0 w:1)
70 | fn set_minimum_deposit() -> Weight {
71 | Weight::from_ref_time(33_429_000 as u64)
72 | .saturating_add(T::DbWeight::get().reads(1 as u64))
73 | .saturating_add(T::DbWeight::get().writes(2 as u64))
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/runtime/vanilla/src/weights/pallet_streaming.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_streaming`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vanilla-dev"), DB CACHE: 1024
7 |
8 | // Executed Command:
9 | // ./target/release/parallel
10 | // benchmark
11 | // pallet
12 | // --chain=vanilla-dev
13 | // --execution=wasm
14 | // --wasm-execution=compiled
15 | // --pallet=pallet_streaming
16 | // --extrinsic=*
17 | // --steps=50
18 | // --repeat=20
19 | // --output=./runtime/vanilla/src/weights/pallet_streaming.rs
20 |
21 | #![cfg_attr(rustfmt, rustfmt_skip)]
22 | #![allow(unused_parens)]
23 | #![allow(unused_imports)]
24 |
25 | use frame_support::{traits::Get, weights::Weight};
26 | use sp_std::marker::PhantomData;
27 |
28 | /// Weight functions for `pallet_streaming`.
29 | pub struct WeightInfo(PhantomData);
30 | impl pallet_streaming::WeightInfo for WeightInfo {
31 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
32 | // Storage: Streaming MinimumDeposits (r:1 w:0)
33 | // Storage: Timestamp Now (r:1 w:0)
34 | // Storage: Assets Asset (r:1 w:1)
35 | // Storage: Assets Account (r:2 w:2)
36 | // Storage: System Account (r:1 w:1)
37 | // Storage: Streaming NextStreamId (r:1 w:1)
38 | // Storage: Streaming StreamLibrary (r:4 w:4)
39 | // Storage: Streaming Streams (r:0 w:1)
40 | fn create() -> Weight {
41 | Weight::from_ref_time(167_116_000 as u64)
42 | .saturating_add(T::DbWeight::get().reads(12 as u64))
43 | .saturating_add(T::DbWeight::get().writes(11 as u64))
44 | }
45 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
46 | // Storage: Streaming Streams (r:1 w:1)
47 | // Storage: Timestamp Now (r:1 w:0)
48 | // Storage: Assets Asset (r:1 w:1)
49 | // Storage: Assets Account (r:2 w:2)
50 | // Storage: System Account (r:1 w:1)
51 | // Storage: Streaming StreamLibrary (r:2 w:2)
52 | fn cancel() -> Weight {
53 | Weight::from_ref_time(175_095_000 as u64)
54 | .saturating_add(T::DbWeight::get().reads(9 as u64))
55 | .saturating_add(T::DbWeight::get().writes(8 as u64))
56 | }
57 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
58 | // Storage: Streaming Streams (r:1 w:1)
59 | // Storage: Timestamp Now (r:1 w:0)
60 | // Storage: Assets Asset (r:1 w:1)
61 | // Storage: Assets Account (r:2 w:2)
62 | // Storage: System Account (r:1 w:1)
63 | fn withdraw() -> Weight {
64 | Weight::from_ref_time(133_003_000 as u64)
65 | .saturating_add(T::DbWeight::get().reads(7 as u64))
66 | .saturating_add(T::DbWeight::get().writes(6 as u64))
67 | }
68 | // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1)
69 | // Storage: Streaming MinimumDeposits (r:0 w:1)
70 | fn set_minimum_deposit() -> Weight {
71 | Weight::from_ref_time(35_267_000 as u64)
72 | .saturating_add(T::DbWeight::get().reads(1 as u64))
73 | .saturating_add(T::DbWeight::get().writes(2 as u64))
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/runtime/heiko/src/weights/pallet_balances.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_balances`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("heiko-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=heiko-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_balances
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/heiko/src/weights/pallet_balances.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_balances`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_balances::WeightInfo for WeightInfo {
32 | // Storage: System Account (r:2 w:2)
33 | fn transfer() -> Weight {
34 | // Minimum execution time: 92_568 nanoseconds.
35 | Weight::from_ref_time(93_939_000)
36 | .saturating_add(T::DbWeight::get().reads(2))
37 | .saturating_add(T::DbWeight::get().writes(2))
38 | }
39 | // Storage: System Account (r:1 w:1)
40 | fn transfer_keep_alive() -> Weight {
41 | // Minimum execution time: 58_415 nanoseconds.
42 | Weight::from_ref_time(59_369_000)
43 | .saturating_add(T::DbWeight::get().reads(1))
44 | .saturating_add(T::DbWeight::get().writes(1))
45 | }
46 | // Storage: System Account (r:1 w:1)
47 | fn set_balance_creating() -> Weight {
48 | // Minimum execution time: 40_299 nanoseconds.
49 | Weight::from_ref_time(41_060_000)
50 | .saturating_add(T::DbWeight::get().reads(1))
51 | .saturating_add(T::DbWeight::get().writes(1))
52 | }
53 | // Storage: System Account (r:1 w:1)
54 | fn set_balance_killing() -> Weight {
55 | // Minimum execution time: 46_157 nanoseconds.
56 | Weight::from_ref_time(46_995_000)
57 | .saturating_add(T::DbWeight::get().reads(1))
58 | .saturating_add(T::DbWeight::get().writes(1))
59 | }
60 | // Storage: System Account (r:3 w:3)
61 | fn force_transfer() -> Weight {
62 | // Minimum execution time: 92_012 nanoseconds.
63 | Weight::from_ref_time(93_374_000)
64 | .saturating_add(T::DbWeight::get().reads(3))
65 | .saturating_add(T::DbWeight::get().writes(3))
66 | }
67 | // Storage: System Account (r:1 w:1)
68 | fn transfer_all() -> Weight {
69 | // Minimum execution time: 68_981 nanoseconds.
70 | Weight::from_ref_time(69_975_000)
71 | .saturating_add(T::DbWeight::get().reads(1))
72 | .saturating_add(T::DbWeight::get().writes(1))
73 | }
74 | // Storage: System Account (r:1 w:1)
75 | fn force_unreserve() -> Weight {
76 | // Minimum execution time: 36_203 nanoseconds.
77 | Weight::from_ref_time(36_595_000)
78 | .saturating_add(T::DbWeight::get().reads(1))
79 | .saturating_add(T::DbWeight::get().writes(1))
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/runtime/parallel/src/weights/pallet_balances.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_balances`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2023-03-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `ip-172-88-3-164`, CPU: `Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz`
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("parallel-dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/parallel
11 | // benchmark
12 | // pallet
13 | // --chain=parallel-dev
14 | // --execution=wasm
15 | // --wasm-execution=compiled
16 | // --pallet=pallet_balances
17 | // --extrinsic=*
18 | // --steps=50
19 | // --repeat=20
20 | // --output=./runtime/parallel/src/weights/pallet_balances.rs
21 |
22 | #![cfg_attr(rustfmt, rustfmt_skip)]
23 | #![allow(unused_parens)]
24 | #![allow(unused_imports)]
25 |
26 | use frame_support::{traits::Get, weights::Weight};
27 | use sp_std::marker::PhantomData;
28 |
29 | /// Weight functions for `pallet_balances`.
30 | pub struct WeightInfo(PhantomData);
31 | impl pallet_balances::WeightInfo for WeightInfo {
32 | // Storage: System Account (r:2 w:2)
33 | fn transfer() -> Weight {
34 | // Minimum execution time: 90_268 nanoseconds.
35 | Weight::from_ref_time(91_458_000)
36 | .saturating_add(T::DbWeight::get().reads(2))
37 | .saturating_add(T::DbWeight::get().writes(2))
38 | }
39 | // Storage: System Account (r:1 w:1)
40 | fn transfer_keep_alive() -> Weight {
41 | // Minimum execution time: 57_569 nanoseconds.
42 | Weight::from_ref_time(58_360_000)
43 | .saturating_add(T::DbWeight::get().reads(1))
44 | .saturating_add(T::DbWeight::get().writes(1))
45 | }
46 | // Storage: System Account (r:1 w:1)
47 | fn set_balance_creating() -> Weight {
48 | // Minimum execution time: 40_240 nanoseconds.
49 | Weight::from_ref_time(40_927_000)
50 | .saturating_add(T::DbWeight::get().reads(1))
51 | .saturating_add(T::DbWeight::get().writes(1))
52 | }
53 | // Storage: System Account (r:1 w:1)
54 | fn set_balance_killing() -> Weight {
55 | // Minimum execution time: 44_827 nanoseconds.
56 | Weight::from_ref_time(46_046_000)
57 | .saturating_add(T::DbWeight::get().reads(1))
58 | .saturating_add(T::DbWeight::get().writes(1))
59 | }
60 | // Storage: System Account (r:3 w:3)
61 | fn force_transfer() -> Weight {
62 | // Minimum execution time: 90_511 nanoseconds.
63 | Weight::from_ref_time(91_474_000)
64 | .saturating_add(T::DbWeight::get().reads(3))
65 | .saturating_add(T::DbWeight::get().writes(3))
66 | }
67 | // Storage: System Account (r:1 w:1)
68 | fn transfer_all() -> Weight {
69 | // Minimum execution time: 68_050 nanoseconds.
70 | Weight::from_ref_time(68_922_000)
71 | .saturating_add(T::DbWeight::get().reads(1))
72 | .saturating_add(T::DbWeight::get().writes(1))
73 | }
74 | // Storage: System Account (r:1 w:1)
75 | fn force_unreserve() -> Weight {
76 | // Minimum execution time: 35_058 nanoseconds.
77 | Weight::from_ref_time(36_281_000)
78 | .saturating_add(T::DbWeight::get().reads(1))
79 | .saturating_add(T::DbWeight::get().writes(1))
80 | }
81 | }
82 |
--------------------------------------------------------------------------------