├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── config.json ├── doc └── rust-setup.md ├── docker-compose.yml ├── file_header.txt ├── node ├── Cargo.toml ├── build.rs ├── specs │ └── statemint.json └── src │ ├── chain_spec.rs │ ├── cli.rs │ ├── command.rs │ ├── lib.rs │ ├── main.rs │ └── service.rs ├── pallets └── collator-selection │ ├── Cargo.toml │ ├── README.md │ └── src │ ├── benchmarking.rs │ ├── lib.rs │ ├── mock.rs │ ├── tests.rs │ └── weights.rs ├── polkadot-launch ├── .gitignore ├── .prettierrc.json ├── LICENSE ├── README.md ├── default.nix ├── package.json ├── shell.nix ├── src │ ├── check.ts │ ├── index.ts │ ├── parachain.ts │ ├── rpc.ts │ ├── spawn.ts │ ├── spec.ts │ └── types.d.ts ├── tsconfig.json ├── yarn.lock └── yarn.nix ├── runtime ├── common │ ├── Cargo.toml │ └── src │ │ ├── impls.rs │ │ └── lib.rs ├── statemine │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── constants.rs │ │ ├── lib.rs │ │ └── weights │ │ ├── mod.rs │ │ ├── pallet_assets.rs │ │ ├── pallet_balances.rs │ │ ├── pallet_collator_selection.rs │ │ ├── pallet_multisig.rs │ │ ├── pallet_proxy.rs │ │ ├── pallet_timestamp.rs │ │ └── pallet_utility.rs ├── statemint │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── constants.rs │ │ ├── lib.rs │ │ └── weights │ │ ├── mod.rs │ │ ├── pallet_assets.rs │ │ ├── pallet_balances.rs │ │ ├── pallet_collator_selection.rs │ │ ├── pallet_multisig.rs │ │ ├── pallet_proxy.rs │ │ ├── pallet_timestamp.rs │ │ └── pallet_utility.rs └── westmint │ ├── Cargo.toml │ ├── build.rs │ └── src │ ├── constants.rs │ ├── lib.rs │ └── weights │ ├── mod.rs │ ├── pallet_assets.rs │ ├── pallet_balances.rs │ ├── pallet_collator_selection.rs │ ├── pallet_multisig.rs │ ├── pallet_proxy.rs │ ├── pallet_timestamp.rs │ └── pallet_utility.rs └── scripts ├── benchmarks.sh ├── generate_keys ├── keys.js ├── package.json └── yarn.lock └── init.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/macos,rust 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=macos,rust 3 | 4 | ### macOS ### 5 | # General 6 | .DS_Store 7 | .AppleDouble 8 | .LSOverride 9 | 10 | # Icon must end with two \r 11 | Icon 12 | 13 | 14 | # Thumbnails 15 | ._* 16 | 17 | # Files that might appear in the root of a volume 18 | .DocumentRevisions-V100 19 | .fseventsd 20 | .Spotlight-V100 21 | .TemporaryItems 22 | .Trashes 23 | .VolumeIcon.icns 24 | .com.apple.timemachine.donotpresent 25 | 26 | # Directories potentially created on remote AFP share 27 | .AppleDB 28 | .AppleDesktop 29 | Network Trash Folder 30 | Temporary Items 31 | .apdisk 32 | 33 | ### Rust ### 34 | # Generated by Cargo 35 | # will have compiled files and executables 36 | /target/ 37 | 38 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 39 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 40 | # Cargo.lock 41 | 42 | # End of https://www.toptal.com/developers/gitignore/api/macos,rust 43 | 44 | dist 45 | *.wasm 46 | *.log 47 | 48 | # Local Parachains files 49 | *-genesis 50 | *-wasm 51 | *-local.json 52 | *-raw.json 53 | 54 | # Polkadot Launch files 55 | configLocal.json 56 | *.json.json 57 | node_modules 58 | polkadot 59 | .vscode 60 | 61 | # Ignore binaries that may be added for creating a test network 62 | bin/ 63 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers 6 | pledge to making participation in our project and our community a harassment-free experience for 7 | everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, 8 | level of experience, nationality, personal appearance, race, religion, or sexual identity and 9 | orientation. 10 | 11 | ## Our Standards 12 | 13 | Examples of behavior that contributes to creating a positive environment include: 14 | 15 | * Using welcoming and inclusive language 16 | * Being respectful of differing viewpoints and experiences 17 | * Gracefully accepting constructive criticism 18 | * Focusing on what is best for the community 19 | * Showing empathy towards other community members 20 | 21 | Examples of unacceptable behavior by participants include: 22 | 23 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 24 | * Trolling, insulting/derogatory comments, and personal or political attacks 25 | * Public or private harassment 26 | * Publishing others' private information, such as a physical or electronic address, without 27 | explicit permission 28 | * Other conduct which could reasonably be considered inappropriate in a professional setting 29 | 30 | ### Facilitation, Not Strongarming 31 | 32 | We recognise that this software is merely a tool for users to create and maintain their blockchain 33 | of preference. We see that blockchains are naturally community platforms with users being the 34 | ultimate decision makers. We assert that good software will maximise user agency by facilitate 35 | user-expression on the network. As such: 36 | 37 | * This project will strive to give users as much choice as is both reasonable and possible over 38 | what protocol they adhere to; but 39 | * use of the project's technical forums, commenting systems, pull requests and issue trackers as a 40 | means to express individual protocol preferences is forbidden. 41 | 42 | ## Our Responsibilities 43 | 44 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are 45 | expected to take appropriate and fair corrective action in response to any instances of 46 | unacceptable behavior. 47 | 48 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, 49 | code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or 50 | to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, 51 | threatening, offensive, or harmful. 52 | 53 | ## Scope 54 | 55 | This Code of Conduct applies both within project spaces and in public spaces when an individual is 56 | representing the project or its community. Examples of representing a project or community include 57 | using an official project e-mail address, posting via an official social media account, or acting 58 | as an appointed representative at an online or offline event. Representation of a project may be 59 | further defined and clarified by project maintainers. 60 | 61 | ## Enforcement 62 | 63 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting 64 | the project team at . The project team will review and investigate all complaints, 65 | and will respond in a way that it deems appropriate to the circumstances. The project team is 66 | obligated to maintain confidentiality with regard to the reporter of an incident. Further details 67 | of specific enforcement policies may be posted separately. 68 | 69 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face 70 | temporary or permanent repercussions as determined by other members of the project's leadership. 71 | 72 | ## Attribution 73 | 74 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available 75 | at https://contributor-covenant.org/version/1/4 76 | 77 | [homepage]: https://contributor-covenant.org 78 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | `Statemint` is an **OPENISH Open Source Project** 4 | 5 | ## What? 6 | 7 | Individuals making significant and valuable contributions are given commit-access to a project to 8 | contribute as they see fit. A project is more like an open wiki than a standard guarded open source 9 | project. 10 | 11 | ## Rules 12 | 13 | There are a few basic ground-rules for contributors (including the maintainer(s) of the project): 14 | 15 | - **No `--force` pushes** or modifying the Git history in any way. If you need to rebase, ensure 16 | you do it in your own repo. 17 | - **Non-master branches**, prefixed with a short name moniker (e.g. `gav-my-feature`) must be used 18 | for ongoing work. 19 | - **All modifications** must be made in a **pull-request** to solicit feedback from other 20 | contributors. 21 | - A pull-request _must not be merged until CI_ has finished successfully. 22 | - Contributors should adhere to the 23 | [house coding style](https://github.com/paritytech/polkadot/wiki/Style-Guide). 24 | 25 | #### Merging pull requests once CI is successful: 26 | 27 | - A pull request that does not alter any logic (e.g. comments, dependencies, docs) may be tagged 28 | [`insubstantial`](https://github.com/paritytech/statemint/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+label%3AA2-insubstantial) 29 | and merged by its author. 30 | - A pull request with no large change to logic that is an urgent fix may be merged after a 31 | non-author contributor has reviewed it well. 32 | - All other PRs should sit for 48 hours with the 33 | [`pleasereview`](https://github.com/paritytech/statemint/pulls?q=is%3Apr+is%3Aopen+label%3AA0-pleasereview) 34 | tag in order to garner feedback. 35 | - No PR should be merged until all reviews' comments are addressed. 36 | 37 | #### Reviewing pull requests: 38 | 39 | When reviewing a pull request, the end-goal is to suggest useful changes to the author. Reviews should finish with approval unless there are issues that would result in: 40 | 41 | - Buggy behaviour. 42 | - Undue maintenance burden. 43 | - Breaking with house coding style. 44 | - Pessimisation (i.e. reduction of speed as measured in the projects benchmarks). 45 | - Feature reduction (i.e. it removes some aspect of functionality that a significant minority of 46 | users rely on). 47 | - Uselessness (i.e. it does not strictly add a feature or fix a known issue). 48 | 49 | #### Reviews may not be used as an effective veto for a PR because: 50 | 51 | - There exists a somewhat cleaner/better/faster way of accomplishing the same feature/fix. 52 | - It does not fit well with some other contributors' longer-term vision for the project. 53 | 54 | ## Releases 55 | 56 | Declaring formal releases remains the prerogative of the project maintainer(s). 57 | 58 | ## Changes to this arrangement 59 | 60 | This is an experiment and feedback is welcome! This document may also be subject to pull-requests 61 | or changes by contributors where you believe you have something valuable to add or change. 62 | 63 | ## Heritage 64 | 65 | These contributing guidelines are modified from the "OPEN Open Source Project" guidelines for the 66 | Level project: https://github.com/Level/community/blob/master/CONTRIBUTING.md 67 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [profile.release] 2 | panic = 'unwind' 3 | 4 | [workspace] 5 | members = [ 6 | 'node', 7 | 'pallets/collator-selection', 8 | 'runtime/statemint', 9 | 'runtime/statemine', 10 | 'runtime/westmint', 11 | ] 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Statemint 2 | 3 | > **Note: Statemint was moved into the [Cumulus repo](https://github.com/paritytech/cumulus). 4 | > Please check there for the current version** 5 | 6 | Implementation of _Statemint,_ a blockchain to support generic assets in the Polkadot and Kusama 7 | networks. 8 | 9 | Statemint will allow users to: 10 | 11 | - Deploy promise-backed assets with a DOT/KSM deposit. 12 | - Set admin roles for an `AssetId` to mint, freeze, thaw, and burn tokens. 13 | - Register assets as "self-sufficient" if the Relay Chain agrees, i.e. the ability for an account 14 | to exist without DOT/KSM so long as it maintains a minimum token balance. 15 | - Pay fees using asset balances. 16 | - Transfer (and approve transfer) assets. 17 | 18 | Statemint must stay fully aligned with the Relay Chain it is connected to. As such, it will accept 19 | the Relay Chain's governance origins as its own. 20 | 21 | ### F.A.Q. 22 | 23 | As Statemint will likely be one of the first common good parachains, we've received a lot of 24 | questions about how it will function and its place in the ecosystem. 25 | 26 | #### Will Statemint be on Kusama and Polkadot? 27 | 28 | Yes, Statemint is the Polkadot parachain, while _Statemine_ is the Kusama parachain. All of the 29 | other answers apply equally to Statemine (but will reference Statemint/Polkadot for brevity). 30 | 31 | #### How will Statemint get a parachain slot? 32 | 33 | We are building Statemint with the intent to make a governance proposal for a parachain slot. The 34 | proposal will go to referendum where Polkadot's stakeholders will decide. For more info on common 35 | good parachains, see [this blog 36 | article](https://polkadot.network/common-good-parachains-an-introduction-to-governance-allocated-parachain-slots/). 37 | 38 | #### How will I use Statemint? 39 | 40 | Statemint will be a parachain that uses the DOT token as its native token, i.e. represented in its 41 | instance of the Balance pallet. In order to make transactions on Statemint, you will need to first 42 | send some DOT from your Relay Chain account to your Statemint account using a cross-chain message. 43 | Addresses on Statemint will use the same SS58 prefix as its Relay Chain. Note that this might not 44 | be "end user friendly" until some user interfaces handle the cross-chain message. 45 | 46 | One way to do this would be to have a back end that connects to both the Relay Chain and Statemint. 47 | When the user tries to make a transaction on Statemint, the app would realize that it needed a 48 | balance there and handle sending the cross-chain message to transfer balances, waiting for its 49 | success, and then broadcasting the Statemint transaction, all in one click for the user. If you 50 | want to contribute, building infrastructure and UIs that can handle applications with multi-chain 51 | back ends would be a great contribution, not only for Statemint. 52 | 53 | #### What will the fees be like? 54 | 55 | The deposits and fees in the Statemint runtime are set to 10% of the levels of the Relay Chain. 56 | That is, generally speaking, transaction fees should be approximately\* 1/10 of what they would be 57 | on the Relay Chain (and likewise for deposits such as proxy and multisig). The _existential 58 | deposit_ will also be 1/10 of its Relay Chain value. 59 | 60 | \* They will not be exactly 1/10. Parachains have lower weight limits per block than the Relay 61 | Chain, and fees change depending on block fullness. So if Statemint blocks are more full than the 62 | Relay Chain blocks for some period of time, the fees would be higher than 1/10 those of the Relay 63 | Chain. 64 | 65 | #### Can I run a collator? 66 | 67 | Yes, Statemint will have very simple logic that will allow one to become a collator for a fixed 68 | bond. Note that there are no inflationary rewards for collators; they only receive a portion of the 69 | transaction fees. At the time of this writing, Aura is not yet working for parachains, so please be 70 | patient as we scale up the number of collator slots with this new capability. 71 | 72 | #### Will Statemint support smart contracts? 73 | 74 | No, Statemint supports specialized logic for handling assets. It will not provide any smart 75 | contract interface. 76 | 77 | #### Will Statemint support NFTs? 78 | 79 | Eventually, yes, but probably not in the first version to hit Kusama and Polkadot. See the [token 80 | tracking issue](https://github.com/paritytech/substrate/issues/8453) for the roadmap on support for 81 | fungible and non-fungible features. 82 | 83 | #### Will Statemint compete with {Smart contract chain, NFT chain, etc.}? 84 | 85 | Statemint is a very basic chain that only provides an interface for representing assets and some 86 | primitive functions for handling them. Tokens tend to bloat smart contract chains with contract 87 | storage and metering transactions that have known complexity. By encoding this logic directly into 88 | the Statemint runtime, token storage and actions can happen faster and cheaper. 89 | 90 | This allows other chains to specialize in what they are good at, and not be weighed down by token 91 | operations. Smart contract chains specialize in allowing anyone to deploy untrusted code to a 92 | global system. NFT platforms specialize in their ability to foster communities, marketplaces, and 93 | galleries. Statemint can store the low-level interfaces for tokens, while other systems can write 94 | the logic to interact with them. 95 | 96 | For example, operations from contract execution could trigger a cross-chain message that lets 97 | Statemint handle the token transactions that are a result of the contract execution. This will 98 | reduce wasted gas and keep fees lower on the smart contract chain. Likewise, an NFT chain or 99 | platform can focus on its business logic of representing the interactions of its community members 100 | and what the conditions are for transferring an NFT, but the data structures and primitive 101 | functionality of NFTs can be on Statemint for multiple communities to use. 102 | 103 | #### How will Statemint be governed? 104 | 105 | As a common good parachain, Statemint must stay fully aligned with the Relay Chain. Upgrades to 106 | Statemint will require the Relay Chain's "root origin", i.e. a referendum. Some of the other logic 107 | (like privileged asset functionality) will defer to the Relay Chain's Council, which can always be 108 | superceded by root. 109 | 110 | ## Contributing 111 | 112 | - [Contribution Guidelines](CONTRIBUTING.md) 113 | - [Code of Conduct](CODE_OF_CONDUCT.md) 114 | 115 | ## License 116 | 117 | Statemint is licensed under [Apache 2](LICENSE). 118 | 119 | ### Temp 120 | 121 | * Pointed the repo towards `statemint` branch. 122 | 123 | __Commits:__ 124 | ``` 125 | "git+https://github.com/paritytech/substrate.git?branch=statemint#3f110196163b5ec03bac5ee188d60bedf3ebd91d" 126 | "git+https://github.com/paritytech/polkadot?branch=statemint#fe0575d96ec442514884ad8e9e230c2aabdfefa2" 127 | "git+https://github.com/paritytech/cumulus.git?branch=statemint#a786066f23afc071c5990ea3f1c80aa2c4010ac8" 128 | "git+https://github.com/paritytech/grandpa-bridge-gadget?branch=statemint#c4a8fed8a21ac55aa4a6a0020d14b3dae0ba32bd" 129 | ``` 130 | 131 | ### Launching a local test network 132 | 133 | Consult the instructions in [_polkadot-launch/README.md_](polkadot-launch/README.md) 134 | 135 | ### Benchmarks 136 | 137 | * TODO 138 | - [] choose steps and repeats 139 | - [] run benchmarks on proper machine specs 140 | 141 | * running 142 | * from root run ```./scripts/benchmarks``` 143 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "relaychain": { 3 | "bin": "./bin/polkadot", 4 | "chain": "rococo-local", 5 | "nodes": [ 6 | { 7 | "name": "alice", 8 | "wsPort": 9944, 9 | "port": 30444 10 | }, 11 | { 12 | "name": "bob", 13 | "wsPort": 9955, 14 | "port": 30555 15 | } 16 | ], 17 | "runtime_genesis_config": { 18 | "parachainsConfiguration": { 19 | "config": { 20 | "validation_upgrade_frequency": 1, 21 | "validation_upgrade_delay": 1 22 | } 23 | } 24 | } 25 | }, 26 | "parachains": [ 27 | { 28 | "bin": "./target/release/statemint", 29 | "chain": "statemint-dev", 30 | "id": "1000", 31 | "balance": "1000000000000000000000", 32 | "nodes": [ 33 | { 34 | "name": "alice", 35 | "wsPort": 9988, 36 | "port": 31200, 37 | "flags": ["-laura=debug", "--", "--execution=wasm"] 38 | } 39 | ] 40 | } 41 | ], 42 | "simpleParachains": [ 43 | ], 44 | "hrmpChannels": [], 45 | "types": { 46 | "BridgedBlockHash": "H256" 47 | }, 48 | "finalization": false 49 | } 50 | -------------------------------------------------------------------------------- /doc/rust-setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation 3 | --- 4 | 5 | This page will guide you through the steps needed to prepare a computer for development with the 6 | Substrate Node Template. Since Substrate is built with 7 | [the Rust programming language](https://www.rust-lang.org/), the first thing you will need to do is 8 | prepare the computer for Rust development - these steps will vary based on the computer's operating 9 | system. Once Rust is configured, you will use its toolchains to interact with Rust projects; the 10 | commands for Rust's toolchains will be the same for all supported, Unix-based operating systems. 11 | 12 | ## Unix-Based Operating Systems 13 | 14 | Substrate development is easiest on Unix-based operating systems like macOS or Linux. The examples 15 | in the Substrate [Tutorials](https://substrate.dev/tutorials) and [Recipes](https://substrate.dev/recipes/) 16 | use Unix-style terminals to demonstrate how to interact with Substrate from the command line. 17 | 18 | ### macOS 19 | 20 | Open the Terminal application and execute the following commands: 21 | 22 | ```bash 23 | # Install Homebrew if necessary https://brew.sh/ 24 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 25 | 26 | # Make sure Homebrew is up-to-date, install openssl and cmake 27 | brew update 28 | brew install openssl cmake 29 | ``` 30 | 31 | ### Ubuntu/Debian 32 | 33 | Use a terminal shell to execute the following commands: 34 | 35 | ```bash 36 | sudo apt update 37 | # May prompt for location information 38 | sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl 39 | ``` 40 | 41 | ### Arch Linux 42 | 43 | Run these commands from a terminal: 44 | 45 | ```bash 46 | pacman -Syu --needed --noconfirm cmake gcc openssl-1.0 pkgconf git clang 47 | export OPENSSL_LIB_DIR="/usr/lib/openssl-1.0" 48 | export OPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0" 49 | ``` 50 | 51 | ### Fedora/RHEL/CentOS 52 | 53 | Use a terminal to run the following commands: 54 | 55 | ```bash 56 | # Update 57 | sudo dnf update 58 | # Install packages 59 | sudo dnf install cmake pkgconfig rocksdb rocksdb-devel llvm git libcurl libcurl-devel curl-devel clang 60 | ``` 61 | 62 | ## Rust Developer Environment 63 | 64 | This project uses [`rustup`](https://rustup.rs/) to help manage the Rust toolchain. First install 65 | and configure `rustup`: 66 | 67 | ```bash 68 | # Install 69 | curl https://sh.rustup.rs -sSf | sh 70 | # Configure 71 | source ~/.cargo/env 72 | ``` 73 | 74 | Finally, configure the Rust toolchain: 75 | 76 | ```bash 77 | rustup default stable 78 | rustup update nightly 79 | rustup update stable 80 | rustup target add wasm32-unknown-unknown --toolchain nightly 81 | ``` 82 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | 3 | services: 4 | dev: 5 | container_name: node-template 6 | image: paritytech/ci-linux:974ba3ac-20201006 7 | working_dir: /var/www/node-template 8 | ports: 9 | - "9944:9944" 10 | environment: 11 | - CARGO_HOME=/var/www/node-template/.cargo 12 | volumes: 13 | - .:/var/www/node-template 14 | - type: bind 15 | source: ./.local 16 | target: /root/.local 17 | command: bash -c "cargo build --release && ./target/release/node-template --dev --ws-external" 18 | -------------------------------------------------------------------------------- /file_header.txt: -------------------------------------------------------------------------------- 1 | // Copyright 2017-2020 Parity Technologies (UK) Ltd. 2 | // This file is part of Polkadot. 3 | 4 | // Statemint is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | 9 | // Statemint is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | 14 | // You should have received a copy of the GNU General Public License 15 | // along with Statemint. If not, see . 16 | -------------------------------------------------------------------------------- /node/Cargo.toml: -------------------------------------------------------------------------------- 1 | [[bin]] 2 | name = 'statemint' 3 | 4 | [package] 5 | authors = ['Anonymous'] 6 | build = 'build.rs' 7 | description = 'Statemint collator node.' 8 | edition = '2018' 9 | homepage = 'https://substrate.dev' 10 | license = 'Apache-2.0' 11 | name = 'statemint' 12 | repository = 'https://github.com/paritytech/statemint' 13 | version = '1.0.0' 14 | [package.metadata.docs.rs] 15 | targets = ['x86_64-unknown-linux-gnu'] 16 | 17 | [dependencies] 18 | derive_more = '0.15.0' 19 | log = "0.4.13" 20 | codec = { package = 'parity-scale-codec', version = '2.0.0' } 21 | structopt = "0.3.8" 22 | serde = { version = "1.0.119", features = ["derive"] } 23 | hex-literal = "0.2.1" 24 | async-trait = "0.1.42" 25 | futures = "0.3.14" 26 | 27 | # RPC related dependencies 28 | jsonrpc-core = "15.1.0" 29 | 30 | [dependencies.frame-benchmarking] 31 | git = 'https://github.com/paritytech/substrate.git' 32 | branch = "master" 33 | version = '3.0.0' 34 | 35 | [dependencies.frame-benchmarking-cli] 36 | git = 'https://github.com/paritytech/substrate.git' 37 | branch = "master" 38 | version = '3.0.0' 39 | 40 | [dependencies.statemint-runtime] 41 | path = '../runtime/statemint' 42 | version = '1.0.0' 43 | 44 | [dependencies.statemine-runtime] 45 | path = '../runtime/statemine' 46 | version = '1.0.0' 47 | 48 | [dependencies.westmint-runtime] 49 | path = '../runtime/westmint' 50 | version = '1.0.0' 51 | 52 | [dependencies.runtime-common] 53 | path = '../runtime/common' 54 | version = "0.8.30" 55 | 56 | [dependencies.pallet-transaction-payment-rpc] 57 | git = 'https://github.com/paritytech/substrate.git' 58 | branch = "master" 59 | version = '3.0.0' 60 | 61 | [dependencies.sc-basic-authorship] 62 | git = 'https://github.com/paritytech/substrate.git' 63 | branch = "master" 64 | version = '0.9.0' 65 | 66 | [dependencies.sc-chain-spec] 67 | git = 'https://github.com/paritytech/substrate.git' 68 | branch = "master" 69 | version = '3.0.0' 70 | 71 | [dependencies.sc-cli] 72 | features = ['wasmtime'] 73 | git = 'https://github.com/paritytech/substrate.git' 74 | branch = "master" 75 | version = '0.9.0' 76 | 77 | [dependencies.sc-client-api] 78 | git = 'https://github.com/paritytech/substrate.git' 79 | branch = "master" 80 | version = '3.0.0' 81 | 82 | [dependencies.sc-consensus] 83 | git = 'https://github.com/paritytech/substrate.git' 84 | branch = "master" 85 | version = '0.9.0' 86 | 87 | [dependencies.sc-executor] 88 | features = ['wasmtime'] 89 | git = 'https://github.com/paritytech/substrate.git' 90 | branch = "master" 91 | version = '0.9.0' 92 | 93 | [dependencies.sc-keystore] 94 | git = 'https://github.com/paritytech/substrate.git' 95 | branch = "master" 96 | version = '3.0.0' 97 | 98 | [dependencies.sc-rpc] 99 | git = 'https://github.com/paritytech/substrate.git' 100 | branch = "master" 101 | version = '3.0.0' 102 | 103 | [dependencies.sc-rpc-api] 104 | git = 'https://github.com/paritytech/substrate.git' 105 | branch = "master" 106 | version = '0.9.0' 107 | 108 | [dependencies.sc-service] 109 | features = ['wasmtime'] 110 | git = 'https://github.com/paritytech/substrate.git' 111 | branch = "master" 112 | version = '0.9.0' 113 | 114 | [dependencies.sc-telemetry] 115 | git = 'https://github.com/paritytech/substrate.git' 116 | branch = "master" 117 | version = '3.0.0' 118 | 119 | [dependencies.sc-transaction-pool] 120 | git = 'https://github.com/paritytech/substrate.git' 121 | branch = "master" 122 | version = '3.0.0' 123 | 124 | [dependencies.sc-tracing] 125 | git = 'https://github.com/paritytech/substrate.git' 126 | branch = "master" 127 | version = '3.0.0' 128 | 129 | [dependencies.sp-api] 130 | git = 'https://github.com/paritytech/substrate.git' 131 | branch = "master" 132 | version = '3.0.0' 133 | 134 | [dependencies.sp-consensus-aura] 135 | git = 'https://github.com/paritytech/substrate.git' 136 | branch = "master" 137 | version = '0.9.0' 138 | 139 | [dependencies.sp-block-builder] 140 | git = 'https://github.com/paritytech/substrate.git' 141 | branch = "master" 142 | version = '3.0.0' 143 | 144 | [dependencies.sp-blockchain] 145 | git = 'https://github.com/paritytech/substrate.git' 146 | branch = "master" 147 | version = '3.0.0' 148 | 149 | [dependencies.sp-consensus] 150 | git = 'https://github.com/paritytech/substrate.git' 151 | branch = "master" 152 | version = '0.9.0' 153 | 154 | [dependencies.sp-core] 155 | git = 'https://github.com/paritytech/substrate.git' 156 | branch = "master" 157 | version = '3.0.0' 158 | 159 | [dependencies.sp-inherents] 160 | git = 'https://github.com/paritytech/substrate.git' 161 | branch = "master" 162 | version = '3.0.0' 163 | 164 | [dependencies.sp-offchain] 165 | git = 'https://github.com/paritytech/substrate.git' 166 | branch = "master" 167 | version = '3.0.0' 168 | 169 | [dependencies.sp-runtime] 170 | git = 'https://github.com/paritytech/substrate.git' 171 | branch = "master" 172 | version = '3.0.0' 173 | 174 | [dependencies.sp-session] 175 | git = 'https://github.com/paritytech/substrate.git' 176 | branch = "master" 177 | version = '3.0.0' 178 | 179 | [dependencies.sp-timestamp] 180 | git = 'https://github.com/paritytech/substrate.git' 181 | branch = "master" 182 | version = '3.0.0' 183 | 184 | [dependencies.sp-transaction-pool] 185 | git = 'https://github.com/paritytech/substrate.git' 186 | branch = "master" 187 | version = '3.0.0' 188 | 189 | [dependencies.substrate-frame-rpc-system] 190 | git = 'https://github.com/paritytech/substrate.git' 191 | branch = "master" 192 | version = '3.0.0' 193 | 194 | # Cumulus dependencies 195 | [dependencies.cumulus-client-cli] 196 | git = 'https://github.com/paritytech/cumulus.git' 197 | branch = "master" 198 | 199 | [dependencies.cumulus-client-consensus-common] 200 | git = 'https://github.com/paritytech/cumulus.git' 201 | branch = "master" 202 | 203 | [dependencies.cumulus-client-consensus-aura] 204 | git = 'https://github.com/paritytech/cumulus.git' 205 | branch = "master" 206 | 207 | [dependencies.cumulus-client-consensus-relay-chain] 208 | git = 'https://github.com/paritytech/cumulus.git' 209 | branch = "master" 210 | 211 | [dependencies.cumulus-client-collator] 212 | git = 'https://github.com/paritytech/cumulus.git' 213 | branch = "master" 214 | 215 | [dependencies.cumulus-client-network] 216 | git = 'https://github.com/paritytech/cumulus.git' 217 | branch = "master" 218 | 219 | [dependencies.cumulus-primitives-core] 220 | git = 'https://github.com/paritytech/cumulus.git' 221 | branch = "master" 222 | 223 | [dependencies.cumulus-primitives-parachain-inherent] 224 | git = 'https://github.com/paritytech/cumulus.git' 225 | branch = "master" 226 | 227 | [dependencies.cumulus-client-service] 228 | git = 'https://github.com/paritytech/cumulus.git' 229 | branch = "master" 230 | 231 | # Polkadot dependencies 232 | [dependencies.polkadot-primitives] 233 | git = "https://github.com/paritytech/polkadot" 234 | branch = "master" 235 | 236 | [dependencies.polkadot-service] 237 | git = "https://github.com/paritytech/polkadot" 238 | branch = "master" 239 | 240 | [dependencies.polkadot-cli] 241 | git = "https://github.com/paritytech/polkadot" 242 | branch = "master" 243 | 244 | [dependencies.polkadot-parachain] 245 | git = "https://github.com/paritytech/polkadot" 246 | branch = "master" 247 | 248 | [build-dependencies.substrate-build-script-utils] 249 | git = 'https://github.com/paritytech/substrate.git' 250 | branch = "master" 251 | version = '3.0.0' 252 | 253 | [features] 254 | default = [] 255 | runtime-benchmarks = [ 256 | 'polkadot-service/runtime-benchmarks', 257 | 'statemint-runtime/runtime-benchmarks', 258 | 'statemine-runtime/runtime-benchmarks', 259 | 'westmint-runtime/runtime-benchmarks', 260 | ] 261 | -------------------------------------------------------------------------------- /node/build.rs: -------------------------------------------------------------------------------- 1 | use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; 2 | 3 | fn main() { 4 | generate_cargo_keys(); 5 | 6 | rerun_if_git_head_changed(); 7 | } 8 | -------------------------------------------------------------------------------- /node/src/cli.rs: -------------------------------------------------------------------------------- 1 | use crate::chain_spec; 2 | use sc_cli; 3 | use std::path::PathBuf; 4 | use structopt::StructOpt; 5 | 6 | /// Sub-commands supported by the collator. 7 | #[derive(Debug, StructOpt)] 8 | pub enum Subcommand { 9 | /// Export the genesis state of the parachain. 10 | #[structopt(name = "export-genesis-state")] 11 | ExportGenesisState(ExportGenesisStateCommand), 12 | 13 | /// Export the genesis wasm of the parachain. 14 | #[structopt(name = "export-genesis-wasm")] 15 | ExportGenesisWasm(ExportGenesisWasmCommand), 16 | 17 | /// Build a chain specification. 18 | BuildSpec(sc_cli::BuildSpecCmd), 19 | 20 | /// Validate blocks. 21 | CheckBlock(sc_cli::CheckBlockCmd), 22 | 23 | /// Export blocks. 24 | ExportBlocks(sc_cli::ExportBlocksCmd), 25 | 26 | /// Export the state of a given block into a chain spec. 27 | ExportState(sc_cli::ExportStateCmd), 28 | 29 | /// Import blocks. 30 | ImportBlocks(sc_cli::ImportBlocksCmd), 31 | 32 | /// Remove the whole chain. 33 | PurgeChain(cumulus_client_cli::PurgeChainCmd), 34 | 35 | /// Revert the chain to a previous state. 36 | Revert(sc_cli::RevertCmd), 37 | 38 | /// The custom benchmark subcommmand benchmarking runtime pallets. 39 | #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")] 40 | Benchmark(frame_benchmarking_cli::BenchmarkCmd), 41 | } 42 | 43 | /// Command for exporting the genesis state of the parachain 44 | #[derive(Debug, StructOpt)] 45 | pub struct ExportGenesisStateCommand { 46 | /// Output file name or stdout if unspecified. 47 | #[structopt(parse(from_os_str))] 48 | pub output: Option, 49 | 50 | /// Id of the parachain this state is for. 51 | #[structopt(long)] 52 | pub parachain_id: Option, 53 | 54 | /// Write output in binary. Default is to write in hex. 55 | #[structopt(short, long)] 56 | pub raw: bool, 57 | 58 | /// The name of the chain for that the genesis state should be exported. 59 | #[structopt(long)] 60 | pub chain: Option, 61 | } 62 | 63 | /// Command for exporting the genesis wasm file. 64 | #[derive(Debug, StructOpt)] 65 | pub struct ExportGenesisWasmCommand { 66 | /// Output file name or stdout if unspecified. 67 | #[structopt(parse(from_os_str))] 68 | pub output: Option, 69 | 70 | /// Write output in binary. Default is to write in hex. 71 | #[structopt(short, long)] 72 | pub raw: bool, 73 | 74 | /// The name of the chain for that the genesis wasm file should be exported. 75 | #[structopt(long)] 76 | pub chain: Option, 77 | } 78 | 79 | #[derive(Debug, StructOpt)] 80 | #[structopt(settings = &[ 81 | structopt::clap::AppSettings::GlobalVersion, 82 | structopt::clap::AppSettings::ArgsNegateSubcommands, 83 | structopt::clap::AppSettings::SubcommandsNegateReqs, 84 | ])] 85 | pub struct Cli { 86 | #[structopt(subcommand)] 87 | pub subcommand: Option, 88 | 89 | #[structopt(flatten)] 90 | pub run: cumulus_client_cli::RunCmd, 91 | 92 | /// Relaychain arguments 93 | #[structopt(raw = true)] 94 | pub relaychain_args: Vec, 95 | } 96 | 97 | #[derive(Debug)] 98 | pub struct RelayChainCli { 99 | /// The actual relay chain cli object. 100 | pub base: polkadot_cli::RunCmd, 101 | 102 | /// Optional chain id that should be passed to the relay chain. 103 | pub chain_id: Option, 104 | 105 | /// The base path that should be used by the relay chain. 106 | pub base_path: Option, 107 | } 108 | 109 | impl RelayChainCli { 110 | /// Parse the relay chain CLI parameters using the para chain `Configuration`. 111 | pub fn new<'a>( 112 | para_config: &sc_service::Configuration, 113 | relay_chain_args: impl Iterator, 114 | ) -> Self { 115 | let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec); 116 | let chain_id = extension.map(|e| e.relay_chain.clone()); 117 | let base_path = para_config 118 | .base_path 119 | .as_ref() 120 | .map(|x| x.path().join("polkadot")); 121 | Self { 122 | base_path, 123 | chain_id, 124 | base: polkadot_cli::RunCmd::from_iter(relay_chain_args), 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /node/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod chain_spec; 2 | pub mod service; 3 | -------------------------------------------------------------------------------- /node/src/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Statemint CLI 17 | #![warn(missing_docs)] 18 | 19 | mod chain_spec; 20 | #[macro_use] 21 | mod service; 22 | mod cli; 23 | mod command; 24 | 25 | fn main() -> sc_cli::Result<()> { 26 | command::run() 27 | } 28 | -------------------------------------------------------------------------------- /pallets/collator-selection/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ['Anonymous'] 3 | description = 'parachain staking pallet.' 4 | edition = '2018' 5 | homepage = 'https://substrate.dev' 6 | license = 'Apache-2.0' 7 | name = 'pallet-collator-selection' 8 | readme = 'README.md' 9 | repository = 'https://github.com/paritytech/statemint' 10 | version = '3.0.0' 11 | 12 | [package.metadata.docs.rs] 13 | targets = ['x86_64-unknown-linux-gnu'] 14 | 15 | [dependencies] 16 | log = { version = "0.4.0", default-features = false } 17 | codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0' } 18 | serde = { version = "1.0.119", default-features = false } 19 | sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 20 | sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 21 | sp-staking = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 22 | frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 23 | frame-system = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 24 | pallet-authorship = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 25 | pallet-session = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 26 | 27 | frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 28 | 29 | [dev-dependencies] 30 | sp-core = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 31 | sp-io = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 32 | sp-tracing = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 33 | sp-runtime = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 34 | pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 35 | sp-consensus-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '0.9.0' } 36 | pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 37 | pallet-aura = { git = 'https://github.com/paritytech/substrate.git', branch = "master", version = '3.0.0' } 38 | 39 | [features] 40 | default = ['std'] 41 | runtime-benchmarks = [ 42 | 'frame-benchmarking', 43 | 'frame-support/runtime-benchmarks', 44 | 'frame-system/runtime-benchmarks', 45 | ] 46 | std = [ 47 | 'codec/std', 48 | 'log/std', 49 | 'sp-runtime/std', 50 | 'sp-staking/std', 51 | 'sp-std/std', 52 | 'frame-support/std', 53 | 'frame-system/std', 54 | 'frame-benchmarking/std', 55 | 'pallet-authorship/std', 56 | 'pallet-session/std', 57 | ] 58 | -------------------------------------------------------------------------------- /pallets/collator-selection/README.md: -------------------------------------------------------------------------------- 1 | License: Apache-2.0 -------------------------------------------------------------------------------- /pallets/collator-selection/src/benchmarking.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Benchmarking setup for pallet-collator-selection 17 | 18 | use super::*; 19 | 20 | #[allow(unused)] 21 | use crate::Pallet as CollatorSelection; 22 | use sp_std::prelude::*; 23 | use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller, account}; 24 | use frame_system::{RawOrigin, EventRecord}; 25 | use frame_support::{ 26 | assert_ok, 27 | traits::{Currency, Get, EnsureOrigin}, 28 | }; 29 | use pallet_authorship::EventHandler; 30 | use pallet_session::SessionManager; 31 | 32 | pub type BalanceOf = 33 | <::Currency as Currency<::AccountId>>::Balance; 34 | 35 | const SEED: u32 = 0; 36 | 37 | // TODO: remove if this is given in substrate commit. 38 | macro_rules! whitelist { 39 | ($acc:ident) => { 40 | frame_benchmarking::benchmarking::add_to_whitelist( 41 | frame_system::Account::::hashed_key_for(&$acc).into() 42 | ); 43 | }; 44 | } 45 | 46 | fn assert_last_event(generic_event: ::Event) { 47 | let events = frame_system::Pallet::::events(); 48 | let system_event: ::Event = generic_event.into(); 49 | // compare to the last event record 50 | let EventRecord { event, .. } = &events[events.len() - 1]; 51 | assert_eq!(event, &system_event); 52 | } 53 | 54 | fn register_candidates(count: u32) { 55 | let candidates = (0..count).map(|c| account("candidate", c, SEED)).collect::>(); 56 | assert!(>::get() > 0u32.into(), "Bond cannot be zero!"); 57 | for who in candidates { 58 | T::Currency::make_free_balance_be(&who, >::get() * 2u32.into()); 59 | >::register_as_candidate(RawOrigin::Signed(who).into()).unwrap(); 60 | } 61 | } 62 | 63 | benchmarks! { 64 | where_clause { where T: pallet_authorship::Config } 65 | 66 | set_invulnerables { 67 | let b in 1 .. T::MaxInvulnerables::get(); 68 | let new_invulnerables = (0..b).map(|c| account("candidate", c, SEED)).collect::>(); 69 | let origin = T::UpdateOrigin::successful_origin(); 70 | }: { 71 | assert_ok!( 72 | >::set_invulnerables(origin, new_invulnerables.clone()) 73 | ); 74 | } 75 | verify { 76 | assert_last_event::(Event::NewInvulnerables(new_invulnerables).into()); 77 | } 78 | 79 | set_desired_candidates { 80 | let max: u32 = 999; 81 | let origin = T::UpdateOrigin::successful_origin(); 82 | }: { 83 | assert_ok!( 84 | >::set_desired_candidates(origin, max.clone()) 85 | ); 86 | } 87 | verify { 88 | assert_last_event::(Event::NewDesiredCandidates(max).into()); 89 | } 90 | 91 | set_candidacy_bond { 92 | let bond: BalanceOf = T::Currency::minimum_balance() * 10u32.into(); 93 | let origin = T::UpdateOrigin::successful_origin(); 94 | }: { 95 | assert_ok!( 96 | >::set_candidacy_bond(origin, bond.clone()) 97 | ); 98 | } 99 | verify { 100 | assert_last_event::(Event::NewCandidacyBond(bond).into()); 101 | } 102 | 103 | // worse case is when we have all the max-candidate slots filled except one, and we fill that 104 | // one. 105 | register_as_candidate { 106 | let c in 1 .. T::MaxCandidates::get(); 107 | 108 | >::put(T::Currency::minimum_balance()); 109 | >::put(c + 1); 110 | register_candidates::(c); 111 | 112 | let caller: T::AccountId = whitelisted_caller(); 113 | let bond: BalanceOf = T::Currency::minimum_balance() * 2u32.into(); 114 | T::Currency::make_free_balance_be(&caller, bond.clone()); 115 | 116 | }: _(RawOrigin::Signed(caller.clone())) 117 | verify { 118 | assert_last_event::(Event::CandidateAdded(caller, bond / 2u32.into()).into()); 119 | } 120 | 121 | // worse case is the last candidate leaving. 122 | leave_intent { 123 | let c in 1 .. T::MaxCandidates::get(); 124 | >::put(T::Currency::minimum_balance()); 125 | >::put(c); 126 | register_candidates::(c); 127 | 128 | let leaving = >::get().last().unwrap().who.clone(); 129 | whitelist!(leaving); 130 | }: _(RawOrigin::Signed(leaving.clone())) 131 | verify { 132 | assert_last_event::(Event::CandidateRemoved(leaving).into()); 133 | } 134 | 135 | // worse case is paying a non-existing candidate account. 136 | note_author { 137 | >::put(T::Currency::minimum_balance()); 138 | T::Currency::make_free_balance_be( 139 | &>::account_id(), 140 | T::Currency::minimum_balance() * 4u32.into(), 141 | ); 142 | let author = account("author", 0, SEED); 143 | let new_block: T::BlockNumber = 10u32.into(); 144 | 145 | frame_system::Pallet::::set_block_number(new_block); 146 | assert!(T::Currency::free_balance(&author) == 0u32.into()); 147 | }: { 148 | as EventHandler<_, _>>::note_author(author.clone()) 149 | } verify { 150 | assert!(T::Currency::free_balance(&author) > 0u32.into()); 151 | assert_eq!(frame_system::Pallet::::block_number(), new_block); 152 | } 153 | 154 | // worse case is on new session. 155 | // TODO review this benchmark 156 | new_session { 157 | let r in 1 .. T::MaxCandidates::get(); 158 | let c in 1 .. T::MaxCandidates::get(); 159 | 160 | >::put(T::Currency::minimum_balance()); 161 | >::put(c); 162 | frame_system::Pallet::::set_block_number(0u32.into()); 163 | register_candidates::(c); 164 | 165 | let new_block: T::BlockNumber = 1800u32.into(); 166 | let zero_block: T::BlockNumber = 0u32.into(); 167 | let candidates = >::get(); 168 | 169 | let non_removals = c.saturating_sub(r); 170 | 171 | for i in 0..c { 172 | >::insert(candidates[i as usize].who.clone(), zero_block); 173 | } 174 | for i in 0..non_removals { 175 | >::insert(candidates[i as usize].who.clone(), new_block); 176 | } 177 | 178 | let pre_length = >::get().len(); 179 | frame_system::Pallet::::set_block_number(new_block); 180 | 181 | assert!(>::get().len() == c as usize); 182 | 183 | }: { 184 | as SessionManager<_>>::new_session(0) 185 | } verify { 186 | assert!(>::get().len() < pre_length); 187 | } 188 | } 189 | 190 | impl_benchmark_test_suite!(CollatorSelection, crate::mock::new_test_ext(), crate::mock::Test,); 191 | -------------------------------------------------------------------------------- /pallets/collator-selection/src/mock.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | use super::*; 17 | use crate as collator_selection; 18 | use sp_core::H256; 19 | use frame_support::{ 20 | parameter_types, ord_parameter_types, 21 | traits::{FindAuthor, GenesisBuild}, 22 | PalletId 23 | }; 24 | use sp_runtime::{ 25 | RuntimeAppPublic, 26 | traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, 27 | testing::{Header, UintAuthorityId}, 28 | }; 29 | use frame_system::{EnsureSignedBy}; 30 | use frame_system as system; 31 | 32 | type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; 33 | type Block = frame_system::mocking::MockBlock; 34 | 35 | // Configure a mock runtime to test the pallet. 36 | frame_support::construct_runtime!( 37 | pub enum Test where 38 | Block = Block, 39 | NodeBlock = Block, 40 | UncheckedExtrinsic = UncheckedExtrinsic, 41 | { 42 | System: frame_system::{Pallet, Call, Config, Storage, Event}, 43 | Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, 44 | Session: pallet_session::{Pallet, Call, Storage, Event, Config}, 45 | Aura: pallet_aura::{Pallet, Call, Storage, Config}, 46 | Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, 47 | CollatorSelection: collator_selection::{Pallet, Call, Storage, Event}, 48 | Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, 49 | } 50 | ); 51 | 52 | parameter_types! { 53 | pub const BlockHashCount: u64 = 250; 54 | pub const SS58Prefix: u8 = 42; 55 | } 56 | 57 | impl system::Config for Test { 58 | type BaseCallFilter = (); 59 | type BlockWeights = (); 60 | type BlockLength = (); 61 | type DbWeight = (); 62 | type Origin = Origin; 63 | type Call = Call; 64 | type Index = u64; 65 | type BlockNumber = u64; 66 | type Hash = H256; 67 | type Hashing = BlakeTwo256; 68 | type AccountId = u64; 69 | type Lookup = IdentityLookup; 70 | type Header = Header; 71 | type Event = Event; 72 | type BlockHashCount = BlockHashCount; 73 | type Version = (); 74 | type PalletInfo = PalletInfo; 75 | type AccountData = pallet_balances::AccountData; 76 | type OnNewAccount = (); 77 | type OnKilledAccount = (); 78 | type SystemWeightInfo = (); 79 | type SS58Prefix = SS58Prefix; 80 | type OnSetCode = (); 81 | } 82 | 83 | parameter_types! { 84 | pub const ExistentialDeposit: u64 = 5; 85 | } 86 | 87 | impl pallet_balances::Config for Test { 88 | type Balance = u64; 89 | type Event = Event; 90 | type DustRemoval = (); 91 | type ExistentialDeposit = ExistentialDeposit; 92 | type AccountStore = System; 93 | type WeightInfo = (); 94 | type MaxLocks = (); 95 | } 96 | 97 | pub struct Author4; 98 | impl FindAuthor for Author4 { 99 | fn find_author<'a, I>(_digests: I) -> Option 100 | where I: 'a + IntoIterator, 101 | { 102 | Some(4) 103 | } 104 | } 105 | 106 | impl pallet_authorship::Config for Test { 107 | type FindAuthor = Author4; 108 | type UncleGenerations = (); 109 | type FilterUncle = (); 110 | type EventHandler = CollatorSelection; 111 | } 112 | 113 | parameter_types! { 114 | pub const MinimumPeriod: u64 = 1; 115 | } 116 | 117 | impl pallet_timestamp::Config for Test { 118 | type Moment = u64; 119 | type OnTimestampSet = Aura; 120 | type MinimumPeriod = MinimumPeriod; 121 | type WeightInfo = (); 122 | } 123 | 124 | impl pallet_aura::Config for Test { 125 | type AuthorityId = sp_consensus_aura::sr25519::AuthorityId; 126 | } 127 | 128 | sp_runtime::impl_opaque_keys! { 129 | pub struct MockSessionKeys { 130 | // a key for aura authoring 131 | pub aura: UintAuthorityId, 132 | } 133 | } 134 | 135 | impl From for MockSessionKeys { 136 | fn from(aura: sp_runtime::testing::UintAuthorityId) -> Self { 137 | Self { aura } 138 | } 139 | } 140 | 141 | parameter_types! { 142 | pub static SessionHandlerCollators: Vec = vec![]; 143 | pub static SessionChangeBlock: u64 = 0; 144 | } 145 | 146 | pub struct TestSessionHandler; 147 | impl pallet_session::SessionHandler for TestSessionHandler { 148 | const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID]; 149 | fn on_genesis_session(keys: &[(u64, Ks)]) { 150 | SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) 151 | } 152 | fn on_new_session(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) { 153 | SessionChangeBlock::set(System::block_number()); 154 | dbg!(keys.len()); 155 | SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) 156 | } 157 | fn on_before_session_ending() {} 158 | fn on_disabled(_: usize) {} 159 | } 160 | 161 | parameter_types! { 162 | pub const Offset: u64 = 0; 163 | pub const Period: u64 = 10; 164 | } 165 | 166 | impl pallet_session::Config for Test { 167 | type Event = Event; 168 | type ValidatorId = ::AccountId; 169 | // we don't have stash and controller, thus we don't need the convert as well. 170 | type ValidatorIdOf = IdentityCollator; 171 | type ShouldEndSession = pallet_session::PeriodicSessions; 172 | type NextSessionRotation = pallet_session::PeriodicSessions; 173 | type SessionManager = CollatorSelection; 174 | type SessionHandler = TestSessionHandler; 175 | type Keys = MockSessionKeys; 176 | type DisabledValidatorsThreshold = (); 177 | type WeightInfo = (); 178 | } 179 | 180 | ord_parameter_types! { 181 | pub const RootAccount: u64 = 777; 182 | } 183 | 184 | parameter_types! { 185 | pub const PotId: PalletId = PalletId(*b"PotStake"); 186 | pub const MaxCandidates: u32 = 20; 187 | pub const MaxInvulnerables: u32 = 20; 188 | } 189 | 190 | impl Config for Test { 191 | type Event = Event; 192 | type Currency = Balances; 193 | type UpdateOrigin = EnsureSignedBy; 194 | type PotId = PotId; 195 | type MaxCandidates = MaxCandidates; 196 | type MaxInvulnerables = MaxInvulnerables; 197 | type KickThreshold = Period; 198 | type WeightInfo = (); 199 | } 200 | 201 | pub fn new_test_ext() -> sp_io::TestExternalities { 202 | sp_tracing::try_init_simple(); 203 | let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); 204 | let invulnerables = vec![1, 2]; 205 | let keys = invulnerables.iter().map(|i| 206 | ( 207 | *i, 208 | *i, 209 | MockSessionKeys { aura: UintAuthorityId(*i) }, 210 | ) 211 | ).collect::>(); 212 | 213 | let balances = pallet_balances::GenesisConfig:: { 214 | balances: vec![ 215 | (1, 100), 216 | (2, 100), 217 | (3, 100), 218 | (4, 100), 219 | (5, 100), 220 | ], 221 | }; 222 | let collator_selection = collator_selection::GenesisConfig:: { 223 | desired_candidates: 2, 224 | candidacy_bond: 10, 225 | invulnerables, 226 | }; 227 | let session = pallet_session::GenesisConfig:: { keys }; 228 | balances.assimilate_storage(&mut t).unwrap(); 229 | // collator selection must be initialized before session. 230 | collator_selection.assimilate_storage(&mut t).unwrap(); 231 | session.assimilate_storage(&mut t).unwrap(); 232 | 233 | t.into() 234 | } 235 | 236 | pub fn initialize_to_block(n: u64) { 237 | for i in System::block_number()+1..=n { 238 | System::set_block_number(i); 239 | >::on_initialize(i); 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /pallets/collator-selection/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 | 18 | #![allow(unused_parens)] 19 | #![allow(unused_imports)] 20 | 21 | use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; 22 | use sp_std::marker::PhantomData; 23 | 24 | // The weight info trait for `pallet_collator_selection`. 25 | pub trait WeightInfo { 26 | fn set_invulnerables(_b: u32) -> Weight; 27 | fn set_desired_candidates() -> Weight; 28 | fn set_candidacy_bond() -> Weight; 29 | fn register_as_candidate(_c: u32) -> Weight; 30 | fn leave_intent(_c: u32) -> Weight; 31 | fn note_author() -> Weight; 32 | fn new_session(_c: u32, _r: u32) -> Weight; 33 | } 34 | 35 | /// Weights for pallet_collator_selection using the Substrate node and recommended hardware. 36 | pub struct SubstrateWeight(PhantomData); 37 | impl WeightInfo for SubstrateWeight { 38 | fn set_invulnerables(b: u32, ) -> Weight { 39 | (18_563_000 as Weight) 40 | // Standard Error: 0 41 | .saturating_add((68_000 as Weight).saturating_mul(b as Weight)) 42 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 43 | } 44 | fn set_desired_candidates() -> Weight { 45 | (16_363_000 as Weight) 46 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 47 | } 48 | fn set_candidacy_bond() -> Weight { 49 | (16_840_000 as Weight) 50 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 51 | } 52 | fn register_as_candidate(c: u32, ) -> Weight { 53 | (71_196_000 as Weight) 54 | // Standard Error: 0 55 | .saturating_add((198_000 as Weight).saturating_mul(c as Weight)) 56 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 57 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 58 | } 59 | fn leave_intent(c: u32, ) -> Weight { 60 | (55_336_000 as Weight) 61 | // Standard Error: 0 62 | .saturating_add((151_000 as Weight).saturating_mul(c as Weight)) 63 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 64 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 65 | } 66 | fn note_author() -> Weight { 67 | (71_461_000 as Weight) 68 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 69 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 70 | } 71 | fn new_session(r: u32, c: u32, ) -> Weight { 72 | (0 as Weight) 73 | // Standard Error: 1_010_000 74 | .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) 75 | // Standard Error: 1_010_000 76 | .saturating_add((151_952_000 as Weight).saturating_mul(c as Weight)) 77 | .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) 78 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 79 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(r as Weight))) 80 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 81 | } 82 | } 83 | 84 | 85 | // For backwards compatibility and tests 86 | impl WeightInfo for () { 87 | fn set_invulnerables(b: u32, ) -> Weight { 88 | (18_563_000 as Weight) 89 | // Standard Error: 0 90 | .saturating_add((68_000 as Weight).saturating_mul(b as Weight)) 91 | .saturating_add(RocksDbWeight::get().writes(1 as Weight)) 92 | } 93 | fn set_desired_candidates() -> Weight { 94 | (16_363_000 as Weight) 95 | .saturating_add(RocksDbWeight::get().writes(1 as Weight)) 96 | } 97 | fn set_candidacy_bond() -> Weight { 98 | (16_840_000 as Weight) 99 | .saturating_add(RocksDbWeight::get().writes(1 as Weight)) 100 | } 101 | fn register_as_candidate(c: u32, ) -> Weight { 102 | (71_196_000 as Weight) 103 | // Standard Error: 0 104 | .saturating_add((198_000 as Weight).saturating_mul(c as Weight)) 105 | .saturating_add(RocksDbWeight::get().reads(4 as Weight)) 106 | .saturating_add(RocksDbWeight::get().writes(2 as Weight)) 107 | } 108 | fn leave_intent(c: u32, ) -> Weight { 109 | (55_336_000 as Weight) 110 | // Standard Error: 0 111 | .saturating_add((151_000 as Weight).saturating_mul(c as Weight)) 112 | .saturating_add(RocksDbWeight::get().reads(1 as Weight)) 113 | .saturating_add(RocksDbWeight::get().writes(2 as Weight)) 114 | } 115 | fn note_author() -> Weight { 116 | (71_461_000 as Weight) 117 | .saturating_add(RocksDbWeight::get().reads(3 as Weight)) 118 | .saturating_add(RocksDbWeight::get().writes(4 as Weight)) 119 | } 120 | fn new_session(r: u32, c: u32, ) -> Weight { 121 | (0 as Weight) 122 | // Standard Error: 1_010_000 123 | .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) 124 | // Standard Error: 1_010_000 125 | .saturating_add((151_952_000 as Weight).saturating_mul(c as Weight)) 126 | .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) 127 | .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 128 | .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(r as Weight))) 129 | .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /polkadot-launch/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | *.wasm 4 | *.log 5 | rococo-local.json 6 | rococo-local-raw.json 7 | configLocal.json 8 | bin 9 | -------------------------------------------------------------------------------- /polkadot-launch/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true 3 | } 4 | -------------------------------------------------------------------------------- /polkadot-launch/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Shawn Tabrizi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /polkadot-launch/README.md: -------------------------------------------------------------------------------- 1 | # polkadot-launch 2 | 3 | Simple CLI tool to launch a local [Polkadot](https://github.com/paritytech/polkadot/) test network. 4 | 5 | ## Notes 6 | 7 | - You must use node.js v14.x.x 8 | - MacOs users: make sure your machines firewall is disabled. Choose Apple menu > System Preferences, click Security & Privacy, then click Firewall and make sure it is off. 9 | - These instructions are adapted from the original polkadot-launch for quickly starting statemint. For the original README consult https://github.com/paritytech/polkadot-launch#readme 10 | 11 | ## Building binaries 12 | 13 | To use polkadot-launch, you need to have binary files for a `polkadot` relay chain and a 14 | `statemint` collator. 15 | 16 | You can generate these files by cloning the `statemint` branch of these projects and building them 17 | with the specific flags below: 18 | 19 | ```bash 20 | git clone -b statemint https://github.com/paritytech/polkadot 21 | cd polkadot 22 | cargo build --release 23 | ``` 24 | 25 | and in the root directory of this repo 26 | 27 | ```bash 28 | cargo build --release 29 | ``` 30 | 31 | ## Use 32 | 33 | ### Setting up config.json 34 | 35 | Modify the `config.json` in this repo's root to point to your polkadot binary built from the 36 | `statemint` branch: 37 | 38 | ```json 39 | { 40 | "relaychain": { 41 | "bin": "", 42 | ... 43 | } 44 | ... 45 | } 46 | ``` 47 | 48 | ### Start up polkadot-launch 49 | 50 | ```bash 51 | cd polkadot-launch 52 | yarn 53 | yarn start 54 | ``` 55 | 56 | ### Node logging 57 | 58 | Each node's `stdout` is piped to files in this directory: `alice.log`, `bob.log`, `charlie.log`, `9988.log`. 59 | 60 | ```bash 61 | cd polkadot-launch 62 | tail -f alice.log 63 | ``` 64 | -------------------------------------------------------------------------------- /polkadot-launch/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | pkgs.mkYarnPackage { 3 | name = "polkadot-launch"; 4 | src = builtins.filterSource 5 | (path: type: type != "directory" || baseNameOf path != "bin") 6 | ./.; 7 | buildPhase = '' 8 | yarn build 9 | ''; 10 | postInstall = '' 11 | chmod +x $out/bin/polkadot-launch 12 | ''; 13 | packageJSON = ./package.json; 14 | yarnLock = ./yarn.lock; 15 | yarnNix = ./yarn.nix; 16 | } 17 | -------------------------------------------------------------------------------- /polkadot-launch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "polkadot-launch", 3 | "version": "1.5.0", 4 | "main": "dist/index.js", 5 | "author": "Shawn Tabrizi ", 6 | "license": "MIT", 7 | "scripts": { 8 | "build": "tsc", 9 | "start": "yarn build && node dist/index.js ../config.json", 10 | "lint": "npx prettier --write ." 11 | }, 12 | "dependencies": { 13 | "@polkadot/api": "^4.11.1", 14 | "@polkadot/util": "^6.5.1", 15 | "@polkadot/util-crypto": "^6.5.1", 16 | "filter-console": "^0.1.1", 17 | "typescript": "^4.1.5", 18 | "yargs": "^15.4.1", 19 | "yarn": "^1.22.10" 20 | }, 21 | "files": [ 22 | "dist" 23 | ], 24 | "bin": { 25 | "polkadot-launch": "dist/index.js" 26 | }, 27 | "devDependencies": { 28 | "prettier": "2.2.1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /polkadot-launch/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | let 3 | polkadot-launch = pkgs.callPackage ./default.nix { }; 4 | in 5 | pkgs.mkShell { 6 | buildInputs = [ 7 | polkadot-launch 8 | ]; 9 | } 10 | -------------------------------------------------------------------------------- /polkadot-launch/src/check.ts: -------------------------------------------------------------------------------- 1 | // This function checks that the `config.json` file has all the expected properties. 2 | // It displays a unique error message and returns `false` for any detected issues. 3 | import { LaunchConfig } from "./types"; 4 | export function checkConfig(config: LaunchConfig) { 5 | if (!config) { 6 | return false; 7 | } 8 | 9 | if (!config.relaychain) { 10 | console.error("⚠ Missing `relaychain` object"); 11 | return false; 12 | } 13 | 14 | if (!config.relaychain.bin) { 15 | console.error("⚠ Missing `relaychain.bin`"); 16 | return false; 17 | } 18 | 19 | if (!config.relaychain.chain) { 20 | console.error("⚠ Missing `relaychain.chain`"); 21 | return false; 22 | } 23 | 24 | if (config.relaychain.nodes.length == 0) { 25 | console.error("⚠ No relaychain nodes defined"); 26 | return false; 27 | } 28 | 29 | for (const node of config.relaychain.nodes) { 30 | if (node.flags && node.flags.constructor !== Array) { 31 | console.error("⚠ Relay chain flags should be an array."); 32 | return false; 33 | } 34 | } 35 | 36 | if (!config.parachains) { 37 | console.error("⚠ Missing `parachains` object"); 38 | return false; 39 | } 40 | 41 | if (config.parachains.length >= config.relaychain.nodes.length) { 42 | console.error( 43 | "⚠ Must have the same or greater number of relaychain nodes than parachains." 44 | ); 45 | return false; 46 | } 47 | 48 | for (let parachain of config.parachains) { 49 | if (!parachain.nodes) { 50 | console.error("⚠ Missing parachain nodes"); 51 | return false; 52 | } 53 | } 54 | 55 | for (let parachain of config.parachains) { 56 | for (let node of parachain.nodes) { 57 | if (node.flags && node.flags.constructor !== Array) { 58 | console.error("⚠ Parachain flags should be an array."); 59 | return false; 60 | } 61 | } 62 | } 63 | 64 | return true; 65 | } 66 | -------------------------------------------------------------------------------- /polkadot-launch/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { 4 | startNode, 5 | startCollator, 6 | killAll, 7 | generateChainSpec, 8 | generateChainSpecRaw, 9 | exportGenesisWasm, 10 | exportGenesisState, 11 | startSimpleCollator, 12 | } from "./spawn"; 13 | import { 14 | connect, 15 | registerParachain, 16 | setBalance, 17 | } from "./rpc"; 18 | import { checkConfig } from "./check"; 19 | import { 20 | clearAuthorities, 21 | addAuthority, 22 | changeGenesisConfig, 23 | addGenesisParachain, 24 | addGenesisHrmpChannel, 25 | } from "./spec"; 26 | import { parachainAccount } from "./parachain"; 27 | import { ApiPromise } from "@polkadot/api"; 28 | 29 | import { resolve, dirname } from "path"; 30 | import fs from "fs"; 31 | import { LaunchConfig, ParachainConfig, HrmpChannelsConfig } from "./types"; 32 | 33 | // Special care is needed to handle paths to various files (binaries, spec, config, etc...) 34 | // The user passes the path to `config.json`, and we use that as the starting point for any other 35 | // relative path. So the `config.json` file is what we will be our starting point. 36 | const { argv } = require("yargs"); 37 | 38 | const config_file = argv._[0] ? argv._[0] : null; 39 | if (!config_file) { 40 | console.error("Missing config file argument..."); 41 | process.exit(); 42 | } 43 | let config_path = resolve(process.cwd(), config_file); 44 | let config_dir = dirname(config_path); 45 | if (!fs.existsSync(config_path)) { 46 | console.error("Config file does not exist: ", config_path); 47 | process.exit(); 48 | } 49 | let config: LaunchConfig = require(config_path); 50 | 51 | function loadTypeDef(types: string | object): object { 52 | if (typeof types === "string") { 53 | // Treat types as a json file path 54 | try { 55 | const rawdata = fs.readFileSync(types, { encoding: "utf-8" }); 56 | return JSON.parse(rawdata); 57 | } catch { 58 | console.error("failed to load parachain typedef file"); 59 | process.exit(1); 60 | } 61 | } else { 62 | return types; 63 | } 64 | } 65 | 66 | // keep track of registered parachains 67 | let registeredParachains: { [key: string]: boolean } = {}; 68 | 69 | async function main() { 70 | // Verify that the `config.json` has all the expected properties. 71 | if (!checkConfig(config)) { 72 | return; 73 | } 74 | 75 | const relay_chain_bin = resolve(config_dir, config.relaychain.bin); 76 | if (!fs.existsSync(relay_chain_bin)) { 77 | console.error("Relay chain binary does not exist: ", relay_chain_bin); 78 | process.exit(); 79 | } 80 | const chain = config.relaychain.chain; 81 | await generateChainSpec(relay_chain_bin, chain); 82 | // -- Start Chain Spec Modify -- 83 | clearAuthorities(`${chain}.json`); 84 | for (const node of config.relaychain.nodes) { 85 | await addAuthority(`${chain}.json`, node.name); 86 | } 87 | if (config.relaychain.runtime_genesis_config) { 88 | await changeGenesisConfig( 89 | `${chain}.json`, 90 | config.relaychain.runtime_genesis_config 91 | ); 92 | } 93 | await addParachainsToGenesis(`${chain}.json`, config.parachains); 94 | await addHrmpChannelsToGenesis(`${chain}.json`, config.hrmpChannels); 95 | // -- End Chain Spec Modify -- 96 | await generateChainSpecRaw(relay_chain_bin, chain); 97 | const spec = resolve(`${chain}-raw.json`); 98 | 99 | // First we launch each of the validators for the relay chain. 100 | for (const node of config.relaychain.nodes) { 101 | const { name, wsPort, port, flags } = node; 102 | console.log(`Starting ${name}...`); 103 | // We spawn a `child_process` starting a node, and then wait until we 104 | // able to connect to it using PolkadotJS in order to know its running. 105 | startNode(relay_chain_bin, name, wsPort, port, spec, flags); 106 | } 107 | 108 | // Connect to the first relay chain node to submit the extrinsic. 109 | let relayChainApi: ApiPromise = await connect( 110 | config.relaychain.nodes[0].wsPort, 111 | loadTypeDef(config.types) 112 | ); 113 | 114 | // Then launch each parachain 115 | for (const parachain of config.parachains) { 116 | const { id, balance, chain } = parachain; 117 | const bin = resolve(config_dir, parachain.bin); 118 | if (!fs.existsSync(bin)) { 119 | console.error("Parachain binary does not exist: ", bin); 120 | process.exit(); 121 | } 122 | let account = parachainAccount(id); 123 | 124 | for (const node of parachain.nodes) { 125 | const { wsPort, port, flags } = node; 126 | console.log( 127 | `Starting a Collator for parachain ${id}: ${account}, Collator port : ${port} wsPort : ${wsPort}` 128 | ); 129 | await startCollator(bin, id, wsPort, port, chain, spec, flags); 130 | } 131 | 132 | // Allow time for the TX to complete, avoiding nonce issues. 133 | // TODO: Handle nonce directly instead of this. 134 | if (balance) { 135 | await setBalance(relayChainApi, account, balance, config.finalization); 136 | } 137 | } 138 | 139 | // Then launch each simple parachain (e.g. an adder-collator) 140 | if (config.simpleParachains) { 141 | for (const simpleParachain of config.simpleParachains) { 142 | const { id, port, balance } = simpleParachain; 143 | const bin = resolve(config_dir, simpleParachain.bin); 144 | if (!fs.existsSync(bin)) { 145 | console.error("Simple parachain binary does not exist: ", bin); 146 | process.exit(); 147 | } 148 | 149 | let account = parachainAccount(id); 150 | console.log(`Starting Parachain ${id}: ${account}`); 151 | await startSimpleCollator(bin, id, spec, port); 152 | 153 | // Get the information required to register the parachain on the relay chain. 154 | let genesisState; 155 | let genesisWasm; 156 | try { 157 | // adder-collator does not support `--parachain-id` for export-genesis-state (and it is 158 | // not necessary for it anyway), so we don't pass it here. 159 | genesisState = await exportGenesisState(bin); 160 | genesisWasm = await exportGenesisWasm(bin); 161 | } catch (err) { 162 | console.error(err); 163 | process.exit(1); 164 | } 165 | 166 | console.log(`Registering Parachain ${id}`); 167 | await registerParachain( 168 | relayChainApi, 169 | id, 170 | genesisWasm, 171 | genesisState, 172 | config.finalization 173 | ); 174 | 175 | // Allow time for the TX to complete, avoiding nonce issues. 176 | // TODO: Handle nonce directly instead of this. 177 | if (balance) { 178 | await setBalance(relayChainApi, account, balance, config.finalization); 179 | } 180 | } 181 | } 182 | 183 | console.log("🚀 POLKADOT LAUNCH COMPLETE 🚀"); 184 | } 185 | 186 | async function addParachainsToGenesis( 187 | spec: string, 188 | parachains: ParachainConfig[] 189 | ) { 190 | console.log("\n⛓ Adding Genesis Parachains"); 191 | for (const parachain of parachains) { 192 | const { id, chain } = parachain; 193 | const bin = resolve(config_dir, parachain.bin); 194 | if (!fs.existsSync(bin)) { 195 | console.error("Parachain binary does not exist: ", bin); 196 | process.exit(); 197 | } 198 | // If it isn't registered yet, register the parachain in genesis 199 | if (!registeredParachains[id]) { 200 | // Get the information required to register the parachain in genesis. 201 | let genesisState; 202 | let genesisWasm; 203 | try { 204 | genesisState = await exportGenesisState(bin, id, chain); 205 | genesisWasm = await exportGenesisWasm(bin, chain); 206 | } catch (err) { 207 | console.error(err); 208 | process.exit(1); 209 | } 210 | 211 | await addGenesisParachain(spec, id, genesisState, genesisWasm, true); 212 | registeredParachains[id] = true; 213 | } 214 | } 215 | } 216 | 217 | async function addHrmpChannelsToGenesis( 218 | spec: string, 219 | hrmpChannels: HrmpChannelsConfig[] 220 | ) { 221 | console.log("⛓ Adding Genesis HRMP Channels"); 222 | for (const hrmpChannel of hrmpChannels) { 223 | await addGenesisHrmpChannel(spec, hrmpChannel); 224 | } 225 | } 226 | 227 | // Kill all processes when exiting. 228 | process.on("exit", function () { 229 | killAll(); 230 | }); 231 | 232 | // Handle ctrl+c to trigger `exit`. 233 | process.on("SIGINT", function () { 234 | process.exit(2); 235 | }); 236 | 237 | main(); 238 | -------------------------------------------------------------------------------- /polkadot-launch/src/parachain.ts: -------------------------------------------------------------------------------- 1 | import { bnToHex, stringToHex, hexStripPrefix } from "@polkadot/util"; 2 | import { encodeAddress } from "@polkadot/util-crypto"; 3 | 4 | export function parachainAccount(id: string) { 5 | let prefix = stringToHex("para"); 6 | let encoded_id = bnToHex(parseInt(id), { isLe: true }); 7 | let address_bytes = (prefix + hexStripPrefix(encoded_id)).padEnd(64 + 2, "0"); 8 | let address = encodeAddress(address_bytes); 9 | 10 | return address; 11 | } 12 | -------------------------------------------------------------------------------- /polkadot-launch/src/rpc.ts: -------------------------------------------------------------------------------- 1 | import { ApiPromise, WsProvider } from "@polkadot/api"; 2 | import { Keyring } from "@polkadot/api"; 3 | import { cryptoWaitReady } from "@polkadot/util-crypto"; 4 | 5 | let nonce = 0; 6 | 7 | const filterConsole = require("filter-console"); 8 | 9 | // Hide some warning messages that are coming from Polkadot JS API. 10 | // TODO: Make configurable. 11 | filterConsole([ 12 | `code: '1006' reason: 'connection failed'`, 13 | `Unhandled promise rejections`, 14 | `UnhandledPromiseRejectionWarning:`, 15 | `Unknown types found`, 16 | ]); 17 | 18 | // Connect to a local Substrate node. This function wont resolve until connected. 19 | // TODO: Add a timeout where we know something went wrong so we don't wait forever. 20 | export async function connect(port: number, types: any) { 21 | const provider = new WsProvider("ws://127.0.0.1:" + port); 22 | const api = await ApiPromise.create({ provider, types, throwOnConnect: false }); 23 | return api; 24 | } 25 | 26 | // Get the genesis header of a node. Used for registering a parachain on the relay chain. 27 | export async function getHeader(api: ApiPromise) { 28 | let genesis_hash = await api.rpc.chain.getBlockHash(0); 29 | let genesis_header = await api.rpc.chain.getHeader(genesis_hash); 30 | return genesis_header.toHex(); 31 | } 32 | 33 | // Submit an extrinsic to the relay chain to register a parachain. 34 | // Uses the Alice account which is known to be Sudo for the relay chain. 35 | export async function registerParachain( 36 | api: ApiPromise, 37 | id: string, 38 | wasm: string, 39 | header: string, 40 | finalization: boolean = false 41 | ) { 42 | return new Promise(async (resolvePromise, reject) => { 43 | await cryptoWaitReady(); 44 | 45 | const keyring = new Keyring({ type: "sr25519" }); 46 | const alice = keyring.addFromUri("//Alice"); 47 | 48 | let paraGenesisArgs = { 49 | genesis_head: header, 50 | validation_code: wasm, 51 | parachain: true, 52 | }; 53 | let genesis = api.createType("ParaGenesisArgs", paraGenesisArgs); 54 | 55 | console.log( 56 | `--- Submitting extrinsic to register parachain ${id}. (nonce: ${nonce}) ---` 57 | ); 58 | const unsub = await api.tx.sudo 59 | .sudo(api.tx.parasSudoWrapper.sudoScheduleParaInitialize(id, genesis)) 60 | .signAndSend(alice, { nonce: nonce, era: 0 }, (result) => { 61 | console.log(`Current status is ${result.status}`); 62 | if (result.status.isInBlock) { 63 | console.log( 64 | `Transaction included at blockHash ${result.status.asInBlock}` 65 | ); 66 | if (finalization) { 67 | console.log("Waiting for finalization..."); 68 | } else { 69 | unsub(); 70 | resolvePromise(); 71 | } 72 | } else if (result.status.isFinalized) { 73 | console.log( 74 | `Transaction finalized at blockHash ${result.status.asFinalized}` 75 | ); 76 | unsub(); 77 | resolvePromise(); 78 | } else if (result.isError) { 79 | console.log(`Transaction Error`); 80 | reject(`Transaction Error`); 81 | } 82 | }); 83 | nonce += 1; 84 | }); 85 | } 86 | 87 | // Set the balance of an account on the relay chain. 88 | export async function setBalance( 89 | api: ApiPromise, 90 | who: string, 91 | value: string, 92 | finalization: boolean = false 93 | ) { 94 | return new Promise(async (resolvePromise, reject) => { 95 | await cryptoWaitReady(); 96 | 97 | const keyring = new Keyring({ type: "sr25519" }); 98 | const alice = keyring.addFromUri("//Alice"); 99 | 100 | if (!nonce) { 101 | nonce = Number((await api.query.system.account(alice.address)).nonce); 102 | } 103 | 104 | console.log( 105 | `--- Submitting extrinsic to set balance of ${who} to ${value}. (nonce: ${nonce}) ---` 106 | ); 107 | const unsub = await api.tx.sudo 108 | .sudo(api.tx.balances.setBalance(who, value, 0)) 109 | .signAndSend(alice, { nonce: nonce, era: 0 }, (result) => { 110 | console.log(`Current status is ${result.status}`); 111 | if (result.status.isInBlock) { 112 | console.log( 113 | `Transaction included at blockHash ${result.status.asInBlock}` 114 | ); 115 | if (finalization) { 116 | console.log("Waiting for finalization..."); 117 | } else { 118 | unsub(); 119 | resolvePromise(); 120 | } 121 | } else if (result.status.isFinalized) { 122 | console.log( 123 | `Transaction finalized at blockHash ${result.status.asFinalized}` 124 | ); 125 | unsub(); 126 | resolvePromise(); 127 | } else if (result.isError) { 128 | console.log(`Transaction Error`); 129 | reject(`Transaction Error`); 130 | } 131 | }); 132 | nonce += 1; 133 | }); 134 | } 135 | 136 | export async function sendHrmpMessage( 137 | api: ApiPromise, 138 | recipient: string, 139 | data: string, 140 | finalization: boolean = false 141 | ) { 142 | return new Promise(async (resolvePromise, reject) => { 143 | await cryptoWaitReady(); 144 | 145 | const keyring = new Keyring({ type: "sr25519" }); 146 | const alice = keyring.addFromUri("//Alice"); 147 | 148 | if (!nonce) { 149 | nonce = Number((await api.query.system.account(alice.address)).nonce); 150 | } 151 | 152 | let hrmpMessage = { 153 | recipient: recipient, 154 | data: data, 155 | }; 156 | let message = api.createType("OutboundHrmpMessage", hrmpMessage); 157 | 158 | console.log(`--- Sending a message to ${recipient}. (nonce: ${nonce}) ---`); 159 | const unsub = await api.tx.sudo 160 | .sudo(api.tx.messageBroker.sudoSendHrmpMessage(message)) 161 | .signAndSend(alice, { nonce: nonce, era: 0 }, (result) => { 162 | console.log(`Current status is ${result.status}`); 163 | if (result.status.isInBlock) { 164 | console.log( 165 | `Transaction included at blockHash ${result.status.asInBlock}` 166 | ); 167 | if (finalization) { 168 | console.log("Waiting for finalization..."); 169 | } else { 170 | unsub(); 171 | resolvePromise(); 172 | } 173 | } else if (result.status.isFinalized) { 174 | console.log( 175 | `Transaction finalized at blockHash ${result.status.asFinalized}` 176 | ); 177 | unsub(); 178 | resolvePromise(); 179 | } else if (result.isError) { 180 | console.log(`Transaction Error`); 181 | reject(`Transaction Error`); 182 | } 183 | }); 184 | nonce += 1; 185 | }); 186 | } 187 | -------------------------------------------------------------------------------- /polkadot-launch/src/spawn.ts: -------------------------------------------------------------------------------- 1 | import { 2 | spawn, 3 | ChildProcessWithoutNullStreams, 4 | execFile as ex, 5 | } from "child_process"; 6 | import util from "util"; 7 | import fs from "fs"; 8 | 9 | // This tracks all the processes that we spawn from this file. 10 | // Used to clean up processes when exiting this program. 11 | const p: { [key: string]: ChildProcessWithoutNullStreams } = {}; 12 | 13 | const execFile = util.promisify(ex); 14 | 15 | // Output the chainspec of a node. 16 | export async function generateChainSpec(bin: string, chain: string) { 17 | return new Promise(function (resolve, reject) { 18 | let args = ["build-spec", "--chain=" + chain, "--disable-default-bootnode"]; 19 | 20 | p["spec"] = spawn(bin, args); 21 | let spec = fs.createWriteStream(`${chain}.json`); 22 | 23 | // `pipe` since it deals with flushing and we need to guarantee that the data is flushed 24 | // before we resolve the promise. 25 | p["spec"].stdout.pipe(spec); 26 | 27 | p["spec"].stderr.pipe(process.stderr); 28 | 29 | p["spec"].on("close", () => { 30 | resolve(); 31 | }); 32 | 33 | p["spec"].on("error", (err) => { 34 | reject(err); 35 | }); 36 | }); 37 | } 38 | 39 | // Output the chainspec of a node using `--raw` from a JSON file. 40 | export async function generateChainSpecRaw(bin: string, chain: string) { 41 | console.log(); // Add a newline in output 42 | return new Promise(function (resolve, reject) { 43 | let args = ["build-spec", "--chain=" + chain + ".json", "--raw"]; 44 | 45 | p["spec"] = spawn(bin, args); 46 | let spec = fs.createWriteStream(`${chain}-raw.json`); 47 | 48 | // `pipe` since it deals with flushing and we need to guarantee that the data is flushed 49 | // before we resolve the promise. 50 | p["spec"].stdout.pipe(spec); 51 | p["spec"].stderr.pipe(process.stderr); 52 | 53 | p["spec"].on("close", () => { 54 | resolve(); 55 | }); 56 | 57 | p["spec"].on("error", (err) => { 58 | reject(err); 59 | }); 60 | }); 61 | } 62 | 63 | // Spawn a new relay chain node. 64 | // `name` must be `alice`, `bob`, `charlie`, etc... (hardcoded in Substrate). 65 | export function startNode( 66 | bin: string, 67 | name: string, 68 | wsPort: number, 69 | port: number, 70 | spec: string, 71 | flags?: string[] 72 | ) { 73 | // TODO: Make DB directory configurable rather than just `tmp` 74 | let args = [ 75 | "--chain=" + spec, 76 | "--tmp", 77 | "--ws-port=" + wsPort, 78 | "--port=" + port, 79 | "--" + name.toLowerCase(), 80 | ]; 81 | 82 | if (flags) { 83 | // Add any additional flags to the CLI 84 | args = args.concat(flags); 85 | console.log(`Added ${flags}`); 86 | } 87 | 88 | p[name] = spawn(bin, args); 89 | 90 | let log = fs.createWriteStream(`${name}.log`); 91 | 92 | p[name].stdout.pipe(log); 93 | p[name].stderr.pipe(log); 94 | } 95 | 96 | // Export the genesis wasm for a parachain and return it as a hex encoded string starting with 0x. 97 | // Used for registering the parachain on the relay chain. 98 | export async function exportGenesisWasm( 99 | bin: string, 100 | chain?: string 101 | ): Promise { 102 | let args = ["export-genesis-wasm"]; 103 | if (chain) { 104 | args.push("--chain=" + chain); 105 | } 106 | 107 | // wasm files are typically large and `exec` requires us to supply the maximum buffer size in 108 | // advance. Hopefully, this generous limit will be enough. 109 | let opts = { maxBuffer: 10 * 1024 * 1024 }; 110 | let { stdout, stderr } = await execFile(bin, args, opts); 111 | if (stderr) { 112 | console.error(stderr); 113 | } 114 | return stdout.trim(); 115 | } 116 | 117 | /// Export the genesis state aka genesis head. 118 | export async function exportGenesisState( 119 | bin: string, 120 | id?: string, 121 | chain?: string 122 | ): Promise { 123 | let args = ["export-genesis-state"]; 124 | if (id) { 125 | args.push("--parachain-id=" + id); 126 | } 127 | if (chain) { 128 | args.push("--chain=" + chain); 129 | } 130 | 131 | // wasm files are typically large and `exec` requires us to supply the maximum buffer size in 132 | // advance. Hopefully, this generous limit will be enough. 133 | let opts = { maxBuffer: 5 * 1024 * 1024 }; 134 | let { stdout, stderr } = await execFile(bin, args, opts); 135 | if (stderr) { 136 | console.error(stderr); 137 | } 138 | return stdout.trim(); 139 | } 140 | 141 | // Start a collator node for a parachain. 142 | export function startCollator( 143 | bin: string, 144 | id: string, 145 | wsPort: number, 146 | port: number, 147 | chain?: string, 148 | spec?: string, 149 | flags?: string[] 150 | ) { 151 | return new Promise(function (resolve) { 152 | // TODO: Make DB directory configurable rather than just `tmp` 153 | let args = [ 154 | "--tmp", 155 | "--ws-port=" + wsPort, 156 | "--port=" + port, 157 | "--parachain-id=" + id, 158 | "--collator", 159 | "--alice", 160 | "--force-authoring" 161 | ]; 162 | 163 | if (chain) { 164 | args.push("--chain=" + chain); 165 | console.log(`Added --chain=${chain}`); 166 | } 167 | 168 | let flags_collator = null; 169 | let flags_parachain = null; 170 | let split_index = flags ? flags.findIndex((value) => value == "--") : -1; 171 | 172 | if (split_index < 0) { 173 | flags_parachain = flags; 174 | } else { 175 | flags_parachain = flags ? flags.slice(0, split_index) : null; 176 | flags_collator = flags ? flags.slice(split_index + 1) : null; 177 | } 178 | 179 | if (flags_parachain) { 180 | // Add any additional flags to the CLI 181 | args = args.concat(flags_parachain); 182 | console.log(`Added ${flags_parachain} to parachain`); 183 | } 184 | 185 | // Arguments for the relay chain node part of the collator binary. 186 | args = args.concat(["--", "--chain=" + spec]); 187 | 188 | if (flags_collator) { 189 | // Add any additional flags to the CLI 190 | args = args.concat(flags_collator); 191 | console.log(`Added ${flags_collator} to collator`); 192 | } 193 | 194 | p[wsPort] = spawn(bin, args); 195 | 196 | let log = fs.createWriteStream(`${wsPort}.log`); 197 | 198 | p[wsPort].stdout.pipe(log); 199 | p[wsPort].stderr.on("data", function (chunk) { 200 | let message = chunk.toString(); 201 | if (message.includes("Listening for new connections")) { 202 | resolve(); 203 | } 204 | log.write(message); 205 | }); 206 | }); 207 | } 208 | 209 | export function startSimpleCollator( 210 | bin: string, 211 | id: string, 212 | spec: string, 213 | port: string 214 | ) { 215 | return new Promise(function (resolve) { 216 | let args = [ 217 | "--tmp", 218 | "--parachain-id=" + id, 219 | "--port=" + port, 220 | "--chain=" + spec, 221 | "--execution=wasm", 222 | ]; 223 | 224 | p[port] = spawn(bin, args); 225 | 226 | let log = fs.createWriteStream(`${port}.log`); 227 | 228 | p[port].stdout.on("data", function (chunk) { 229 | let message = chunk.toString(); 230 | log.write(message); 231 | }); 232 | p[port].stderr.on("data", function (chunk) { 233 | let message = chunk.toString(); 234 | if (message.substring(21, 50) === "Listening for new connections") { 235 | resolve(); 236 | } 237 | log.write(message); 238 | }); 239 | }); 240 | } 241 | 242 | // Purge the chain for any node. 243 | // You shouldn't need to use this function since every node starts with `--tmp` 244 | // TODO: Make DB directory configurable rather than just `tmp` 245 | export function purgeChain(bin: string, spec: string) { 246 | console.log("Purging Chain..."); 247 | let args = ["purge-chain"]; 248 | 249 | if (spec) { 250 | args.push("--chain=" + spec); 251 | } 252 | 253 | // Avoid prompt to confirm. 254 | args.push("-y"); 255 | 256 | p["purge"] = spawn(bin, args); 257 | 258 | p["purge"].stdout.on("data", function (chunk) { 259 | let message = chunk.toString(); 260 | console.log(message); 261 | }); 262 | 263 | p["purge"].stderr.on("data", function (chunk) { 264 | let message = chunk.toString(); 265 | console.log(message); 266 | }); 267 | } 268 | 269 | // Kill all processes spawned and tracked by this file. 270 | export function killAll() { 271 | console.log("\nKilling all processes..."); 272 | for (const key of Object.keys(p)) { 273 | p[key].kill(); 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /polkadot-launch/src/spec.ts: -------------------------------------------------------------------------------- 1 | import { Keyring } from "@polkadot/api"; 2 | import { cryptoWaitReady } from "@polkadot/util-crypto"; 3 | import { encodeAddress } from "@polkadot/util-crypto"; 4 | import { ChainSpec, HrmpChannelsConfig } from "./types"; 5 | const fs = require("fs"); 6 | 7 | function nameCase(string: string) { 8 | return string.charAt(0).toUpperCase() + string.slice(1); 9 | } 10 | 11 | // Get authority keys from within chainSpec data 12 | function getAuthorityKeys(chainSpec: ChainSpec) { 13 | // this is the most recent spec struct 14 | if ( 15 | chainSpec.genesis.runtime.runtime_genesis_config && 16 | chainSpec.genesis.runtime.runtime_genesis_config.palletSession 17 | ) { 18 | return chainSpec.genesis.runtime.runtime_genesis_config.palletSession.keys; 19 | } 20 | // Backward compatibility 21 | return chainSpec.genesis.runtime.palletSession.keys; 22 | } 23 | 24 | // Remove all existing keys from `session.keys` 25 | export function clearAuthorities(spec: string) { 26 | let rawdata = fs.readFileSync(spec); 27 | let chainSpec; 28 | try { 29 | chainSpec = JSON.parse(rawdata); 30 | } catch { 31 | console.error("failed to parse the chain spec"); 32 | process.exit(1); 33 | } 34 | 35 | let keys = getAuthorityKeys(chainSpec); 36 | keys.length = 0; 37 | 38 | let data = JSON.stringify(chainSpec, null, 2); 39 | fs.writeFileSync(spec, data); 40 | console.log(`\n🧹 Starting with a fresh authority set...`); 41 | } 42 | 43 | // Add additional authorities to chain spec in `session.keys` 44 | export async function addAuthority(spec: string, name: string) { 45 | await cryptoWaitReady(); 46 | 47 | const sr_keyring = new Keyring({ type: "sr25519" }); 48 | const sr_account = sr_keyring.createFromUri(`//${nameCase(name)}`); 49 | const sr_stash = sr_keyring.createFromUri(`//${nameCase(name)}//stash`); 50 | 51 | const ed_keyring = new Keyring({ type: "ed25519" }); 52 | const ed_account = ed_keyring.createFromUri(`//${nameCase(name)}`); 53 | 54 | const ec_keyring = new Keyring({ type: "ecdsa" }); 55 | const ec_account = ec_keyring.createFromUri(`//${nameCase(name)}`); 56 | 57 | let key = [ 58 | sr_stash.address, 59 | sr_stash.address, 60 | { 61 | grandpa: ed_account.address, 62 | babe: sr_account.address, 63 | im_online: sr_account.address, 64 | parachain_validator: sr_account.address, 65 | authority_discovery: sr_account.address, 66 | para_validator: sr_account.address, 67 | para_assignment: sr_account.address, 68 | beefy: encodeAddress(ec_account.publicKey), 69 | }, 70 | ]; 71 | 72 | let rawdata = fs.readFileSync(spec); 73 | let chainSpec = JSON.parse(rawdata); 74 | 75 | let keys = getAuthorityKeys(chainSpec); 76 | keys.push(key); 77 | 78 | let data = JSON.stringify(chainSpec, null, 2); 79 | fs.writeFileSync(spec, data); 80 | console.log(` 👤 Added Genesis Authority ${name}`); 81 | } 82 | 83 | // Add parachains to the chain spec at genesis. 84 | export async function addGenesisParachain( 85 | spec: string, 86 | para_id: string, 87 | head: string, 88 | wasm: string, 89 | parachain: boolean 90 | ) { 91 | let rawdata = fs.readFileSync(spec); 92 | let chainSpec = JSON.parse(rawdata); 93 | 94 | if ( 95 | chainSpec.genesis.runtime.runtime_genesis_config && 96 | chainSpec.genesis.runtime.runtime_genesis_config.parachainsParas 97 | ) { 98 | let paras = 99 | chainSpec.genesis.runtime.runtime_genesis_config.parachainsParas.paras; 100 | 101 | let new_para = [ 102 | parseInt(para_id), 103 | { 104 | genesis_head: head, 105 | validation_code: wasm, 106 | parachain: parachain, 107 | }, 108 | ]; 109 | 110 | paras.push(new_para); 111 | 112 | let data = JSON.stringify(chainSpec, null, 2); 113 | fs.writeFileSync(spec, data); 114 | console.log(` ✓ Added Genesis Parachain ${para_id}`); 115 | } 116 | } 117 | 118 | export async function addGenesisHrmpChannel( 119 | spec: string, 120 | hrmpChannel: HrmpChannelsConfig 121 | ) { 122 | let rawdata = fs.readFileSync(spec); 123 | let chainSpec = JSON.parse(rawdata); 124 | 125 | let newHrmpChannel = [ 126 | hrmpChannel.sender, 127 | hrmpChannel.recipient, 128 | hrmpChannel.maxCapacity, 129 | hrmpChannel.maxMessageSize 130 | ]; 131 | 132 | if (chainSpec.genesis.runtime.runtime_genesis_config.parachainsHrmp && 133 | chainSpec.genesis.runtime.runtime_genesis_config.parachainsHrmp.preopenHrmpChannels 134 | ) { 135 | chainSpec.genesis.runtime.runtime_genesis_config.parachainsHrmp.preopenHrmpChannels.push(newHrmpChannel); 136 | 137 | let data = JSON.stringify(chainSpec, null, 2); 138 | fs.writeFileSync(spec, data); 139 | console.log(` ✓ Added HRMP channel ${hrmpChannel.sender} -> ${hrmpChannel.recipient}`); 140 | } 141 | } 142 | 143 | // Update the `runtime_genesis_config` in the genesis. 144 | // It will try to match keys which exist within the configuration and update the value. 145 | export async function changeGenesisConfig(spec: string, updates: any) { 146 | let rawdata = fs.readFileSync(spec); 147 | let chainSpec = JSON.parse(rawdata); 148 | 149 | console.log(`\n⚙ Updating Parachains Genesis Configuration`); 150 | 151 | if (chainSpec.genesis.runtime.runtime_genesis_config) { 152 | let config = chainSpec.genesis.runtime.runtime_genesis_config; 153 | findAndReplaceConfig(updates, config); 154 | 155 | let data = JSON.stringify(chainSpec, null, 2); 156 | fs.writeFileSync(spec, data); 157 | } 158 | } 159 | 160 | // Look at the key + values from `obj1` and try to replace them in `obj2`. 161 | function findAndReplaceConfig(obj1: any, obj2: any) { 162 | // Look at keys of obj1 163 | Object.keys(obj1).forEach((key) => { 164 | // See if obj2 also has this key 165 | if (obj2.hasOwnProperty(key)) { 166 | // If it goes deeper, recurse... 167 | if (obj1[key].constructor === Object) { 168 | findAndReplaceConfig(obj1[key], obj2[key]); 169 | } else { 170 | obj2[key] = obj1[key]; 171 | console.log( 172 | ` ✓ Updated Parachains Configuration [ ${key}: ${obj2[key]} ]` 173 | ); 174 | } 175 | } else { 176 | console.error( 177 | ` ⚠ Bad Parachains Configuration [ ${key}: ${obj1[key]} ]` 178 | ); 179 | } 180 | }); 181 | } 182 | -------------------------------------------------------------------------------- /polkadot-launch/src/types.d.ts: -------------------------------------------------------------------------------- 1 | export interface LaunchConfig { 2 | relaychain: RelayChainConfig; 3 | parachains: ParachainConfig[]; 4 | simpleParachains: SimpleParachainConfig[]; 5 | hrmpChannels: HrmpChannelsConfig[]; 6 | types: any; 7 | finalization: boolean; 8 | } 9 | export interface ParachainNodeConfig { 10 | rpcPort: number; 11 | wsPort: number; 12 | port: number; 13 | flags: string[]; 14 | } 15 | export interface ParachainConfig { 16 | bin: string; 17 | id: string; 18 | balance: string; 19 | chain?: string; 20 | nodes: ParachainNodeConfig[]; 21 | } 22 | export interface SimpleParachainConfig { 23 | bin: string; 24 | id: string; 25 | port: string; 26 | balance: string; 27 | } 28 | export interface HrmpChannelsConfig { 29 | sender: number; 30 | recipient: number; 31 | maxCapacity: number; 32 | maxMessageSize: number; 33 | } 34 | export interface RelayChainConfig { 35 | bin: string; 36 | chain: string; 37 | nodes: { 38 | name: string; 39 | wsPort: number; 40 | port: number; 41 | flags?: string[]; 42 | }[]; 43 | runtime_genesis_config?: JSON; 44 | } 45 | 46 | export interface ChainSpec { 47 | name: string; 48 | id: string; 49 | chainType: string; 50 | bootNodes: string[]; 51 | telemetryEndpoints: null; 52 | protocolId: string; 53 | properties: null; 54 | forkBlocks: null; 55 | badBlocks: null; 56 | consensusEngine: null; 57 | lightSyncState: null; 58 | genesis: { 59 | runtime: any; // this can change depending on the versions 60 | raw: { 61 | top: { 62 | [key: string]: string; 63 | }; 64 | }; 65 | }; 66 | } 67 | -------------------------------------------------------------------------------- /polkadot-launch/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "esModuleInterop": true, 5 | "target": "es6", 6 | "module": "commonjs", 7 | "lib": ["esnext"], 8 | "outDir": "dist", 9 | "resolveJsonModule": true, 10 | "strict": true 11 | }, 12 | "exclude": ["node_modules", "dist", "test"] 13 | } 14 | -------------------------------------------------------------------------------- /runtime/common/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies.substrate-wasm-builder] 2 | git = 'https://github.com/paritytech/substrate.git' 3 | branch = "master" 4 | version = '4.0.0' 5 | 6 | [package] 7 | name = "runtime-common" 8 | version = "0.8.30" 9 | authors = ["Parity Technologies "] 10 | edition = "2018" 11 | 12 | [package.metadata.docs.rs] 13 | targets = ['x86_64-unknown-linux-gnu'] 14 | 15 | [dependencies.sp-consensus-aura] 16 | default-features = false 17 | git = 'https://github.com/paritytech/substrate.git' 18 | branch = "master" 19 | version = '0.9.0' 20 | 21 | [dependencies.sp-std] 22 | default-features = false 23 | git = 'https://github.com/paritytech/substrate.git' 24 | branch = "master" 25 | version = '3.0.0' 26 | 27 | [dependencies.sp-io] 28 | default-features = false 29 | git = 'https://github.com/paritytech/substrate.git' 30 | branch = "master" 31 | version = '3.0.0' 32 | 33 | [dependencies.codec] 34 | default-features = false 35 | features = ['derive'] 36 | package = 'parity-scale-codec' 37 | version = '2.0.0' 38 | 39 | [dependencies.frame-executive] 40 | default-features = false 41 | git = 'https://github.com/paritytech/substrate.git' 42 | branch = "master" 43 | version = '3.0.0' 44 | 45 | [dependencies.frame-support] 46 | default-features = false 47 | git = 'https://github.com/paritytech/substrate.git' 48 | branch = "master" 49 | version = '3.0.0' 50 | 51 | [dependencies.frame-system] 52 | default-features = false 53 | git = 'https://github.com/paritytech/substrate.git' 54 | branch = "master" 55 | version = '3.0.0' 56 | 57 | 58 | [dependencies.pallet-balances] 59 | default-features = false 60 | git = 'https://github.com/paritytech/substrate.git' 61 | branch = "master" 62 | version = '3.0.0' 63 | 64 | [dependencies.sp-runtime] 65 | default-features = false 66 | git = 'https://github.com/paritytech/substrate.git' 67 | branch = "master" 68 | version = '3.0.0' 69 | 70 | [dependencies.sp-core] 71 | default-features = false 72 | git = 'https://github.com/paritytech/substrate.git' 73 | branch = "master" 74 | version = '3.0.0' 75 | 76 | [dependencies.node-primitives] 77 | default-features = false 78 | git = 'https://github.com/paritytech/substrate.git' 79 | branch = "master" 80 | 81 | [dependencies.polkadot-runtime-common] 82 | git = 'https://github.com/paritytech/polkadot' 83 | branch = "master" 84 | default-features = false 85 | 86 | # Polkadot dependencies 87 | [dependencies.polkadot-primitives] 88 | git = 'https://github.com/paritytech/polkadot' 89 | branch = "master" 90 | default-features = false 91 | 92 | [dependencies.pallet-collator-selection] 93 | default-features = false 94 | path = '../../pallets/collator-selection' 95 | 96 | [dev-dependencies] 97 | serde = { version = "1.0.119" } 98 | 99 | [dev-dependencies.sp-io] 100 | default-features = false 101 | git = 'https://github.com/paritytech/substrate.git' 102 | branch = "master" 103 | version = '3.0.0' 104 | 105 | [dev-dependencies.pallet-authorship] 106 | default-features = false 107 | git = 'https://github.com/paritytech/substrate.git' 108 | branch = "master" 109 | version = '3.0.0' 110 | 111 | 112 | 113 | [features] 114 | default = ["std"] 115 | std = [ 116 | 'codec/std', 117 | 'sp-consensus-aura/std', 118 | 'sp-std/std', 119 | 'sp-io/std', 120 | 'frame-support/std', 121 | 'frame-executive/std', 122 | 'frame-system/std', 123 | 'pallet-collator-selection/std', 124 | 'pallet-balances/std', 125 | 'node-primitives/std', 126 | 'polkadot-runtime-common/std', 127 | 'polkadot-primitives/std', 128 | ] 129 | -------------------------------------------------------------------------------- /runtime/common/src/impls.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | //! Auxillary struct/enums for Statemint runtime. 17 | //! Taken from polkadot/runtime/common (at a21cd64) and adapted for Statemint. 18 | 19 | use frame_support::traits::{Currency, Imbalance, OnUnbalanced}; 20 | 21 | pub type NegativeImbalance = as Currency<::AccountId>>::NegativeImbalance; 22 | 23 | /// Logic for the author to get a portion of fees. 24 | pub struct ToStakingPot(sp_std::marker::PhantomData); 25 | impl OnUnbalanced> for ToStakingPot 26 | where 27 | R: pallet_balances::Config + pallet_collator_selection::Config, 28 | ::AccountId: From, 29 | ::AccountId: Into, 30 | ::Event: From>, 31 | { 32 | fn on_nonzero_unbalanced(amount: NegativeImbalance) { 33 | let numeric_amount = amount.peek(); 34 | let staking_pot = >::account_id(); 35 | >::resolve_creating( 36 | &staking_pot, 37 | amount, 38 | ); 39 | >::deposit_event(pallet_balances::Event::Deposit( 40 | staking_pot, 41 | numeric_amount, 42 | )); 43 | } 44 | } 45 | 46 | pub struct DealWithFees(sp_std::marker::PhantomData); 47 | impl OnUnbalanced> for DealWithFees 48 | where 49 | R: pallet_balances::Config + pallet_collator_selection::Config, 50 | ::AccountId: From, 51 | ::AccountId: Into, 52 | ::Event: From>, 53 | { 54 | fn on_unbalanceds(mut fees_then_tips: impl Iterator>) { 55 | if let Some(mut fees) = fees_then_tips.next() { 56 | if let Some(tips) = fees_then_tips.next() { 57 | tips.merge_into(&mut fees); 58 | } 59 | as OnUnbalanced<_>>::on_unbalanced(fees); 60 | } 61 | } 62 | } 63 | 64 | #[cfg(test)] 65 | mod tests { 66 | use super::*; 67 | use frame_support::traits::FindAuthor; 68 | use frame_support::{parameter_types, weights::DispatchClass, PalletId}; 69 | use frame_system::{limits, EnsureRoot}; 70 | use polkadot_primitives::v1::AccountId; 71 | use sp_core::H256; 72 | use sp_runtime::{ 73 | testing::Header, 74 | traits::{BlakeTwo256, IdentityLookup}, 75 | Perbill, 76 | }; 77 | 78 | type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; 79 | type Block = frame_system::mocking::MockBlock; 80 | 81 | frame_support::construct_runtime!( 82 | pub enum Test where 83 | Block = Block, 84 | NodeBlock = Block, 85 | UncheckedExtrinsic = UncheckedExtrinsic, 86 | { 87 | System: frame_system::{Pallet, Call, Config, Storage, Event}, 88 | Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, 89 | CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event}, 90 | } 91 | ); 92 | 93 | parameter_types! { 94 | pub const BlockHashCount: u64 = 250; 95 | pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() 96 | .for_class(DispatchClass::all(), |weight| { 97 | weight.base_extrinsic = 100; 98 | }) 99 | .for_class(DispatchClass::non_mandatory(), |weight| { 100 | weight.max_total = Some(1024); 101 | }) 102 | .build_or_panic(); 103 | pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024); 104 | pub const AvailableBlockRatio: Perbill = Perbill::one(); 105 | } 106 | 107 | impl frame_system::Config for Test { 108 | type BaseCallFilter = (); 109 | type Origin = Origin; 110 | type Index = u64; 111 | type BlockNumber = u64; 112 | type Call = Call; 113 | type Hash = H256; 114 | type Hashing = BlakeTwo256; 115 | type AccountId = AccountId; 116 | type Lookup = IdentityLookup; 117 | type Header = Header; 118 | type Event = Event; 119 | type BlockHashCount = BlockHashCount; 120 | type BlockLength = BlockLength; 121 | type BlockWeights = BlockWeights; 122 | type DbWeight = (); 123 | type Version = (); 124 | type PalletInfo = PalletInfo; 125 | type AccountData = pallet_balances::AccountData; 126 | type OnNewAccount = (); 127 | type OnKilledAccount = (); 128 | type SystemWeightInfo = (); 129 | type SS58Prefix = (); 130 | type OnSetCode = (); 131 | } 132 | 133 | impl pallet_balances::Config for Test { 134 | type Balance = u64; 135 | type Event = Event; 136 | type DustRemoval = (); 137 | type ExistentialDeposit = (); 138 | type AccountStore = System; 139 | type MaxLocks = (); 140 | type WeightInfo = (); 141 | } 142 | 143 | pub struct OneAuthor; 144 | impl FindAuthor for OneAuthor { 145 | fn find_author<'a, I>(_: I) -> Option 146 | where 147 | I: 'a, 148 | { 149 | Some(Default::default()) 150 | } 151 | } 152 | 153 | parameter_types! { 154 | pub const PotId: PalletId = PalletId(*b"PotStake"); 155 | pub const MaxCandidates: u32 = 20; 156 | pub const MaxInvulnerables: u32 = 20; 157 | } 158 | 159 | impl pallet_collator_selection::Config for Test { 160 | type Event = Event; 161 | type Currency = Balances; 162 | type UpdateOrigin = EnsureRoot; 163 | type PotId = PotId; 164 | type MaxCandidates = MaxCandidates; 165 | type MaxInvulnerables = MaxInvulnerables; 166 | type KickThreshold = (); 167 | type WeightInfo = (); 168 | } 169 | 170 | impl pallet_authorship::Config for Test { 171 | type FindAuthor = OneAuthor; 172 | type UncleGenerations = (); 173 | type FilterUncle = (); 174 | type EventHandler = (); 175 | } 176 | 177 | pub fn new_test_ext() -> sp_io::TestExternalities { 178 | let mut t = frame_system::GenesisConfig::default() 179 | .build_storage::() 180 | .unwrap(); 181 | // We use default for brevity, but you can configure as desired if needed. 182 | pallet_balances::GenesisConfig::::default() 183 | .assimilate_storage(&mut t) 184 | .unwrap(); 185 | t.into() 186 | } 187 | 188 | #[test] 189 | fn test_fees_and_tip_split() { 190 | new_test_ext().execute_with(|| { 191 | let fee = Balances::issue(10); 192 | let tip = Balances::issue(20); 193 | 194 | assert_eq!(Balances::free_balance(AccountId::default()), 0); 195 | 196 | DealWithFees::on_unbalanceds(vec![fee, tip].into_iter()); 197 | 198 | // Author gets 100% of tip and 100% of fee = 30 199 | assert_eq!(Balances::free_balance(CollatorSelection::account_id()), 30); 200 | }); 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /runtime/common/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #![cfg_attr(not(feature = "std"), no_std)] 17 | 18 | pub mod impls; 19 | pub use types::*; 20 | pub use constants::*; 21 | 22 | /// Common types of statemint and statemine. 23 | mod types { 24 | use sp_runtime::traits::{Verify, IdentifyAccount, BlakeTwo256}; 25 | 26 | /// An index to a block. 27 | pub type BlockNumber = u32; 28 | 29 | /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. 30 | pub type Signature = sp_runtime::MultiSignature; 31 | 32 | /// Some way of identifying an account on the chain. We intentionally make it equivalent 33 | /// to the public key of our transaction signing scheme. 34 | pub type AccountId = <::Signer as IdentifyAccount>::AccountId; 35 | 36 | /// The type for looking up accounts. We don't expect more than 4 billion of them, but you 37 | /// never know... 38 | pub type AccountIndex = u32; 39 | 40 | /// Balance of an account. 41 | pub type Balance = u128; 42 | 43 | /// Index of a transaction in the chain. 44 | pub type Index = u32; 45 | 46 | /// A hash of some data used by the chain. 47 | pub type Hash = sp_core::H256; 48 | 49 | /// Block header type as expected by this runtime. 50 | pub type Header = sp_runtime::generic::Header; 51 | 52 | /// Digest item type. 53 | pub type DigestItem = sp_runtime::generic::DigestItem; 54 | 55 | // Aura consensus authority. 56 | pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; 57 | } 58 | 59 | /// Common constants of statemint and statemine 60 | mod constants { 61 | use super::types::BlockNumber; 62 | use sp_runtime::Perbill; 63 | use frame_support::weights::{Weight, constants::WEIGHT_PER_SECOND}; 64 | /// This determines the average expected block time that we are targeting. Blocks will be 65 | /// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by 66 | /// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn 67 | /// slot_duration()`. 68 | /// 69 | /// Change this to adjust the block time. 70 | pub const MILLISECS_PER_BLOCK: u64 = 12000; 71 | pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; 72 | 73 | // Time is measured by number of blocks. 74 | pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); 75 | pub const HOURS: BlockNumber = MINUTES * 60; 76 | pub const DAYS: BlockNumber = HOURS * 24; 77 | 78 | /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is 79 | /// used to limit the maximal weight of a single extrinsic. 80 | pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); 81 | /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by 82 | /// Operational extrinsics. 83 | pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); 84 | 85 | /// We allow for 0.5 seconds of compute with a 6 second average block time. 86 | pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2; 87 | } 88 | -------------------------------------------------------------------------------- /runtime/statemine/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies.substrate-wasm-builder] 2 | git = 'https://github.com/paritytech/substrate.git' 3 | branch = "master" 4 | version = '4.0.0' 5 | 6 | [package] 7 | authors = ['Anonymous'] 8 | edition = '2018' 9 | homepage = 'https://substrate.dev' 10 | license = 'Apache-2.0' 11 | name = 'statemine-runtime' 12 | repository = 'https://github.com/paritytech/statemint' 13 | version = '1.0.0' 14 | 15 | [dependencies] 16 | smallvec = "1.6.1" 17 | 18 | [package.metadata.docs.rs] 19 | targets = ['x86_64-unknown-linux-gnu'] 20 | 21 | [dependencies.codec] 22 | default-features = false 23 | features = ['derive'] 24 | package = 'parity-scale-codec' 25 | version = '2.0.0' 26 | 27 | [dependencies.frame-benchmarking] 28 | default-features = false 29 | git = 'https://github.com/paritytech/substrate.git' 30 | optional = true 31 | branch = "master" 32 | version = '3.0.0' 33 | 34 | [dependencies.frame-executive] 35 | default-features = false 36 | git = 'https://github.com/paritytech/substrate.git' 37 | branch = "master" 38 | version = '3.0.0' 39 | 40 | [dependencies.frame-support] 41 | default-features = false 42 | git = 'https://github.com/paritytech/substrate.git' 43 | branch = "master" 44 | version = '3.0.0' 45 | 46 | [dependencies.frame-system] 47 | default-features = false 48 | git = 'https://github.com/paritytech/substrate.git' 49 | branch = "master" 50 | version = '3.0.0' 51 | 52 | [dependencies.frame-system-benchmarking] 53 | default-features = false 54 | git = 'https://github.com/paritytech/substrate.git' 55 | optional = true 56 | branch = "master" 57 | version = '3.0.0' 58 | 59 | [dependencies.frame-system-rpc-runtime-api] 60 | default-features = false 61 | git = 'https://github.com/paritytech/substrate.git' 62 | branch = "master" 63 | version = '3.0.0' 64 | 65 | [dependencies.hex-literal] 66 | optional = true 67 | version = '0.3.1' 68 | 69 | [dependencies.pallet-assets] 70 | default-features = false 71 | git = 'https://github.com/paritytech/substrate.git' 72 | branch = "master" 73 | 74 | [dependencies.pallet-authorship] 75 | default-features = false 76 | git = 'https://github.com/paritytech/substrate.git' 77 | branch = "master" 78 | 79 | [dependencies.pallet-balances] 80 | default-features = false 81 | git = 'https://github.com/paritytech/substrate.git' 82 | branch = "master" 83 | version = '3.0.0' 84 | 85 | [dependencies.pallet-multisig] 86 | default-features = false 87 | git = 'https://github.com/paritytech/substrate.git' 88 | branch = "master" 89 | version = '3.0.0' 90 | 91 | [dependencies.pallet-proxy] 92 | default-features = false 93 | git = 'https://github.com/paritytech/substrate.git' 94 | branch = "master" 95 | version = '3.0.0' 96 | 97 | [dependencies.pallet-randomness-collective-flip] 98 | default-features = false 99 | git = 'https://github.com/paritytech/substrate.git' 100 | branch = "master" 101 | version = '3.0.0' 102 | 103 | [dependencies.pallet-timestamp] 104 | default-features = false 105 | git = 'https://github.com/paritytech/substrate.git' 106 | branch = "master" 107 | version = '3.0.0' 108 | 109 | [dependencies.pallet-transaction-payment] 110 | default-features = false 111 | git = 'https://github.com/paritytech/substrate.git' 112 | branch = "master" 113 | version = '3.0.0' 114 | 115 | [dependencies.pallet-transaction-payment-rpc-runtime-api] 116 | default-features = false 117 | git = 'https://github.com/paritytech/substrate.git' 118 | branch = "master" 119 | version = '3.0.0' 120 | 121 | [dependencies.pallet-utility] 122 | default-features = false 123 | git = 'https://github.com/paritytech/substrate.git' 124 | branch = "master" 125 | version = '3.0.0' 126 | 127 | [dependencies.pallet-aura] 128 | default-features = false 129 | git = 'https://github.com/paritytech/substrate.git' 130 | branch = "master" 131 | version = '3.0.0' 132 | 133 | [dependencies.serde] 134 | features = ['derive'] 135 | optional = true 136 | version = '1.0.119' 137 | 138 | [dependencies.node-primitives] 139 | default-features = false 140 | git = 'https://github.com/paritytech/substrate.git' 141 | branch = "master" 142 | 143 | [dependencies.sp-api] 144 | default-features = false 145 | git = 'https://github.com/paritytech/substrate.git' 146 | branch = "master" 147 | version = '3.0.0' 148 | 149 | [dependencies.sp-block-builder] 150 | default-features = false 151 | git = 'https://github.com/paritytech/substrate.git' 152 | branch = "master" 153 | version = '3.0.0' 154 | 155 | [dependencies.sp-core] 156 | default-features = false 157 | git = 'https://github.com/paritytech/substrate.git' 158 | branch = "master" 159 | version = '3.0.0' 160 | 161 | [dependencies.sp-inherents] 162 | default-features = false 163 | git = 'https://github.com/paritytech/substrate.git' 164 | branch = "master" 165 | version = '3.0.0' 166 | 167 | [dependencies.sp-io] 168 | default-features = false 169 | git = 'https://github.com/paritytech/substrate.git' 170 | branch = "master" 171 | version = '3.0.0' 172 | 173 | [dependencies.sp-offchain] 174 | default-features = false 175 | git = 'https://github.com/paritytech/substrate.git' 176 | branch = "master" 177 | version = '3.0.0' 178 | 179 | [dependencies.sp-runtime] 180 | default-features = false 181 | git = 'https://github.com/paritytech/substrate.git' 182 | branch = "master" 183 | version = '3.0.0' 184 | 185 | [dependencies.sp-session] 186 | default-features = false 187 | git = 'https://github.com/paritytech/substrate.git' 188 | branch = "master" 189 | version = '3.0.0' 190 | 191 | [dependencies.sp-std] 192 | default-features = false 193 | git = 'https://github.com/paritytech/substrate.git' 194 | branch = "master" 195 | version = '3.0.0' 196 | 197 | [dependencies.sp-transaction-pool] 198 | default-features = false 199 | git = 'https://github.com/paritytech/substrate.git' 200 | branch = "master" 201 | version = '3.0.0' 202 | 203 | [dependencies.sp-version] 204 | default-features = false 205 | git = 'https://github.com/paritytech/substrate.git' 206 | branch = "master" 207 | version = '3.0.0' 208 | 209 | [dependencies.sp-consensus-aura] 210 | default-features = false 211 | git = 'https://github.com/paritytech/substrate.git' 212 | branch = "master" 213 | version = '0.9.0' 214 | 215 | [dependencies.max-encoded-len] 216 | default-features = false 217 | git = 'https://github.com/paritytech/substrate.git' 218 | branch = "master" 219 | 220 | # Cumulus dependencies 221 | [dependencies.cumulus-pallet-aura-ext] 222 | default-features = false 223 | git = 'https://github.com/paritytech/cumulus.git' 224 | branch = "master" 225 | 226 | [dependencies.parachain-info] 227 | default-features = false 228 | git = 'https://github.com/paritytech/cumulus.git' 229 | branch = "master" 230 | version = '0.1.0' 231 | 232 | [dependencies.cumulus-pallet-parachain-system] 233 | git = 'https://github.com/paritytech/cumulus.git' 234 | branch = "master" 235 | default-features = false 236 | 237 | [dependencies.cumulus-primitives-core] 238 | git = 'https://github.com/paritytech/cumulus.git' 239 | branch = "master" 240 | default-features = false 241 | 242 | [dependencies.cumulus-primitives-utility] 243 | git = 'https://github.com/paritytech/cumulus.git' 244 | branch = "master" 245 | default-features = false 246 | 247 | [dependencies.cumulus-pallet-dmp-queue] 248 | git = 'https://github.com/paritytech/cumulus.git' 249 | branch = "master" 250 | default-features = false 251 | 252 | [dependencies.cumulus-pallet-xcmp-queue] 253 | git = 'https://github.com/paritytech/cumulus.git' 254 | branch = "master" 255 | default-features = false 256 | 257 | [dependencies.cumulus-pallet-xcm] 258 | git = 'https://github.com/paritytech/cumulus.git' 259 | branch = "master" 260 | default-features = false 261 | 262 | # Polkadot dependencies 263 | [dependencies.polkadot-primitives] 264 | git = 'https://github.com/paritytech/polkadot' 265 | branch = "master" 266 | default-features = false 267 | 268 | [dependencies.polkadot-runtime-common] 269 | git = 'https://github.com/paritytech/polkadot' 270 | branch = "master" 271 | default-features = false 272 | 273 | [dependencies.polkadot-parachain] 274 | git = 'https://github.com/paritytech/polkadot' 275 | branch = "master" 276 | default-features = false 277 | 278 | [dependencies.xcm] 279 | git = 'https://github.com/paritytech/polkadot' 280 | branch = "master" 281 | default-features = false 282 | 283 | [dependencies.xcm-builder] 284 | git = 'https://github.com/paritytech/polkadot' 285 | branch = "master" 286 | default-features = false 287 | 288 | [dependencies.xcm-executor] 289 | git = 'https://github.com/paritytech/polkadot' 290 | branch = "master" 291 | default-features = false 292 | 293 | [dependencies.pallet-xcm] 294 | git = 'https://github.com/paritytech/polkadot' 295 | branch = "master" 296 | default-features = false 297 | 298 | [dependencies.pallet-collator-selection] 299 | default-features = false 300 | path = '../../pallets/collator-selection' 301 | 302 | [dependencies.runtime-common] 303 | default-features = false 304 | version = "0.8.30" 305 | path = '../common' 306 | 307 | [dependencies.pallet-session] 308 | default-features = false 309 | git = 'https://github.com/paritytech/substrate.git' 310 | branch = "master" 311 | version = '3.0.0' 312 | 313 | 314 | [features] 315 | default = ['std'] 316 | runtime-benchmarks = [ 317 | 'hex-literal', 318 | 'xcm-builder/runtime-benchmarks', 319 | 'sp-runtime/runtime-benchmarks', 320 | 'frame-benchmarking', 321 | 'frame-support/runtime-benchmarks', 322 | 'frame-system-benchmarking', 323 | 'frame-system/runtime-benchmarks', 324 | 'pallet-assets/runtime-benchmarks', 325 | 'pallet-balances/runtime-benchmarks', 326 | 'pallet-multisig/runtime-benchmarks', 327 | 'pallet-proxy/runtime-benchmarks', 328 | 'pallet-utility/runtime-benchmarks', 329 | 'pallet-timestamp/runtime-benchmarks', 330 | 'pallet-collator-selection/runtime-benchmarks', 331 | 'pallet-xcm/runtime-benchmarks', 332 | ] 333 | std = [ 334 | 'codec/std', 335 | 'serde', 336 | 'sp-api/std', 337 | 'sp-std/std', 338 | 'sp-io/std', 339 | 'sp-core/std', 340 | 'sp-runtime/std', 341 | 'sp-version/std', 342 | 'sp-offchain/std', 343 | 'sp-session/std', 344 | 'sp-block-builder/std', 345 | 'sp-transaction-pool/std', 346 | 'sp-inherents/std', 347 | 'sp-consensus-aura/std', 348 | 'frame-support/std', 349 | 'frame-executive/std', 350 | 'frame-system/std', 351 | 'frame-system-rpc-runtime-api/std', 352 | 'pallet-assets/std', 353 | 'pallet-aura/std', 354 | 'pallet-authorship/std', 355 | 'pallet-balances/std', 356 | 'pallet-multisig/std', 357 | 'pallet-proxy/std', 358 | 'pallet-session/std', 359 | 'pallet-utility/std', 360 | 'pallet-randomness-collective-flip/std', 361 | 'pallet-transaction-payment-rpc-runtime-api/std', 362 | 'pallet-timestamp/std', 363 | 'pallet-xcm/std', 364 | 'pallet-transaction-payment/std', 365 | 'pallet-collator-selection/std', 366 | 'node-primitives/std', 367 | 'parachain-info/std', 368 | "cumulus-pallet-aura-ext/std", 369 | 'cumulus-pallet-parachain-system/std', 370 | 'cumulus-pallet-dmp-queue/std', 371 | "cumulus-pallet-xcmp-queue/std", 372 | "cumulus-pallet-xcm/std", 373 | "cumulus-primitives-core/std", 374 | "cumulus-primitives-utility/std", 375 | 'xcm/std', 376 | 'xcm-builder/std', 377 | 'xcm-executor/std', 378 | 'polkadot-runtime-common/std', 379 | 'runtime-common/std', 380 | 'polkadot-primitives/std', 381 | "max-encoded-len/std", 382 | ] 383 | -------------------------------------------------------------------------------- /runtime/statemine/build.rs: -------------------------------------------------------------------------------- 1 | use substrate_wasm_builder::WasmBuilder; 2 | 3 | fn main() { 4 | WasmBuilder::new() 5 | .with_current_project() 6 | .export_heap_base() 7 | .import_memory() 8 | .build() 9 | } 10 | -------------------------------------------------------------------------------- /runtime/statemine/src/constants.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | pub mod currency { 17 | use node_primitives::Balance; 18 | 19 | /// The existential deposit. Set to 1/10 of its parent Relay Chain (v9020). 20 | pub const EXISTENTIAL_DEPOSIT: Balance = CENTS / 10; 21 | 22 | pub const UNITS: Balance = 1_000_000_000_000; 23 | pub const CENTS: Balance = UNITS / 30_000; 24 | pub const GRAND: Balance = CENTS * 100_000; 25 | pub const MILLICENTS: Balance = CENTS / 1_000; 26 | 27 | pub const fn deposit(items: u32, bytes: u32) -> Balance { 28 | // map to 1/10 of what the kusama relay chain charges (v9020) 29 | (items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS) / 10 30 | } 31 | } 32 | 33 | /// Fee-related. 34 | pub mod fee { 35 | use node_primitives::Balance; 36 | pub use sp_runtime::Perbill; 37 | use frame_support::weights::{ 38 | constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, 39 | WeightToFeePolynomial, 40 | }; 41 | use smallvec::smallvec; 42 | 43 | /// The block saturation level. Fees will be updates based on this value. 44 | pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); 45 | 46 | /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the 47 | /// node's balance type. 48 | /// 49 | /// This should typically create a mapping between the following ranges: 50 | /// - [0, MAXIMUM_BLOCK_WEIGHT] 51 | /// - [Balance::min, Balance::max] 52 | /// 53 | /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: 54 | /// - Setting it to `0` will essentially disable the weight fee. 55 | /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. 56 | pub struct WeightToFee; 57 | impl WeightToFeePolynomial for WeightToFee { 58 | type Balance = Balance; 59 | fn polynomial() -> WeightToFeeCoefficients { 60 | // in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: 61 | // in Statemine, we map to 1/10 of that, or 1/100 CENT 62 | let p = super::currency::CENTS; 63 | let q = 100 * Balance::from(ExtrinsicBaseWeight::get()); 64 | smallvec![WeightToFeeCoefficient { 65 | degree: 1, 66 | negative: false, 67 | coeff_frac: Perbill::from_rational(p % q, q), 68 | coeff_integer: p / q, 69 | }] 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /runtime/statemine/src/weights/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod pallet_assets; 2 | pub mod pallet_balances; 3 | pub mod pallet_multisig; 4 | pub mod pallet_collator_selection; 5 | pub mod pallet_proxy; 6 | pub mod pallet_timestamp; 7 | pub mod pallet_utility; 8 | -------------------------------------------------------------------------------- /runtime/statemine/src/weights/pallet_assets.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_assets 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_assets 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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_assets. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_assets::WeightInfo for WeightInfo { 31 | fn create() -> Weight { 32 | (44_224_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn force_create() -> Weight { 37 | (22_533_000 as Weight) 38 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn destroy(c: u32, s: u32, a: u32, ) -> Weight { 42 | (0 as Weight) 43 | // Standard Error: 37_000 44 | .saturating_add((21_529_000 as Weight).saturating_mul(c as Weight)) 45 | // Standard Error: 37_000 46 | .saturating_add((28_905_000 as Weight).saturating_mul(s as Weight)) 47 | // Standard Error: 377_000 48 | .saturating_add((3_745_000 as Weight).saturating_mul(a as Weight)) 49 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 50 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 51 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) 52 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 53 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 54 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) 55 | .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) 56 | } 57 | fn mint() -> Weight { 58 | (49_078_000 as Weight) 59 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 60 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 61 | } 62 | fn burn() -> Weight { 63 | (55_886_000 as Weight) 64 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 65 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 66 | } 67 | fn transfer() -> Weight { 68 | (84_857_000 as Weight) 69 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 70 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 71 | } 72 | fn transfer_keep_alive() -> Weight { 73 | (71_330_000 as Weight) 74 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 75 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 76 | } 77 | fn force_transfer() -> Weight { 78 | (85_127_000 as Weight) 79 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 80 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 81 | } 82 | fn freeze() -> Weight { 83 | (31_403_000 as Weight) 84 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 85 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 86 | } 87 | fn thaw() -> Weight { 88 | (31_250_000 as Weight) 89 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 90 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 91 | } 92 | fn freeze_asset() -> Weight { 93 | (22_097_000 as Weight) 94 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 95 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 96 | } 97 | fn thaw_asset() -> Weight { 98 | (22_245_000 as Weight) 99 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 100 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 101 | } 102 | fn transfer_ownership() -> Weight { 103 | (25_479_000 as Weight) 104 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 105 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 106 | } 107 | fn set_team() -> Weight { 108 | (22_271_000 as Weight) 109 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 110 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 111 | } 112 | fn set_metadata(_n: u32, s: u32, ) -> Weight { 113 | (50_315_000 as Weight) 114 | // Standard Error: 0 115 | .saturating_add((8_000 as Weight).saturating_mul(s as Weight)) 116 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 117 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 118 | } 119 | fn clear_metadata() -> Weight { 120 | (48_134_000 as Weight) 121 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 122 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 123 | } 124 | fn force_set_metadata(_n: u32, s: u32, ) -> Weight { 125 | (25_933_000 as Weight) 126 | // Standard Error: 0 127 | .saturating_add((7_000 as Weight).saturating_mul(s as Weight)) 128 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 129 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 130 | } 131 | fn force_clear_metadata() -> Weight { 132 | (49_243_000 as Weight) 133 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 134 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 135 | } 136 | fn force_asset_status() -> Weight { 137 | (22_305_000 as Weight) 138 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 139 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 140 | } 141 | fn approve_transfer() -> Weight { 142 | (48_885_000 as Weight) 143 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 144 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 145 | } 146 | fn transfer_approved() -> Weight { 147 | (108_026_000 as Weight) 148 | .saturating_add(T::DbWeight::get().reads(5 as Weight)) 149 | .saturating_add(T::DbWeight::get().writes(5 as Weight)) 150 | } 151 | fn cancel_approval() -> Weight { 152 | (48_943_000 as Weight) 153 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 154 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 155 | } 156 | fn force_cancel_approval() -> Weight { 157 | (56_914_000 as Weight) 158 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 159 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /runtime/statemine/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_balances 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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 | fn transfer() -> Weight { 32 | (79_381_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn transfer_keep_alive() -> Weight { 37 | (58_057_000 as Weight) 38 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn set_balance_creating() -> Weight { 42 | (28_834_000 as Weight) 43 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 44 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 45 | } 46 | fn set_balance_killing() -> Weight { 47 | (36_213_000 as Weight) 48 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 49 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 50 | } 51 | fn force_transfer() -> Weight { 52 | (78_526_000 as Weight) 53 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 54 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /runtime/statemine/src/weights/pallet_collator_selection.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_collator_selection 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_collator_selection 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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_collator_selection. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_collator_selection::WeightInfo for WeightInfo { 31 | fn set_invulnerables(b: u32, ) -> Weight { 32 | (18_481_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((67_000 as Weight).saturating_mul(b as Weight)) 35 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 36 | } 37 | fn set_desired_candidates() -> Weight { 38 | (16_376_000 as Weight) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn set_candidacy_bond() -> Weight { 42 | (17_031_000 as Weight) 43 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 44 | } 45 | fn register_as_candidate(c: u32, ) -> Weight { 46 | (72_345_000 as Weight) 47 | // Standard Error: 0 48 | .saturating_add((197_000 as Weight).saturating_mul(c as Weight)) 49 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 50 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 51 | } 52 | fn leave_intent(c: u32, ) -> Weight { 53 | (55_446_000 as Weight) 54 | // Standard Error: 0 55 | .saturating_add((153_000 as Weight).saturating_mul(c as Weight)) 56 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 57 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 58 | } 59 | fn note_author() -> Weight { 60 | (71_828_000 as Weight) 61 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 62 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 63 | } 64 | fn new_session(r: u32, c: u32, ) -> Weight { 65 | (0 as Weight) 66 | // Standard Error: 1_004_000 67 | .saturating_add((110_066_000 as Weight).saturating_mul(r as Weight)) 68 | // Standard Error: 1_004_000 69 | .saturating_add((152_035_000 as Weight).saturating_mul(c as Weight)) 70 | .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) 71 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 72 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(r as Weight))) 73 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /runtime/statemine/src/weights/pallet_multisig.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_multisig 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_multisig 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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_multisig. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_multisig::WeightInfo for WeightInfo { 31 | fn as_multi_threshold_1(z: u32, ) -> Weight { 32 | (15_911_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 35 | } 36 | fn as_multi_create(s: u32, z: u32, ) -> Weight { 37 | (55_326_000 as Weight) 38 | // Standard Error: 0 39 | .saturating_add((133_000 as Weight).saturating_mul(s as Weight)) 40 | // Standard Error: 0 41 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 42 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 43 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 44 | } 45 | fn as_multi_create_store(s: u32, z: u32, ) -> Weight { 46 | (62_423_000 as Weight) 47 | // Standard Error: 0 48 | .saturating_add((133_000 as Weight).saturating_mul(s as Weight)) 49 | // Standard Error: 0 50 | .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) 51 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 52 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 53 | } 54 | fn as_multi_approve(s: u32, z: u32, ) -> Weight { 55 | (32_430_000 as Weight) 56 | // Standard Error: 0 57 | .saturating_add((148_000 as Weight).saturating_mul(s as Weight)) 58 | // Standard Error: 0 59 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 60 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 61 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 62 | } 63 | fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { 64 | (59_789_000 as Weight) 65 | // Standard Error: 0 66 | .saturating_add((165_000 as Weight).saturating_mul(s as Weight)) 67 | // Standard Error: 0 68 | .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) 69 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 70 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 71 | } 72 | fn as_multi_complete(s: u32, z: u32, ) -> Weight { 73 | (80_926_000 as Weight) 74 | // Standard Error: 0 75 | .saturating_add((276_000 as Weight).saturating_mul(s as Weight)) 76 | // Standard Error: 0 77 | .saturating_add((5_000 as Weight).saturating_mul(z as Weight)) 78 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 79 | .saturating_add(T::DbWeight::get().writes(3 as Weight)) 80 | } 81 | fn approve_as_multi_create(s: u32, ) -> Weight { 82 | (54_860_000 as Weight) 83 | // Standard Error: 0 84 | .saturating_add((134_000 as Weight).saturating_mul(s as Weight)) 85 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 86 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 87 | } 88 | fn approve_as_multi_approve(s: u32, ) -> Weight { 89 | (31_924_000 as Weight) 90 | // Standard Error: 0 91 | .saturating_add((154_000 as Weight).saturating_mul(s as Weight)) 92 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 93 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 94 | } 95 | fn approve_as_multi_complete(s: u32, ) -> Weight { 96 | (154_001_000 as Weight) 97 | // Standard Error: 0 98 | .saturating_add((281_000 as Weight).saturating_mul(s as Weight)) 99 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 100 | .saturating_add(T::DbWeight::get().writes(3 as Weight)) 101 | } 102 | fn cancel_as_multi(s: u32, ) -> Weight { 103 | (103_770_000 as Weight) 104 | // Standard Error: 0 105 | .saturating_add((130_000 as Weight).saturating_mul(s as Weight)) 106 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 107 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /runtime/statemine/src/weights/pallet_proxy.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_proxy 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_proxy 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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_proxy. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_proxy::WeightInfo for WeightInfo { 31 | fn proxy(p: u32, ) -> Weight { 32 | (27_318_000 as Weight) 33 | // Standard Error: 1_000 34 | .saturating_add((208_000 as Weight).saturating_mul(p as Weight)) 35 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 36 | } 37 | fn proxy_announced(a: u32, p: u32, ) -> Weight { 38 | (60_665_000 as Weight) 39 | // Standard Error: 2_000 40 | .saturating_add((677_000 as Weight).saturating_mul(a as Weight)) 41 | // Standard Error: 2_000 42 | .saturating_add((197_000 as Weight).saturating_mul(p as Weight)) 43 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 44 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 45 | } 46 | fn remove_announcement(a: u32, p: u32, ) -> Weight { 47 | (39_455_000 as Weight) 48 | // Standard Error: 2_000 49 | .saturating_add((687_000 as Weight).saturating_mul(a as Weight)) 50 | // Standard Error: 2_000 51 | .saturating_add((3_000 as Weight).saturating_mul(p as Weight)) 52 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 53 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 54 | } 55 | fn reject_announcement(a: u32, p: u32, ) -> Weight { 56 | (39_411_000 as Weight) 57 | // Standard Error: 2_000 58 | .saturating_add((686_000 as Weight).saturating_mul(a as Weight)) 59 | // Standard Error: 2_000 60 | .saturating_add((3_000 as Weight).saturating_mul(p as Weight)) 61 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 62 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 63 | } 64 | fn announce(a: u32, p: u32, ) -> Weight { 65 | (54_386_000 as Weight) 66 | // Standard Error: 2_000 67 | .saturating_add((677_000 as Weight).saturating_mul(a as Weight)) 68 | // Standard Error: 2_000 69 | .saturating_add((194_000 as Weight).saturating_mul(p as Weight)) 70 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 71 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 72 | } 73 | fn add_proxy(p: u32, ) -> Weight { 74 | (37_411_000 as Weight) 75 | // Standard Error: 2_000 76 | .saturating_add((298_000 as Weight).saturating_mul(p as Weight)) 77 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 78 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 79 | } 80 | fn remove_proxy(p: u32, ) -> Weight { 81 | (36_658_000 as Weight) 82 | // Standard Error: 2_000 83 | .saturating_add((332_000 as Weight).saturating_mul(p as Weight)) 84 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 85 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 86 | } 87 | fn remove_proxies(p: u32, ) -> Weight { 88 | (34_893_000 as Weight) 89 | // Standard Error: 1_000 90 | .saturating_add((209_000 as Weight).saturating_mul(p as Weight)) 91 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 92 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 93 | } 94 | fn anonymous(p: u32, ) -> Weight { 95 | (51_243_000 as Weight) 96 | // Standard Error: 1_000 97 | .saturating_add((44_000 as Weight).saturating_mul(p as Weight)) 98 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 99 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 100 | } 101 | fn kill_anonymous(p: u32, ) -> Weight { 102 | (37_188_000 as Weight) 103 | // Standard Error: 1_000 104 | .saturating_add((208_000 as Weight).saturating_mul(p as Weight)) 105 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 106 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /runtime/statemine/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_timestamp 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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 | fn set() -> Weight { 32 | (7_543_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn on_finalize() -> Weight { 37 | (4_272_000 as Weight) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime/statemine/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemine-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_utility 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemine/src/weights/ 20 | 21 | 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_utility. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_utility::WeightInfo for WeightInfo { 31 | fn batch(c: u32, ) -> Weight { 32 | (16_177_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((4_582_000 as Weight).saturating_mul(c as Weight)) 35 | } 36 | fn as_derivative() -> Weight { 37 | (7_848_000 as Weight) 38 | } 39 | fn batch_all(c: u32, ) -> Weight { 40 | (17_745_000 as Weight) 41 | // Standard Error: 0 42 | .saturating_add((4_578_000 as Weight).saturating_mul(c as Weight)) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /runtime/statemint/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies.substrate-wasm-builder] 2 | git = 'https://github.com/paritytech/substrate.git' 3 | branch = "master" 4 | version = '4.0.0' 5 | 6 | [package] 7 | authors = ['Anonymous'] 8 | edition = '2018' 9 | homepage = 'https://substrate.dev' 10 | license = 'Apache-2.0' 11 | name = 'statemint-runtime' 12 | repository = 'https://github.com/paritytech/statemint' 13 | version = '1.0.0' 14 | 15 | [dependencies] 16 | smallvec = "1.6.1" 17 | 18 | [package.metadata.docs.rs] 19 | targets = ['x86_64-unknown-linux-gnu'] 20 | 21 | [dependencies.codec] 22 | default-features = false 23 | features = ['derive'] 24 | package = 'parity-scale-codec' 25 | version = '2.0.0' 26 | 27 | [dependencies.frame-benchmarking] 28 | default-features = false 29 | git = 'https://github.com/paritytech/substrate.git' 30 | optional = true 31 | branch = "master" 32 | version = '3.0.0' 33 | 34 | [dependencies.frame-executive] 35 | default-features = false 36 | git = 'https://github.com/paritytech/substrate.git' 37 | branch = "master" 38 | version = '3.0.0' 39 | 40 | [dependencies.frame-support] 41 | default-features = false 42 | git = 'https://github.com/paritytech/substrate.git' 43 | branch = "master" 44 | version = '3.0.0' 45 | 46 | [dependencies.frame-system] 47 | default-features = false 48 | git = 'https://github.com/paritytech/substrate.git' 49 | branch = "master" 50 | version = '3.0.0' 51 | 52 | [dependencies.frame-system-benchmarking] 53 | default-features = false 54 | git = 'https://github.com/paritytech/substrate.git' 55 | optional = true 56 | branch = "master" 57 | version = '3.0.0' 58 | 59 | [dependencies.frame-system-rpc-runtime-api] 60 | default-features = false 61 | git = 'https://github.com/paritytech/substrate.git' 62 | branch = "master" 63 | version = '3.0.0' 64 | 65 | [dependencies.hex-literal] 66 | optional = true 67 | version = '0.3.1' 68 | 69 | [dependencies.pallet-assets] 70 | default-features = false 71 | git = 'https://github.com/paritytech/substrate.git' 72 | branch = "master" 73 | 74 | [dependencies.pallet-authorship] 75 | default-features = false 76 | git = 'https://github.com/paritytech/substrate.git' 77 | branch = "master" 78 | 79 | [dependencies.pallet-balances] 80 | default-features = false 81 | git = 'https://github.com/paritytech/substrate.git' 82 | branch = "master" 83 | version = '3.0.0' 84 | 85 | [dependencies.pallet-multisig] 86 | default-features = false 87 | git = 'https://github.com/paritytech/substrate.git' 88 | branch = "master" 89 | version = '3.0.0' 90 | 91 | [dependencies.pallet-proxy] 92 | default-features = false 93 | git = 'https://github.com/paritytech/substrate.git' 94 | branch = "master" 95 | version = '3.0.0' 96 | 97 | [dependencies.pallet-randomness-collective-flip] 98 | default-features = false 99 | git = 'https://github.com/paritytech/substrate.git' 100 | branch = "master" 101 | version = '3.0.0' 102 | 103 | [dependencies.pallet-timestamp] 104 | default-features = false 105 | git = 'https://github.com/paritytech/substrate.git' 106 | branch = "master" 107 | version = '3.0.0' 108 | 109 | [dependencies.pallet-transaction-payment] 110 | default-features = false 111 | git = 'https://github.com/paritytech/substrate.git' 112 | branch = "master" 113 | version = '3.0.0' 114 | 115 | [dependencies.pallet-transaction-payment-rpc-runtime-api] 116 | default-features = false 117 | git = 'https://github.com/paritytech/substrate.git' 118 | branch = "master" 119 | version = '3.0.0' 120 | 121 | [dependencies.pallet-utility] 122 | default-features = false 123 | git = 'https://github.com/paritytech/substrate.git' 124 | branch = "master" 125 | version = '3.0.0' 126 | 127 | [dependencies.pallet-aura] 128 | default-features = false 129 | git = 'https://github.com/paritytech/substrate.git' 130 | branch = "master" 131 | version = '3.0.0' 132 | 133 | [dependencies.max-encoded-len] 134 | default-features = false 135 | git = 'https://github.com/paritytech/substrate.git' 136 | branch = "master" 137 | 138 | [dependencies.serde] 139 | features = ['derive'] 140 | optional = true 141 | version = '1.0.119' 142 | 143 | [dependencies.node-primitives] 144 | default-features = false 145 | git = 'https://github.com/paritytech/substrate.git' 146 | branch = "master" 147 | 148 | [dependencies.sp-api] 149 | default-features = false 150 | git = 'https://github.com/paritytech/substrate.git' 151 | branch = "master" 152 | version = '3.0.0' 153 | 154 | [dependencies.sp-block-builder] 155 | default-features = false 156 | git = 'https://github.com/paritytech/substrate.git' 157 | branch = "master" 158 | version = '3.0.0' 159 | 160 | [dependencies.sp-core] 161 | default-features = false 162 | git = 'https://github.com/paritytech/substrate.git' 163 | branch = "master" 164 | version = '3.0.0' 165 | 166 | [dependencies.sp-inherents] 167 | default-features = false 168 | git = 'https://github.com/paritytech/substrate.git' 169 | branch = "master" 170 | version = '3.0.0' 171 | 172 | [dependencies.sp-io] 173 | default-features = false 174 | git = 'https://github.com/paritytech/substrate.git' 175 | branch = "master" 176 | version = '3.0.0' 177 | 178 | [dependencies.sp-offchain] 179 | default-features = false 180 | git = 'https://github.com/paritytech/substrate.git' 181 | branch = "master" 182 | version = '3.0.0' 183 | 184 | [dependencies.sp-runtime] 185 | default-features = false 186 | git = 'https://github.com/paritytech/substrate.git' 187 | branch = "master" 188 | version = '3.0.0' 189 | 190 | [dependencies.sp-session] 191 | default-features = false 192 | git = 'https://github.com/paritytech/substrate.git' 193 | branch = "master" 194 | version = '3.0.0' 195 | 196 | [dependencies.sp-std] 197 | default-features = false 198 | git = 'https://github.com/paritytech/substrate.git' 199 | branch = "master" 200 | version = '3.0.0' 201 | 202 | [dependencies.sp-transaction-pool] 203 | default-features = false 204 | git = 'https://github.com/paritytech/substrate.git' 205 | branch = "master" 206 | version = '3.0.0' 207 | 208 | [dependencies.sp-version] 209 | default-features = false 210 | git = 'https://github.com/paritytech/substrate.git' 211 | branch = "master" 212 | version = '3.0.0' 213 | 214 | [dependencies.sp-consensus-aura] 215 | default-features = false 216 | git = 'https://github.com/paritytech/substrate.git' 217 | branch = "master" 218 | version = '0.9.0' 219 | 220 | # Cumulus dependencies 221 | [dependencies.cumulus-pallet-aura-ext] 222 | default-features = false 223 | git = 'https://github.com/paritytech/cumulus.git' 224 | branch = "master" 225 | 226 | [dependencies.parachain-info] 227 | default-features = false 228 | git = 'https://github.com/paritytech/cumulus.git' 229 | branch = "master" 230 | version = '0.1.0' 231 | 232 | [dependencies.cumulus-pallet-parachain-system] 233 | git = 'https://github.com/paritytech/cumulus.git' 234 | branch = "master" 235 | default-features = false 236 | 237 | [dependencies.cumulus-primitives-core] 238 | git = 'https://github.com/paritytech/cumulus.git' 239 | branch = "master" 240 | default-features = false 241 | 242 | [dependencies.cumulus-primitives-utility] 243 | git = 'https://github.com/paritytech/cumulus.git' 244 | branch = "master" 245 | default-features = false 246 | 247 | [dependencies.cumulus-pallet-dmp-queue] 248 | git = 'https://github.com/paritytech/cumulus.git' 249 | branch = "master" 250 | default-features = false 251 | 252 | [dependencies.cumulus-pallet-xcmp-queue] 253 | git = 'https://github.com/paritytech/cumulus.git' 254 | branch = "master" 255 | default-features = false 256 | 257 | [dependencies.cumulus-pallet-xcm] 258 | git = 'https://github.com/paritytech/cumulus.git' 259 | branch = "master" 260 | default-features = false 261 | 262 | # Polkadot dependencies 263 | [dependencies.polkadot-primitives] 264 | git = 'https://github.com/paritytech/polkadot' 265 | branch = "master" 266 | default-features = false 267 | 268 | [dependencies.polkadot-runtime-common] 269 | git = 'https://github.com/paritytech/polkadot' 270 | branch = "master" 271 | default-features = false 272 | 273 | [dependencies.polkadot-parachain] 274 | git = 'https://github.com/paritytech/polkadot' 275 | branch = "master" 276 | default-features = false 277 | 278 | [dependencies.xcm] 279 | git = 'https://github.com/paritytech/polkadot' 280 | branch = "master" 281 | default-features = false 282 | 283 | [dependencies.xcm-builder] 284 | git = 'https://github.com/paritytech/polkadot' 285 | branch = "master" 286 | default-features = false 287 | 288 | [dependencies.xcm-executor] 289 | git = 'https://github.com/paritytech/polkadot' 290 | branch = "master" 291 | default-features = false 292 | 293 | [dependencies.pallet-xcm] 294 | git = 'https://github.com/paritytech/polkadot' 295 | branch = "master" 296 | default-features = false 297 | 298 | [dependencies.pallet-collator-selection] 299 | default-features = false 300 | path = '../../pallets/collator-selection' 301 | 302 | [dependencies.runtime-common] 303 | default-features = false 304 | version = "0.8.30" 305 | path = '../common' 306 | 307 | [dependencies.pallet-session] 308 | default-features = false 309 | git = 'https://github.com/paritytech/substrate.git' 310 | branch = "master" 311 | version = '3.0.0' 312 | 313 | [features] 314 | default = ['std'] 315 | runtime-benchmarks = [ 316 | 'hex-literal', 317 | 'sp-runtime/runtime-benchmarks', 318 | 'xcm-builder/runtime-benchmarks', 319 | 'frame-benchmarking', 320 | 'frame-system-benchmarking', 321 | 'frame-support/runtime-benchmarks', 322 | 'frame-system/runtime-benchmarks', 323 | 'pallet-assets/runtime-benchmarks', 324 | 'pallet-balances/runtime-benchmarks', 325 | 'pallet-multisig/runtime-benchmarks', 326 | 'pallet-proxy/runtime-benchmarks', 327 | 'pallet-utility/runtime-benchmarks', 328 | 'pallet-timestamp/runtime-benchmarks', 329 | 'pallet-xcm/runtime-benchmarks', 330 | 'pallet-collator-selection/runtime-benchmarks', 331 | ] 332 | std = [ 333 | 'codec/std', 334 | 'serde', 335 | 'sp-consensus-aura/std', 336 | 'pallet-aura/std', 337 | 'sp-api/std', 338 | 'sp-std/std', 339 | 'sp-io/std', 340 | 'sp-core/std', 341 | 'sp-runtime/std', 342 | 'sp-version/std', 343 | 'sp-offchain/std', 344 | 'sp-session/std', 345 | 'sp-block-builder/std', 346 | 'sp-transaction-pool/std', 347 | 'sp-inherents/std', 348 | 'frame-support/std', 349 | 'frame-executive/std', 350 | 'frame-system/std', 351 | 'frame-system-rpc-runtime-api/std', 352 | 'pallet-assets/std', 353 | 'pallet-authorship/std', 354 | 'pallet-balances/std', 355 | 'pallet-multisig/std', 356 | 'pallet-proxy/std', 357 | 'pallet-utility/std', 358 | 'pallet-randomness-collective-flip/std', 359 | 'pallet-transaction-payment-rpc-runtime-api/std', 360 | 'pallet-timestamp/std', 361 | 'pallet-session/std', 362 | 'pallet-xcm/std', 363 | 'pallet-transaction-payment/std', 364 | 'pallet-collator-selection/std', 365 | 'node-primitives/std', 366 | 'parachain-info/std', 367 | "cumulus-pallet-aura-ext/std", 368 | 'cumulus-pallet-parachain-system/std', 369 | 'cumulus-pallet-dmp-queue/std', 370 | "cumulus-pallet-xcmp-queue/std", 371 | "cumulus-pallet-xcm/std", 372 | "cumulus-primitives-core/std", 373 | "cumulus-primitives-utility/std", 374 | 'xcm/std', 375 | 'xcm-builder/std', 376 | 'xcm-executor/std', 377 | 'polkadot-runtime-common/std', 378 | 'runtime-common/std', 379 | 'polkadot-primitives/std', 380 | "max-encoded-len/std", 381 | ] 382 | -------------------------------------------------------------------------------- /runtime/statemint/build.rs: -------------------------------------------------------------------------------- 1 | use substrate_wasm_builder::WasmBuilder; 2 | 3 | fn main() { 4 | WasmBuilder::new() 5 | .with_current_project() 6 | .export_heap_base() 7 | .import_memory() 8 | .build() 9 | } 10 | -------------------------------------------------------------------------------- /runtime/statemint/src/constants.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | pub mod currency { 17 | use node_primitives::Balance; 18 | 19 | /// The existential deposit. Set to 1/10 of its parent Relay Chain (v9010). 20 | pub const EXISTENTIAL_DEPOSIT: Balance = 10 * CENTS; 21 | 22 | pub const UNITS: Balance = 10_000_000_000; 23 | pub const DOLLARS: Balance = UNITS; 24 | pub const CENTS: Balance = UNITS / 100; // 100_000_000 25 | pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000 26 | 27 | pub const fn deposit(items: u32, bytes: u32) -> Balance { 28 | // 1/10 of Polkadot v9010 29 | (items as Balance * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS) / 10 30 | } 31 | } 32 | 33 | /// Fee-related. 34 | pub mod fee { 35 | use node_primitives::Balance; 36 | pub use sp_runtime::Perbill; 37 | use frame_support::weights::{ 38 | constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, 39 | WeightToFeePolynomial, 40 | }; 41 | use smallvec::smallvec; 42 | 43 | /// The block saturation level. Fees will be updates based on this value. 44 | pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); 45 | 46 | /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the 47 | /// node's balance type. 48 | /// 49 | /// This should typically create a mapping between the following ranges: 50 | /// - [0, MAXIMUM_BLOCK_WEIGHT] 51 | /// - [Balance::min, Balance::max] 52 | /// 53 | /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: 54 | /// - Setting it to `0` will essentially disable the weight fee. 55 | /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. 56 | pub struct WeightToFee; 57 | impl WeightToFeePolynomial for WeightToFee { 58 | type Balance = Balance; 59 | fn polynomial() -> WeightToFeeCoefficients { 60 | // in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: 61 | // in Statemint, we map to 1/10 of that, or 1/100 CENT 62 | let p = super::currency::CENTS; 63 | let q = 100 * Balance::from(ExtrinsicBaseWeight::get()); 64 | smallvec![WeightToFeeCoefficient { 65 | degree: 1, 66 | negative: false, 67 | coeff_frac: Perbill::from_rational(p % q, q), 68 | coeff_integer: p / q, 69 | }] 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /runtime/statemint/src/weights/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod pallet_assets; 2 | pub mod pallet_balances; 3 | pub mod pallet_multisig; 4 | pub mod pallet_collator_selection; 5 | pub mod pallet_proxy; 6 | pub mod pallet_timestamp; 7 | pub mod pallet_utility; 8 | -------------------------------------------------------------------------------- /runtime/statemint/src/weights/pallet_assets.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_assets 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_assets 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_assets. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_assets::WeightInfo for WeightInfo { 31 | fn create() -> Weight { 32 | (44_125_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn force_create() -> Weight { 37 | (22_842_000 as Weight) 38 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn destroy(c: u32, s: u32, a: u32, ) -> Weight { 42 | (0 as Weight) 43 | // Standard Error: 37_000 44 | .saturating_add((21_822_000 as Weight).saturating_mul(c as Weight)) 45 | // Standard Error: 37_000 46 | .saturating_add((29_044_000 as Weight).saturating_mul(s as Weight)) 47 | // Standard Error: 370_000 48 | .saturating_add((3_000_000 as Weight).saturating_mul(a as Weight)) 49 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 50 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 51 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) 52 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 53 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 54 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) 55 | .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) 56 | } 57 | fn mint() -> Weight { 58 | (49_933_000 as Weight) 59 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 60 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 61 | } 62 | fn burn() -> Weight { 63 | (56_434_000 as Weight) 64 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 65 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 66 | } 67 | fn transfer() -> Weight { 68 | (85_393_000 as Weight) 69 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 70 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 71 | } 72 | fn transfer_keep_alive() -> Weight { 73 | (72_039_000 as Weight) 74 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 75 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 76 | } 77 | fn force_transfer() -> Weight { 78 | (85_214_000 as Weight) 79 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 80 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 81 | } 82 | fn freeze() -> Weight { 83 | (31_915_000 as Weight) 84 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 85 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 86 | } 87 | fn thaw() -> Weight { 88 | (31_296_000 as Weight) 89 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 90 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 91 | } 92 | fn freeze_asset() -> Weight { 93 | (22_272_000 as Weight) 94 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 95 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 96 | } 97 | fn thaw_asset() -> Weight { 98 | (22_336_000 as Weight) 99 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 100 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 101 | } 102 | fn transfer_ownership() -> Weight { 103 | (25_526_000 as Weight) 104 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 105 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 106 | } 107 | fn set_team() -> Weight { 108 | (22_632_000 as Weight) 109 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 110 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 111 | } 112 | fn set_metadata(_n: u32, s: u32, ) -> Weight { 113 | (50_330_000 as Weight) 114 | // Standard Error: 0 115 | .saturating_add((9_000 as Weight).saturating_mul(s as Weight)) 116 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 117 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 118 | } 119 | fn clear_metadata() -> Weight { 120 | (48_266_000 as Weight) 121 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 122 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 123 | } 124 | fn force_set_metadata(_n: u32, s: u32, ) -> Weight { 125 | (26_249_000 as Weight) 126 | // Standard Error: 0 127 | .saturating_add((6_000 as Weight).saturating_mul(s as Weight)) 128 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 129 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 130 | } 131 | fn force_clear_metadata() -> Weight { 132 | (49_616_000 as Weight) 133 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 134 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 135 | } 136 | fn force_asset_status() -> Weight { 137 | (22_596_000 as Weight) 138 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 139 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 140 | } 141 | fn approve_transfer() -> Weight { 142 | (48_708_000 as Weight) 143 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 144 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 145 | } 146 | fn transfer_approved() -> Weight { 147 | (108_476_000 as Weight) 148 | .saturating_add(T::DbWeight::get().reads(5 as Weight)) 149 | .saturating_add(T::DbWeight::get().writes(5 as Weight)) 150 | } 151 | fn cancel_approval() -> Weight { 152 | (49_157_000 as Weight) 153 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 154 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 155 | } 156 | fn force_cancel_approval() -> Weight { 157 | (56_862_000 as Weight) 158 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 159 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /runtime/statemint/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_balances 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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 | fn transfer() -> Weight { 32 | (79_601_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn transfer_keep_alive() -> Weight { 37 | (58_429_000 as Weight) 38 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn set_balance_creating() -> Weight { 42 | (29_124_000 as Weight) 43 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 44 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 45 | } 46 | fn set_balance_killing() -> Weight { 47 | (36_476_000 as Weight) 48 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 49 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 50 | } 51 | fn force_transfer() -> Weight { 52 | (78_772_000 as Weight) 53 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 54 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /runtime/statemint/src/weights/pallet_collator_selection.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_collator_selection 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_collator_selection 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_collator_selection. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_collator_selection::WeightInfo for WeightInfo { 31 | fn set_invulnerables(b: u32, ) -> Weight { 32 | (18_563_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((68_000 as Weight).saturating_mul(b as Weight)) 35 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 36 | } 37 | fn set_desired_candidates() -> Weight { 38 | (16_363_000 as Weight) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn set_candidacy_bond() -> Weight { 42 | (16_840_000 as Weight) 43 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 44 | } 45 | fn register_as_candidate(c: u32, ) -> Weight { 46 | (71_196_000 as Weight) 47 | // Standard Error: 0 48 | .saturating_add((198_000 as Weight).saturating_mul(c as Weight)) 49 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 50 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 51 | } 52 | fn leave_intent(c: u32, ) -> Weight { 53 | (55_336_000 as Weight) 54 | // Standard Error: 0 55 | .saturating_add((151_000 as Weight).saturating_mul(c as Weight)) 56 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 57 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 58 | } 59 | fn note_author() -> Weight { 60 | (71_461_000 as Weight) 61 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 62 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 63 | } 64 | fn new_session(r: u32, c: u32, ) -> Weight { 65 | (0 as Weight) 66 | // Standard Error: 1_010_000 67 | .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) 68 | // Standard Error: 1_010_000 69 | .saturating_add((151_952_000 as Weight).saturating_mul(c as Weight)) 70 | .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) 71 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 72 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(r as Weight))) 73 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /runtime/statemint/src/weights/pallet_multisig.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_multisig 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_multisig 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_multisig. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_multisig::WeightInfo for WeightInfo { 31 | fn as_multi_threshold_1(z: u32, ) -> Weight { 32 | (14_936_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 35 | } 36 | fn as_multi_create(s: u32, z: u32, ) -> Weight { 37 | (56_090_000 as Weight) 38 | // Standard Error: 1_000 39 | .saturating_add((63_000 as Weight).saturating_mul(s as Weight)) 40 | // Standard Error: 0 41 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 42 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 43 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 44 | } 45 | fn as_multi_create_store(s: u32, z: u32, ) -> Weight { 46 | (62_519_000 as Weight) 47 | // Standard Error: 1_000 48 | .saturating_add((66_000 as Weight).saturating_mul(s as Weight)) 49 | // Standard Error: 0 50 | .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) 51 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 52 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 53 | } 54 | fn as_multi_approve(s: u32, z: u32, ) -> Weight { 55 | (30_781_000 as Weight) 56 | // Standard Error: 0 57 | .saturating_add((111_000 as Weight).saturating_mul(s as Weight)) 58 | // Standard Error: 0 59 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 60 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 61 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 62 | } 63 | fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { 64 | (60_393_000 as Weight) 65 | // Standard Error: 0 66 | .saturating_add((118_000 as Weight).saturating_mul(s as Weight)) 67 | // Standard Error: 0 68 | .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) 69 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 70 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 71 | } 72 | fn as_multi_complete(s: u32, z: u32, ) -> Weight { 73 | (81_704_000 as Weight) 74 | // Standard Error: 1_000 75 | .saturating_add((248_000 as Weight).saturating_mul(s as Weight)) 76 | // Standard Error: 0 77 | .saturating_add((5_000 as Weight).saturating_mul(z as Weight)) 78 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 79 | .saturating_add(T::DbWeight::get().writes(3 as Weight)) 80 | } 81 | fn approve_as_multi_create(s: u32, ) -> Weight { 82 | (55_585_000 as Weight) 83 | // Standard Error: 1_000 84 | .saturating_add((115_000 as Weight).saturating_mul(s as Weight)) 85 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 86 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 87 | } 88 | fn approve_as_multi_approve(s: u32, ) -> Weight { 89 | (33_483_000 as Weight) 90 | // Standard Error: 1_000 91 | .saturating_add((82_000 as Weight).saturating_mul(s as Weight)) 92 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 93 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 94 | } 95 | fn approve_as_multi_complete(s: u32, ) -> Weight { 96 | (154_732_000 as Weight) 97 | // Standard Error: 1_000 98 | .saturating_add((253_000 as Weight).saturating_mul(s as Weight)) 99 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 100 | .saturating_add(T::DbWeight::get().writes(3 as Weight)) 101 | } 102 | fn cancel_as_multi(s: u32, ) -> Weight { 103 | (104_447_000 as Weight) 104 | // Standard Error: 1_000 105 | .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) 106 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 107 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /runtime/statemint/src/weights/pallet_proxy.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_proxy 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_proxy 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_proxy. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_proxy::WeightInfo for WeightInfo { 31 | fn proxy(p: u32, ) -> Weight { 32 | (27_585_000 as Weight) 33 | // Standard Error: 1_000 34 | .saturating_add((203_000 as Weight).saturating_mul(p as Weight)) 35 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 36 | } 37 | fn proxy_announced(a: u32, p: u32, ) -> Weight { 38 | (61_093_000 as Weight) 39 | // Standard Error: 2_000 40 | .saturating_add((680_000 as Weight).saturating_mul(a as Weight)) 41 | // Standard Error: 2_000 42 | .saturating_add((201_000 as Weight).saturating_mul(p as Weight)) 43 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 44 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 45 | } 46 | fn remove_announcement(a: u32, p: u32, ) -> Weight { 47 | (39_494_000 as Weight) 48 | // Standard Error: 2_000 49 | .saturating_add((686_000 as Weight).saturating_mul(a as Weight)) 50 | // Standard Error: 2_000 51 | .saturating_add((1_000 as Weight).saturating_mul(p as Weight)) 52 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 53 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 54 | } 55 | fn reject_announcement(a: u32, p: u32, ) -> Weight { 56 | (39_817_000 as Weight) 57 | // Standard Error: 2_000 58 | .saturating_add((685_000 as Weight).saturating_mul(a as Weight)) 59 | // Standard Error: 2_000 60 | .saturating_add((1_000 as Weight).saturating_mul(p as Weight)) 61 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 62 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 63 | } 64 | fn announce(a: u32, p: u32, ) -> Weight { 65 | (54_835_000 as Weight) 66 | // Standard Error: 2_000 67 | .saturating_add((684_000 as Weight).saturating_mul(a as Weight)) 68 | // Standard Error: 2_000 69 | .saturating_add((205_000 as Weight).saturating_mul(p as Weight)) 70 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 71 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 72 | } 73 | fn add_proxy(p: u32, ) -> Weight { 74 | (37_625_000 as Weight) 75 | // Standard Error: 2_000 76 | .saturating_add((300_000 as Weight).saturating_mul(p as Weight)) 77 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 78 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 79 | } 80 | fn remove_proxy(p: u32, ) -> Weight { 81 | (36_945_000 as Weight) 82 | // Standard Error: 3_000 83 | .saturating_add((325_000 as Weight).saturating_mul(p as Weight)) 84 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 85 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 86 | } 87 | fn remove_proxies(p: u32, ) -> Weight { 88 | (35_128_000 as Weight) 89 | // Standard Error: 1_000 90 | .saturating_add((209_000 as Weight).saturating_mul(p as Weight)) 91 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 92 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 93 | } 94 | fn anonymous(p: u32, ) -> Weight { 95 | (51_624_000 as Weight) 96 | // Standard Error: 1_000 97 | .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) 98 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 99 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 100 | } 101 | fn kill_anonymous(p: u32, ) -> Weight { 102 | (37_469_000 as Weight) 103 | // Standard Error: 1_000 104 | .saturating_add((204_000 as Weight).saturating_mul(p as Weight)) 105 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 106 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /runtime/statemint/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_timestamp 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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 | fn set() -> Weight { 32 | (7_687_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn on_finalize() -> Weight { 37 | (4_303_000 as Weight) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime/statemint/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_utility 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_utility. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_utility::WeightInfo for WeightInfo { 31 | fn batch(c: u32, ) -> Weight { 32 | (15_408_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) 35 | } 36 | fn as_derivative() -> Weight { 37 | (7_817_000 as Weight) 38 | } 39 | fn batch_all(c: u32, ) -> Weight { 40 | (16_520_000 as Weight) 41 | // Standard Error: 0 42 | .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /runtime/westmint/build.rs: -------------------------------------------------------------------------------- 1 | use substrate_wasm_builder::WasmBuilder; 2 | 3 | fn main() { 4 | WasmBuilder::new() 5 | .with_current_project() 6 | .export_heap_base() 7 | .import_memory() 8 | .build() 9 | } 10 | -------------------------------------------------------------------------------- /runtime/westmint/src/constants.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Parity Technologies (UK) Ltd. 2 | // SPDX-License-Identifier: Apache-2.0 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 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | pub mod currency { 17 | use node_primitives::Balance; 18 | 19 | /// The existential deposit. Set to 1/10 of its parent Relay Chain. 20 | pub const EXISTENTIAL_DEPOSIT: Balance = 100 * MILLICENTS; 21 | 22 | pub const UNITS: Balance = 1_000_000_000_000; 23 | pub const CENTS: Balance = UNITS / 100; 24 | pub const MILLICENTS: Balance = CENTS / 1_000; 25 | pub const GRAND: Balance = CENTS * 100_000; 26 | 27 | pub const fn deposit(items: u32, bytes: u32) -> Balance { 28 | // 1/10 of Westend testnet 29 | (items as Balance * 100 * CENTS + (bytes as Balance) * 5 * MILLICENTS) / 10 30 | } 31 | } 32 | 33 | /// Fee-related. 34 | pub mod fee { 35 | use node_primitives::Balance; 36 | pub use sp_runtime::Perbill; 37 | use frame_support::weights::{ 38 | constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, 39 | WeightToFeePolynomial, 40 | }; 41 | use smallvec::smallvec; 42 | 43 | /// The block saturation level. Fees will be updates based on this value. 44 | pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); 45 | 46 | /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the 47 | /// node's balance type. 48 | /// 49 | /// This should typically create a mapping between the following ranges: 50 | /// - [0, MAXIMUM_BLOCK_WEIGHT] 51 | /// - [Balance::min, Balance::max] 52 | /// 53 | /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: 54 | /// - Setting it to `0` will essentially disable the weight fee. 55 | /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. 56 | pub struct WeightToFee; 57 | impl WeightToFeePolynomial for WeightToFee { 58 | type Balance = Balance; 59 | fn polynomial() -> WeightToFeeCoefficients { 60 | // in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: 61 | // in Statemint, we map to 1/10 of that, or 1/100 CENT 62 | let p = super::currency::CENTS; 63 | let q = 100 * Balance::from(ExtrinsicBaseWeight::get()); 64 | smallvec![WeightToFeeCoefficient { 65 | degree: 1, 66 | negative: false, 67 | coeff_frac: Perbill::from_rational(p % q, q), 68 | coeff_integer: p / q, 69 | }] 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /runtime/westmint/src/weights/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod pallet_assets; 2 | pub mod pallet_balances; 3 | pub mod pallet_multisig; 4 | pub mod pallet_collator_selection; 5 | pub mod pallet_proxy; 6 | pub mod pallet_timestamp; 7 | pub mod pallet_utility; 8 | -------------------------------------------------------------------------------- /runtime/westmint/src/weights/pallet_assets.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_assets 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_assets 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_assets. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_assets::WeightInfo for WeightInfo { 31 | fn create() -> Weight { 32 | (44_125_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn force_create() -> Weight { 37 | (22_842_000 as Weight) 38 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn destroy(c: u32, s: u32, a: u32, ) -> Weight { 42 | (0 as Weight) 43 | // Standard Error: 37_000 44 | .saturating_add((21_822_000 as Weight).saturating_mul(c as Weight)) 45 | // Standard Error: 37_000 46 | .saturating_add((29_044_000 as Weight).saturating_mul(s as Weight)) 47 | // Standard Error: 370_000 48 | .saturating_add((3_000_000 as Weight).saturating_mul(a as Weight)) 49 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 50 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 51 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) 52 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 53 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 54 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) 55 | .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) 56 | } 57 | fn mint() -> Weight { 58 | (49_933_000 as Weight) 59 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 60 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 61 | } 62 | fn burn() -> Weight { 63 | (56_434_000 as Weight) 64 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 65 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 66 | } 67 | fn transfer() -> Weight { 68 | (85_393_000 as Weight) 69 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 70 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 71 | } 72 | fn transfer_keep_alive() -> Weight { 73 | (72_039_000 as Weight) 74 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 75 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 76 | } 77 | fn force_transfer() -> Weight { 78 | (85_214_000 as Weight) 79 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 80 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 81 | } 82 | fn freeze() -> Weight { 83 | (31_915_000 as Weight) 84 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 85 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 86 | } 87 | fn thaw() -> Weight { 88 | (31_296_000 as Weight) 89 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 90 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 91 | } 92 | fn freeze_asset() -> Weight { 93 | (22_272_000 as Weight) 94 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 95 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 96 | } 97 | fn thaw_asset() -> Weight { 98 | (22_336_000 as Weight) 99 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 100 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 101 | } 102 | fn transfer_ownership() -> Weight { 103 | (25_526_000 as Weight) 104 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 105 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 106 | } 107 | fn set_team() -> Weight { 108 | (22_632_000 as Weight) 109 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 110 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 111 | } 112 | fn set_metadata(_n: u32, s: u32, ) -> Weight { 113 | (50_330_000 as Weight) 114 | // Standard Error: 0 115 | .saturating_add((9_000 as Weight).saturating_mul(s as Weight)) 116 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 117 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 118 | } 119 | fn clear_metadata() -> Weight { 120 | (48_266_000 as Weight) 121 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 122 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 123 | } 124 | fn force_set_metadata(_n: u32, s: u32, ) -> Weight { 125 | (26_249_000 as Weight) 126 | // Standard Error: 0 127 | .saturating_add((6_000 as Weight).saturating_mul(s as Weight)) 128 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 129 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 130 | } 131 | fn force_clear_metadata() -> Weight { 132 | (49_616_000 as Weight) 133 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 134 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 135 | } 136 | fn force_asset_status() -> Weight { 137 | (22_596_000 as Weight) 138 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 139 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 140 | } 141 | fn approve_transfer() -> Weight { 142 | (48_708_000 as Weight) 143 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 144 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 145 | } 146 | fn transfer_approved() -> Weight { 147 | (108_476_000 as Weight) 148 | .saturating_add(T::DbWeight::get().reads(5 as Weight)) 149 | .saturating_add(T::DbWeight::get().writes(5 as Weight)) 150 | } 151 | fn cancel_approval() -> Weight { 152 | (49_157_000 as Weight) 153 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 154 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 155 | } 156 | fn force_cancel_approval() -> Weight { 157 | (56_862_000 as Weight) 158 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 159 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /runtime/westmint/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_balances 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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 | fn transfer() -> Weight { 32 | (79_601_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn transfer_keep_alive() -> Weight { 37 | (58_429_000 as Weight) 38 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn set_balance_creating() -> Weight { 42 | (29_124_000 as Weight) 43 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 44 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 45 | } 46 | fn set_balance_killing() -> Weight { 47 | (36_476_000 as Weight) 48 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 49 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 50 | } 51 | fn force_transfer() -> Weight { 52 | (78_772_000 as Weight) 53 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 54 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /runtime/westmint/src/weights/pallet_collator_selection.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_collator_selection 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_collator_selection 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_collator_selection. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_collator_selection::WeightInfo for WeightInfo { 31 | fn set_invulnerables(b: u32, ) -> Weight { 32 | (18_563_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((68_000 as Weight).saturating_mul(b as Weight)) 35 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 36 | } 37 | fn set_desired_candidates() -> Weight { 38 | (16_363_000 as Weight) 39 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 40 | } 41 | fn set_candidacy_bond() -> Weight { 42 | (16_840_000 as Weight) 43 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 44 | } 45 | fn register_as_candidate(c: u32, ) -> Weight { 46 | (71_196_000 as Weight) 47 | // Standard Error: 0 48 | .saturating_add((198_000 as Weight).saturating_mul(c as Weight)) 49 | .saturating_add(T::DbWeight::get().reads(4 as Weight)) 50 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 51 | } 52 | fn leave_intent(c: u32, ) -> Weight { 53 | (55_336_000 as Weight) 54 | // Standard Error: 0 55 | .saturating_add((151_000 as Weight).saturating_mul(c as Weight)) 56 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 57 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 58 | } 59 | fn note_author() -> Weight { 60 | (71_461_000 as Weight) 61 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 62 | .saturating_add(T::DbWeight::get().writes(4 as Weight)) 63 | } 64 | fn new_session(r: u32, c: u32, ) -> Weight { 65 | (0 as Weight) 66 | // Standard Error: 1_010_000 67 | .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) 68 | // Standard Error: 1_010_000 69 | .saturating_add((151_952_000 as Weight).saturating_mul(c as Weight)) 70 | .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) 71 | .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight))) 72 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(r as Weight))) 73 | .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /runtime/westmint/src/weights/pallet_multisig.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_multisig 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_multisig 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_multisig. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_multisig::WeightInfo for WeightInfo { 31 | fn as_multi_threshold_1(z: u32, ) -> Weight { 32 | (14_936_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 35 | } 36 | fn as_multi_create(s: u32, z: u32, ) -> Weight { 37 | (56_090_000 as Weight) 38 | // Standard Error: 1_000 39 | .saturating_add((63_000 as Weight).saturating_mul(s as Weight)) 40 | // Standard Error: 0 41 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 42 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 43 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 44 | } 45 | fn as_multi_create_store(s: u32, z: u32, ) -> Weight { 46 | (62_519_000 as Weight) 47 | // Standard Error: 1_000 48 | .saturating_add((66_000 as Weight).saturating_mul(s as Weight)) 49 | // Standard Error: 0 50 | .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) 51 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 52 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 53 | } 54 | fn as_multi_approve(s: u32, z: u32, ) -> Weight { 55 | (30_781_000 as Weight) 56 | // Standard Error: 0 57 | .saturating_add((111_000 as Weight).saturating_mul(s as Weight)) 58 | // Standard Error: 0 59 | .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) 60 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 61 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 62 | } 63 | fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { 64 | (60_393_000 as Weight) 65 | // Standard Error: 0 66 | .saturating_add((118_000 as Weight).saturating_mul(s as Weight)) 67 | // Standard Error: 0 68 | .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) 69 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 70 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 71 | } 72 | fn as_multi_complete(s: u32, z: u32, ) -> Weight { 73 | (81_704_000 as Weight) 74 | // Standard Error: 1_000 75 | .saturating_add((248_000 as Weight).saturating_mul(s as Weight)) 76 | // Standard Error: 0 77 | .saturating_add((5_000 as Weight).saturating_mul(z as Weight)) 78 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 79 | .saturating_add(T::DbWeight::get().writes(3 as Weight)) 80 | } 81 | fn approve_as_multi_create(s: u32, ) -> Weight { 82 | (55_585_000 as Weight) 83 | // Standard Error: 1_000 84 | .saturating_add((115_000 as Weight).saturating_mul(s as Weight)) 85 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 86 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 87 | } 88 | fn approve_as_multi_approve(s: u32, ) -> Weight { 89 | (33_483_000 as Weight) 90 | // Standard Error: 1_000 91 | .saturating_add((82_000 as Weight).saturating_mul(s as Weight)) 92 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 93 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 94 | } 95 | fn approve_as_multi_complete(s: u32, ) -> Weight { 96 | (154_732_000 as Weight) 97 | // Standard Error: 1_000 98 | .saturating_add((253_000 as Weight).saturating_mul(s as Weight)) 99 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 100 | .saturating_add(T::DbWeight::get().writes(3 as Weight)) 101 | } 102 | fn cancel_as_multi(s: u32, ) -> Weight { 103 | (104_447_000 as Weight) 104 | // Standard Error: 1_000 105 | .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) 106 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 107 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /runtime/westmint/src/weights/pallet_proxy.rs: -------------------------------------------------------------------------------- 1 | 2 | //! Autogenerated weights for pallet_proxy 3 | //! 4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_proxy 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_proxy. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_proxy::WeightInfo for WeightInfo { 31 | fn proxy(p: u32, ) -> Weight { 32 | (27_585_000 as Weight) 33 | // Standard Error: 1_000 34 | .saturating_add((203_000 as Weight).saturating_mul(p as Weight)) 35 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 36 | } 37 | fn proxy_announced(a: u32, p: u32, ) -> Weight { 38 | (61_093_000 as Weight) 39 | // Standard Error: 2_000 40 | .saturating_add((680_000 as Weight).saturating_mul(a as Weight)) 41 | // Standard Error: 2_000 42 | .saturating_add((201_000 as Weight).saturating_mul(p as Weight)) 43 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 44 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 45 | } 46 | fn remove_announcement(a: u32, p: u32, ) -> Weight { 47 | (39_494_000 as Weight) 48 | // Standard Error: 2_000 49 | .saturating_add((686_000 as Weight).saturating_mul(a as Weight)) 50 | // Standard Error: 2_000 51 | .saturating_add((1_000 as Weight).saturating_mul(p as Weight)) 52 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 53 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 54 | } 55 | fn reject_announcement(a: u32, p: u32, ) -> Weight { 56 | (39_817_000 as Weight) 57 | // Standard Error: 2_000 58 | .saturating_add((685_000 as Weight).saturating_mul(a as Weight)) 59 | // Standard Error: 2_000 60 | .saturating_add((1_000 as Weight).saturating_mul(p as Weight)) 61 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 62 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 63 | } 64 | fn announce(a: u32, p: u32, ) -> Weight { 65 | (54_835_000 as Weight) 66 | // Standard Error: 2_000 67 | .saturating_add((684_000 as Weight).saturating_mul(a as Weight)) 68 | // Standard Error: 2_000 69 | .saturating_add((205_000 as Weight).saturating_mul(p as Weight)) 70 | .saturating_add(T::DbWeight::get().reads(3 as Weight)) 71 | .saturating_add(T::DbWeight::get().writes(2 as Weight)) 72 | } 73 | fn add_proxy(p: u32, ) -> Weight { 74 | (37_625_000 as Weight) 75 | // Standard Error: 2_000 76 | .saturating_add((300_000 as Weight).saturating_mul(p as Weight)) 77 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 78 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 79 | } 80 | fn remove_proxy(p: u32, ) -> Weight { 81 | (36_945_000 as Weight) 82 | // Standard Error: 3_000 83 | .saturating_add((325_000 as Weight).saturating_mul(p as Weight)) 84 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 85 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 86 | } 87 | fn remove_proxies(p: u32, ) -> Weight { 88 | (35_128_000 as Weight) 89 | // Standard Error: 1_000 90 | .saturating_add((209_000 as Weight).saturating_mul(p as Weight)) 91 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 92 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 93 | } 94 | fn anonymous(p: u32, ) -> Weight { 95 | (51_624_000 as Weight) 96 | // Standard Error: 1_000 97 | .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) 98 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 99 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 100 | } 101 | fn kill_anonymous(p: u32, ) -> Weight { 102 | (37_469_000 as Weight) 103 | // Standard Error: 1_000 104 | .saturating_add((204_000 as Weight).saturating_mul(p as Weight)) 105 | .saturating_add(T::DbWeight::get().reads(1 as Weight)) 106 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /runtime/westmint/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_timestamp 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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 | fn set() -> Weight { 32 | (7_687_000 as Weight) 33 | .saturating_add(T::DbWeight::get().reads(2 as Weight)) 34 | .saturating_add(T::DbWeight::get().writes(1 as Weight)) 35 | } 36 | fn on_finalize() -> Weight { 37 | (4_303_000 as Weight) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime/westmint/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 3.0.0 5 | //! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` 6 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 128 7 | 8 | // Executed Command: 9 | // ./target/release/statemint 10 | // benchmark 11 | // --chain=statemint-dev 12 | // --execution=wasm 13 | // --wasm-execution=compiled 14 | // --pallet=pallet_utility 15 | // --extrinsic=* 16 | // --steps=50 17 | // --repeat=20 18 | // --raw 19 | // --output=./runtime/statemint/src/weights/ 20 | 21 | 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_utility. 29 | pub struct WeightInfo(PhantomData); 30 | impl pallet_utility::WeightInfo for WeightInfo { 31 | fn batch(c: u32, ) -> Weight { 32 | (15_408_000 as Weight) 33 | // Standard Error: 0 34 | .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) 35 | } 36 | fn as_derivative() -> Weight { 37 | (7_817_000 as Weight) 38 | } 39 | fn batch_all(c: u32, ) -> Weight { 40 | (16_520_000 as Weight) 41 | // Standard Error: 0 42 | .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /scripts/benchmarks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | steps=50 4 | repeat=20 5 | statemineOutput=./runtime/statemine/src/weights/ 6 | statemintOutput=./runtime/statemint/src/weights/ 7 | statemineChain=statemine-dev 8 | statemintChain=statemint-dev 9 | pallets=( 10 | pallet_assets 11 | pallet_balances 12 | pallet_collator_selection 13 | pallet_multisig 14 | pallet_proxy 15 | pallet_timestamp 16 | pallet_utility 17 | ) 18 | 19 | for p in ${pallets[@]} 20 | do 21 | ./target/release/statemint benchmark \ 22 | --chain=$statemineChain \ 23 | --execution=wasm \ 24 | --wasm-execution=compiled \ 25 | --pallet=$p \ 26 | --extrinsic='*' \ 27 | --steps=$steps \ 28 | --repeat=$repeat \ 29 | --raw \ 30 | --output=$statemineOutput 31 | 32 | ./target/release/statemint benchmark \ 33 | --chain=$statemintChain \ 34 | --execution=wasm \ 35 | --wasm-execution=compiled \ 36 | --pallet=$p \ 37 | --extrinsic='*' \ 38 | --steps=$steps \ 39 | --repeat=$repeat \ 40 | --raw \ 41 | --output=$statemintOutput 42 | 43 | done -------------------------------------------------------------------------------- /scripts/generate_keys/keys.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const { exit } = require("process"); 3 | const { xxhashAsHex } = require("@polkadot/util-crypto"); 4 | 5 | if (!process.argv[2] || !process.argv[3]) { 6 | console.log("usage: node generate_keys "); 7 | exit(); 8 | } 9 | 10 | const input = process.argv[2]; 11 | const output = process.argv[3]; 12 | fs.readFile(input, "utf8", (err, data) => { 13 | if (err) { 14 | console.log(`Error reading file from disk: ${err}`); 15 | exit(1); 16 | } 17 | 18 | const toHex = (str) => "0x" + Buffer.from(str, "ascii").toString("hex"); 19 | const startsWith = (str, arr) => arr.some((test) => str.startsWith(test)); 20 | 21 | const filter_prefixes = [ 22 | // substrate well known keys 23 | ":code", 24 | ":heappages", 25 | ":extrinsic_index", 26 | ":changes_trie", 27 | ":child_storage", 28 | ] 29 | .map(toHex) 30 | .concat( 31 | // shell pallets 32 | ["System", "ParachainSystem", "ParachainInfo", "CumulusXcm"].map((str) => 33 | xxhashAsHex(str) 34 | ) 35 | ) 36 | .concat([ 37 | // polkadot well known keys; don't seem necessary, but just to make sure 38 | "0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385", 39 | "0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e", 40 | "0x6a0da05ca59913bc38a8630590f2627cb6604cff828a6e3f579ca6c59ace013d", 41 | "0x6a0da05ca59913bc38a8630590f2627c1d3719f5b0b12c7105c073c507445948", 42 | "0x6a0da05ca59913bc38a8630590f2627cf12b746dcf32e843354583c9702cc020", 43 | "0x63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce5", 44 | ]); 45 | 46 | const spec = JSON.parse(data); 47 | 48 | const genesis = Object.fromEntries( 49 | Object.entries(spec.genesis.raw.top).filter( 50 | ([key, value]) => !startsWith(key, filter_prefixes) 51 | ) 52 | ); 53 | fs.writeFileSync(output, JSON.stringify(genesis)); 54 | }); 55 | -------------------------------------------------------------------------------- /scripts/generate_keys/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "keys", 3 | "version": "1.0.0", 4 | "description": "generate and filter storage keys", 5 | "main": "keys.js", 6 | "scripts": { 7 | "keys": "node keys.js" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@polkadot/util-crypto": "^6.5.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /scripts/init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "*** Initializing WASM build environment" 6 | 7 | if [ -z $CI_PROJECT_NAME ] ; then 8 | rustup update nightly 9 | rustup update stable 10 | fi 11 | 12 | rustup target add wasm32-unknown-unknown --toolchain nightly 13 | --------------------------------------------------------------------------------